Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Disabled user

Author  Topic 

Peter99
Constraint Violating Yak Guru

498 Posts

Posted - 2012-07-05 : 18:51:24
Hi,

Under users tab, one user shows disabled (red down arrow). This user has login on server level which is enabled. I want to enable this user on db level but cannot. I right clicked on it but there is no option to disable it. I searched net but did not find any option to enable db user. There are some command to enable login but not users. Any help will be appreciated.

Thanks

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-07-06 : 10:15:44
Is there perhaps a SID mismatch between the user and the login? You can look up the SIDs like shown below, and they should match:
USE MyDB
GO
SELECT SID FROM sys.syslogins WHERE NAME = 'testsql';
SELECT SID FROM sys.sysusers WHERE NAME = 'testsql';
If there is a mismatch, use sp_change_users_login to fix it. http://msdn.microsoft.com/en-us/library/ms174378.aspx
Go to Top of Page

Peter99
Constraint Violating Yak Guru

498 Posts

Posted - 2012-07-06 : 10:34:39
Thanks for reply.
Go to Top of Page

Peter99
Constraint Violating Yak Guru

498 Posts

Posted - 2012-07-06 : 10:40:47

I just created another user with same name. Granted it permissions. Now it is working.

My question is:

How to enable a user which is in disable state. I am asking about user not login.

Is there any command?

For login we can use alter login <login name> enable/disable

How to do the same thing with user? Suppose I don't want to delete user but I just want to disable it?

Thanks

Go to Top of Page

Krishna_DBA
Starting Member

4 Posts

Posted - 2012-07-09 : 15:00:05
run the below command to enable the user on that database

sp_grantdbaccess <username>
Go to Top of Page

Peter99
Constraint Violating Yak Guru

498 Posts

Posted - 2012-07-14 : 19:35:27
another option is grant user connect privileges. Right click on user, go to properties, click permission and click connect.
Go to Top of Page
   

- Advertisement -