Home Microsoft SQL Server DigiMailing Contact
    Keyword



sys.sp_MSrepl_getpublisherinfo

  No additional text.


Syntax


-- Name:
--		sp_MSrepl_getpublisherinfo

-- Description:
--		Retrieve info about a publisher.
--		If output param is NULL, returns new value
--		If output is '%', returns a result set

-- Returns:
--		0 == Failed
--		1 == Succeed

-- Security:
--		public

-- Notes:
--		Primarily used for determining a pubtype as
--		well as building an RPC header for executing
--		commands in the correct context.

--		@publisher is rejected for MSSQLSERVER publications.
--		This is to prevent any unexpected security issues with
--		supplying the publisher name.  HREPL is designed from
--		the start to have this parameter and the code paths are
--		expecting to validate publisher names.  SQL Server only
--		code has no notion of this and generally needs to trust
--		the publisher name implicitly.


CREATE PROCEDURE sys.sp_MSrepl_getpublisherinfo
(
    @publisher sysname = NULL,
    @publisher_type sysname = NULL OUTPUT,
    @publisher_id int = NULL OUTPUT,
    @distributor sysname = NULL OUTPUT,
    @distribdb sysname = NULL OUTPUT,
    @rpcheader nvarchar(4000) = NULL OUTPUT,
    @hreplOnly bit = 0,
    @skipSecurityCheck bit = 0
)
AS
BEGIN
    set nocount on
    IF @publisher IS NULL
    BEGIN
        -- SQL Server
        -- Set output parameters
        SELECT  @publisher_type = N'MSSQLSERVER',
                    @publisher_id = 0,
                    @distributor = NULL,
                    @distribdb = NULL,
                    @rpcheader = N''
    END
    ELSE
    BEGIN
        -- HREPL publisher
        DECLARE @retcode int
                    ,@loc_pubtype sysname
                    ,@loc_publisherid int
                    ,@loc_distributor sysname
                    ,@loc_distribdb sysname

        SELECT  @loc_pubtype = NULL,
                    @loc_publisherid = 0,
                    @loc_distributor = NULL,
                    @loc_distribdb = NULL

        IF @skipSecurityCheck = 0
        BEGIN
            -- Verify that the user is 'sysadmin' at the distributor
            -- HREPL always requires sysadmin.  HREPL is implied when @publisher
            -- is provided.  To avoid info disclosure, do a security check right
            -- now.  This prevents returning info if you shouldn't know about it.
            IF (IS_SRVROLEMEMBER('sysadmin') = 0)
            BEGIN
                RAISERROR(21089,16,-1)
                RETURN (1)
            END
        END

        -- Verify publisher name makes sense
        EXECUTE @retcode = sys.sp_validname @publisher
        IF @@ERROR <> 0 OR @retcode <> 0
            RETURN (1)

        -- Find distribution databse
        EXEC @retcode = sys.sp_MSrepl_getdistributorinfo    @publisher      = @publisher,
                                                                                @distributor    = @loc_distributor OUTPUT,
                                                                                @distribdb      = @loc_distribdb   OUTPUT,
                                                                                @publisher_type = @loc_pubtype     OUTPUT,
                                                                                @publisher_id   = @loc_publisherid OUTPUT
        IF @@error <> 0 OR @retcode <> 0 or (@loc_distributor IS NULL) or (@loc_distribdb IS NULL)
        BEGIN
            RAISERROR (14080, 16, -1, @publisher)
            RETURN (1)
        END

        IF @loc_pubtype = 'MSSQLSERVER'
        BEGIN
            IF @hreplOnly = 1
            BEGIN
                -- Publisher param for HREPL only
                RAISERROR(21774, 16, -1, @publisher)
            END
            ELSE
            BEGIN
                -- Publisher parameter only valid for HREPL
                RAISERROR(21606, 16, -1, '@publisher', 'NULL')
            END

            RETURN (1)
        END

        -- Verify that distributor is local.  If not, reject with error
        IF UPPER(@loc_distributor) != CONVERT(sysname, SERVERPROPERTY('ServerName'))
        BEGIN
            RAISERROR (21671, 16, -1)
            RETURN (1)
        END

        -- Set output parameters
        SELECT @publisher_type = @loc_pubtype,
               @publisher_id = @loc_publisherid,
               @distributor = @loc_distributor,
               @distribdb = @loc_distribdb,
               @rpcheader = QUOTENAME(@loc_distribdb) + N'.'
    END -- HREPL publisher block
    -- all done
    RETURN 0
END

 
Last revision 2008RTM
See also

  sp_addarticle (Procedure)
sp_addlogreader_agent (Procedure)
sp_addpublication (Procedure)
sp_addpublication_snapshot (Procedure)
sp_addpushsubscription_agent (Procedure)
sp_addscriptexec (Procedure)
sp_addsubscriber (Procedure)
sp_addsubscriber_schedule (Procedure)
sp_addsubscription (Procedure)
sp_articlecolumn (Procedure)
sp_articlefilter (Procedure)
sp_articleview (Procedure)
sp_article_validation (Procedure)
sp_browsesnapshotfolder (Procedure)
sp_changearticle (Procedure)
sp_changearticlecolumndatatype (Procedure)
sp_changelogreader_agent (Procedure)
sp_changepublication (Procedure)
sp_changepublication_snapshot (Procedure)
sp_changesubscriber (Procedure)
sp_changesubscriber_schedule (Procedure)
sp_changesubscription (Procedure)
sp_changesubstatus (Procedure)
sp_checkOraclepackageversion (Procedure)
sp_copysnapshot (Procedure)
sp_droparticle (Procedure)
sp_droppublication (Procedure)
sp_dropsubscriber (Procedure)
sp_dropsubscription (Procedure)
sp_enable_heterogeneous_subscription (Procedure)
sp_enumfullsubscribers (Procedure)
sp_getOraclepackageversion (Procedure)
sp_getsubscription_status_hsnapshot (Procedure)
sp_get_Oracle_publisher_metadata (Procedure)
sp_helparticle (Procedure)
sp_helparticlecolumns (Procedure)
sp_helplogreader_agent (Procedure)
sp_helppublication (Procedure)
sp_helppublication_snapshot (Procedure)
sp_helpsubscriberinfo (Procedure)
sp_helpsubscription (Procedure)
sp_helpxactsetjob (Procedure)
sp_IHflushmetadata (Procedure)
sp_IHsyncmetadata (Procedure)
sp_IHValidateRowFilter (Procedure)
sp_IHXactSetJob (Procedure)
sp_marksubscriptionvalidation (Procedure)
sp_MSactivate_auto_sub (Procedure)
sp_MSdrop_replcom (Procedure)
sp_MSget_shared_agent (Procedure)
sp_MSget_synctran_commands (Procedure)
sp_MSrepl_helparticlermo (Procedure)
sp_MSrepl_snapshot_helparticlecolumns (Procedure)
sp_posttracertoken (Procedure)
sp_publicationsummary (Procedure)
sp_publication_validation (Procedure)
sp_publisherproperty (Procedure)
sp_refreshsubscriptions (Procedure)
sp_refresh_heterogeneous_publisher (Procedure)
sp_reinitsubscription (Procedure)
sp_replincrementlsn (Procedure)
sp_schemafilter (Procedure)
sp_scriptpublicationcustomprocs (Procedure)
sp_setOraclepackageversion (Procedure)
sp_startpublication_snapshot (Procedure)
sp_startpushsubscription_agent (Procedure)
sp_stoppublication_snapshot (Procedure)
sp_stoppushsubscription_agent (Procedure)
sp_subscriptionsummary (Procedure)
sp_validatecache (Procedure)
sp_verifypublisher (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