简体   繁体   English

sp_addlinkedsrvlogin / 还原

[英]sp_addlinkedsrvlogin / revert

I am a sysadmin on the two SQL server machines (obviously not a very good one).我是两台 SQL 服务器机器的系统管理员(显然不是一个很好的机器)。 I linked the servers by using sp_addlinkedserver.我使用 sp_addlinkedserver 链接了服务器。 I was successful, and my query ran fine as T-SQL and a stored procedure.我成功了,我的查询作为 T-SQL 和存储过程运行良好。 I tried to setup my stored procedure to run as a SQL Server Agent job.我尝试将我的存储过程设置为作为 SQL 服务器代理作业运行。 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.作为Sa,我可以做到这一点。 I can't add the linked server with my user anymore, gotta do that with sa.我不能再用我的用户添加链接服务器,必须用 sa 来做。

Basically, how do I restore my permissions?基本上,我如何恢复我的权限? I'm still sysadmin in both SQL instances.我仍然是 SQL 实例中的系统管理员。

thanks谢谢

So I did figure it out myself.所以我自己也想通了。 I logged in as SA to perform the following command.我以 SA 身份登录以执行以下命令。

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.这成功了,但我确实必须以域用户的身份关闭所有活动连接,重新启动 SSMS 才能让我获得权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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