Home Microsoft SQL Server DigiMailing iRN Contact


  No additional text.


-- Name:
--          sp_MSrepl_DistDBPALAccess

-- Description:
--          This stored procedure runs in a distribution database.  It returns
--          Success (0) if the current user has PAL access to the distribution
--          database.  The user must either be a member of the 'db_owner' or
--          'replmonitor' role of the distribution database or must be in the PAL
--          of a publication associated with a publication that uses the current
--          database as its distribution database.

--          If @publisher is specified, only this publisher is checked.
--          If @publisher is not specified, all publishers are checked.

--          If @publication is specified, only this publication is checked.
--          If @publication is not specified, all publications are checked.

--          If @publication is specified, @publisher must be specified as well.

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

-- Returns:
--          Success (0) or failure (1)

-- Owner:

create procedure sys.sp_MSrepl_DistDBPALAccess
    @publisher sysname = N'%',
    @publication sysname = N'%'
    set nocount on
    declare @isntname int
                ,@sid varbinary(85)

    -- If @publication is specified, @publisher must be specified as well
    if @publication <> N'%' and @publisher = N'%'
    -- if the user is a member of either the db_owner or the replmonitor
    -- role return success
    if is_member(N'db_owner') = 1 or isnull(is_member(N'replmonitor'),0) = 1
    -- initialize
    select @sid = suser_sid()

    select @isntname = isntname
    from master.dbo.syslogins
    where sid = @sid and hasaccess = 1

    if @isntname is null and @sid is not null
        select @isntname = 1
    -- if the user is in the PAL of the/any publication associated
    -- with the/any publisher making use of this distribution database
    -- return success
    if exists ( select distinct d.distribution_db
                from MSpublication_access a,
                     MSpublications p,
                     master.dbo.sysservers s,
                     msdb.dbo.MSdistpublishers d
                where a.publication_id = p.publication_id
                and   p.publication LIKE @publication
                and   (a.sid = @sid or
                    (@isntname = 1) and (exists (select * from master..syslogins
                        where sid = a.sid and isntgroup = 1 and is_member(a.login) = 1))
                and   p.publisher_id = s.srvid
                and   UPPER(s.srvname collate database_default) = d.name collate database_default
                and   d.distribution_db = DB_NAME()
                and   UPPER(s.srvname collate database_default) LIKE UPPER(@publisher))
    -- if we are here - no PAL access

Last revision 2008RTM
See also

  sp_helpdistpublisher (Procedure)
sp_helpdistributiondb (Procedure)
sp_MSdrop_replcom (Procedure)
sp_MShelp_profile (Procedure)
sp_MSrepl_DistributorPALAccess (Procedure)


  Query a named instance
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
Zoekmachine optimalisatie
SQL Servers hidden objects
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
sIFR; de combinatie tussen HTML en Flash