The meta data is from an SQL 2012 Server.
I have posted alot more, find the whole list here.
Goto Definition or MetaData
Definition:
sys.sp_droplinkedsrvlogin(nvarchar @rmtsrvname, nvarchar @locallogin)
MetaData:
create procedure sys.sp_droplinkedsrvlogin @rmtsrvname sysname, @locallogin sysname as declare @localid int -- DISALLOW USER TRANSACTION set implicit_transactions off if @@trancount > 0 begin raiserror(15002,-1,-1,'sys.sp_droplinkedsrvlogin') return (1) end -- CHECK PERMISSIONS if not (has_perms_by_name(null, null, 'alter any login') = 1) begin EXEC %%System().AuditEvent(ID = 1380207692, Success = 0, TargetLoginName = @locallogin, TargetUserName = NULL, Role = NULL, Object = NULL, Provider = NULL, Server = @rmtsrvname) raiserror(15247,-1,-1) return (1) end else EXEC %%System().AuditEvent(ID = 1380207692, Success = 1, TargetLoginName = @locallogin, TargetUserName = NULL, Role = NULL, Object = NULL, Provider = NULL, Server = @rmtsrvname) BEGIN TRAN -- VALIDATE/LOCK SERVER NAME -- EXEC %%LinkedServer ( Name = @rmtsrvname ) . Lock ( Exclusive = 1 ) IF @@ERROR <> 0 begin ROLLBACK TRAN raiserror(15015,-1,-1,@rmtsrvname) return (1) end -- CHECK LOCAL USER NAME IF GIVEN select @localid = 0 if @locallogin is not null begin -- share-lock the local login EXEC %%LocalLogin ( Name = @locallogin ) . Lock ( Exclusive = 0 ) IF @@ERROR = 0 select @localid = principal_id from sys.server_principals where name = @locallogin and type in ('S', 'U') if @localid = 0 begin -- THERE WILL BE NO LinkedLogins, SO ONLY AN ERROR IF NO NT-NAME OUT THERE -- IF suser_sid(@locallogin) IS NULL BEGIN ROLLBACK TRAN raiserror(15007,-1,-1,@locallogin) return (1) END -- "SUCCESS" -- COMMIT TRAN return(0) end end -- IF MAPPING EXISTS FOR THIS SID, REMOVE IT -- IF EXISTS (SELECT * FROM sys.linked_logins WHERE server_id IN (SELECT server_id FROM sys.servers where name = @rmtsrvname) AND local_principal_id = @localid) BEGIN EXEC %%LinkedServer(Name=@rmtsrvname).RemoveLinkedLogin(LocalID=@localid) END -- EMDEventType(x_eet_Drop_Linked_Server_Login), EMDUniversalClass(x_eunc_Linked_Server), src major id, src minor id, src name -- -1 means ignore target stuff, target major id, target minor id, target name, -- # of parameters, 5 parameters EXEC %%System().FireTrigger(ID = 236, ID = 102, ID = 0, ID = 0, Value = @rmtsrvname, ID = 101, ID = @localid, ID = 0, Value = NULL, ID = 2, Value = @rmtsrvname, Value = @locallogin, Value = NULL, Value = NULL, Value = NULL, Value = NULL, Value = NULL) -- SUCCESS -- COMMIT TRAN return(0) -- sp_droplinkedsrvlogin
No comments:
Post a Comment