Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSrevokeconnectreplication

  No additional text.


Syntax

-- Name:
--        sp_MSrevokeconnectreplication

-- Description:
--        This procedure will revoke "connect replication" for the passed in user.
--        If the user is in the PAL for another publication in the same database then the
--        permission is not revoked.
--        This permission is required for NFR to be honored.

-- Parameters:

-- Returns:
--        0 - succeeded
--        1 - failed

-- Result:
--        None

-- Security:


create procedure sys.sp_MSrevokeconnectreplication
(
    @publisher sysname,
    @publisher_db sysname,
    @login sysname,
    @user sysname
)
as
begin
    DECLARE @distribdb          sysname,
                @distproc       nvarchar (300),
                @command        nvarchar(400),
                @proc           nvarchar(524),
                @retcode	    int,
                @dist_rpcname   sysname,
                @publisher_type sysname,
                @loc_publisher  sysname

    DECLARE @curuser_publications TABLE
    (
        publisher_db 	sysname collate database_default not null,
        publication     sysname collate database_default not null
    )

    -- Set publisher name if not supplied
    select @loc_publisher = case when (@publisher is null) then publishingservername()
                                                else @publisher end

    -- Get publisher info
    EXEC @retcode = sys.sp_MSrepl_getdistributorinfo    @publisher      = @loc_publisher,
                                                        @rpcsrvname     = @dist_rpcname   OUTPUT,
                                                        @distribdb      = @distribdb      OUTPUT,
                                                        @publisher_type = @publisher_type OUTPUT

    IF @@error <> 0
    BEGIN
         RAISERROR (14071, 16, -1)
         return (1)
    END

    IF @retcode <> 0 OR @distribdb IS NULL OR @dist_rpcname IS NULL
    BEGIN
        RAISERROR (14071, 16, -1)
        return(1)
    END



    SELECT @proc = case when (@dist_rpcname IS NOT NULL) THEN quotename(@dist_rpcname) + N'.' else N' ' end
                            + quotename(@distribdb) + N'.sys.sp_MSpublication_access'
    
    -- Get accessible publication list.
    
    insert into @curuser_publications
    EXEC @retcode = @proc
                    @publisher = @publisher,
                    @operation = N'get_publications',
                    @login = @login


    
    -- Revoke connect replication permission if the user is not in the PAL of any other
    -- publication on this publisherdb
    
    if not exists (select * from @curuser_publications where publisher_db = @publisher_db)
    begin
        select @command = N'revoke connect replication to ' + quotename(@user)
        exec(@command)
    end

    return 0
end

 
Last revision 2008RTM
See also

  sp_revoke_publication_access (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