Ward Minson
asked on
Alter logins accross many servers without cms
is it possible to do an 'ALTER LOGIN [loginname] DISABLE' using either openrowsource or opendatasource?
And if so how can i do this?
I have a list of servers that i need to change all users with a specific name to disabled.
And if so how can i do this?
I have a list of servers that i need to change all users with a specific name to disabled.
You can use EXEC with a server link to execute remote.
ASKER
Qlemo
could you show me an example of what you are suggesting?
could you show me an example of what you are suggesting?
declare @name = nvarchar(100)
set @name = 'whoever'
exec ('ALTER LOGIN ' + @name + ' DISABLE') at LinkedServerName
You can code the user name literally into the command, of course, if you don't need it to be variable.
ASKER
is there any other way with out creating a linked server?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am planning on creating the connection string dynamically and then run the alter on the server that needs the change.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can use OPENDATASOURCE. The complete guide to this command is here in MSDN.
ASKER
this worked with my original script very well thank you.