简体   繁体   中英

sp_addlinkedsrvlogin / revert

I am a sysadmin on the two SQL server machines (obviously not a very good one). I linked the servers by using sp_addlinkedserver. I was successful, and my query ran fine as T-SQL and a stored procedure. I tried to setup my stored procedure to run as a SQL Server Agent job. It was here that it was failing. I tried making a user on both servers the owner, but it was still failing. I did some reading and I wanted to add a mapped user. I ran the following command, not thinking it through, and now my user is messed up. I keep getting permission issues.

EXEC sp_addlinkedsrvlogin 
    @rmtsrvname = 'servername', 
    @useself = 'true',
    @locallogin = 'null

How do I revert this back? I tried dropping the linked server and logins... my user doesn't have that permission anymore. I can do that as Sa. I can't add the linked server with my user anymore, gotta do that with sa.

Basically, how do I restore my permissions? I'm still sysadmin in both SQL instances.

thanks

So I did figure it out myself. I logged in as SA to perform the following command.

EXEC sp_droplinkedsrvlogin
    @rmtsrvname = 'remoteserver',
    @locallogin = 'domain\user'

this did the trick, but I did have to close out of all active connections as the domain user, restart SSMS in order for me permissions to get returned.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM