Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_IHCheckPublisherLogin

  No additional text.


Syntax


-- Name:
--          sp_IHCheckPublisherLogin

-- Description:
--          Verify a linked server login mapping exists for the specified
--			login

-- Input/Output:
--			@publisher	Publisher server with a linked server to
--						check logins for.  Returns server name in
--						same case as it is stored in sysservers.
--						This is useful to make sure that it is in
--						the correct case for usage in distributed
--						query operations

-- Security:
--          Internal
-- Requires Certificate signature for catalog access

-- Returns:
--          1 == No login mapping exists
--			0 == Login mapping exists


CREATE PROCEDURE sys.sp_IHCheckPublisherLogin
(
	@publisher sysname OUTPUT
)
AS
BEGIN
    DECLARE @retcode int

    -- Find linked server name (with correct case setting)
	SELECT	@publisher = srvname
	FROM	master.sys.sysservers
	WHERE	UPPER(srvname  collate database_default) = UPPER(@publisher) collate database_default

	-- Verify linked server exists
	IF @publisher IS NULL
	BEGIN
		RAISERROR(21600, 16, -1, @publisher)
		RETURN (1)
	END

	-- Verify login mapping exists for publisher admin account
	IF NOT EXISTS
	(
		SELECT	principal_id
		FROM	master.sys.server_principals sp,
				master.sys.linked_logins ll,
				master.sys.servers s,
				msdb.dbo.MSdistpublishers msdp
		WHERE	sp.principal_id	= ll.local_principal_id
		  AND	s.server_id		= ll.server_id
		  AND	ll.remote_name	= msdp.login
		  AND	UPPER(s.name collate database_default)	= UPPER(msdp.name collate database_default)
		  AND	UPPER(s.name collate database_default)	= UPPER(@publisher) collate database_default
		  AND	sp.name			= SUSER_SNAME(0x01)
		UNION
		SELECT	principal_id
		FROM	master.sys.server_principals sp,
				master.sys.linked_logins ll,
				master.sys.servers s,
				msdb.dbo.MSdistpublishers msdp
		WHERE	sp.principal_id			= ll.local_principal_id
		  AND	s.server_id				= ll.server_id
		  AND	ll.uses_self_credential	= 1
		  AND	msdp.security_mode		= 1
		  AND	UPPER(s.name collate database_default)	= UPPER(msdp.name collate database_default)
		  AND	UPPER(s.name collate database_default)	= UPPER(@publisher) collate database_default
		  AND	sp.name			= SUSER_SNAME(0x01)
	)
        BEGIN
        	DECLARE @login sysname
        	SET @login = suser_sname()
        	RAISERROR(21681, 16, -1, @login, @publisher)
        	RETURN (1)
        END

	RETURN (0)
END

 
Last revision 2008RTM
See also

  sp_IHquery (Procedure)
sp_MSdrop_replcom (Procedure)
sp_ORAremotequery (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash