I need to disable some user accounts within a sql server version 2000. the following sql command is giving me an " incorrect syntax near 'Login' " error. The user name is valid and spelled correctly so I'm wondering if the command syntax is different for version 2000.
ALTER LOGIN exampleuser DISABLE
-
SQL Server 2000 doesn't have the ALTER LOGIN statement. So to be able to disable the login you'll have to call the sp_denylogin procedure instead.
EXEC sp_denylogin 'exampleuser'or
EXEC sp_revokelogin 'exampleuser'To give them back access again you should use
EXEC sp_grantlogin 'exampleuser'Note:
sp_denylogin,sp_revokeloginandsp_grantloginonly works on Windows accounts and groups.To be able to deny pure SQL Server logins, it seems like the only option is to remove that login completely with
EXEC sp_droplogin 'exampleuser'but to enable it again, it needs to be re-created with
EXEC sp_addlogin 'exampleuser', 'examplepassword'or just remove that logins access to the current database with
EXEC sp_revokedbaccess 'exampleuser'MG : Do you know what the command is to enable the account after it's been disabled?MG : Is this method only valid for Windows NT user or groups?Jimmy Stenke : To be honest. I'm not entirely sure. They should apply to both SQL Server logins and Windows NT users.MG : This command fails when i try to use it on a non winders nt user :( msg: windows nt user or group 'exampleuser' not found. check the name again.Jimmy Stenke : hmm, ok, that I didn't know. Then I think the only option you can do is use the sp_droplogin procedure and remove the user login completelyJimmy Stenke : Alternatively, you can remove the user from each of the databases with sp_revokedbaccess. That will stop them from entering any databases, even if they still can access the cluster.MG : Thank you for your help. much appreciated! -
sp_revokelogin will remove the login entry. However , this proc has been deprecated in favour of drop login
But note that both of these will not disable the user but delete the login.
Your ALTER LOGIN approach is correct
ALTER LOGIN exampleuser DISABLE;works with sql server 2008 atleast.
Jimmy Stenke : In SQL Server 2000 it is not deprecated, instead the only way to do it. CREATE LOGIN, ALTER LOGIN and DROP LOGIN was introduced in 2005
0 comments:
Post a Comment