Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSadduser_implicit_ntlogin

  No additional text.


Syntax

-- NOTE: FOR INTERNAL SECURITY USE ONLY!
--      DO NOT DOCUMENT OR USE!

create procedure sys.sp_MSadduser_implicit_ntlogin
    @ntname         sysname
AS
	declare @ret		int
	
    -- NO-OP IF LOGIN ALREADY EXISTS 
	if database_principal_id(@ntname) is null
	begin

        -- MUST BE NT NAME 
        if (charindex('\', @ntname) = 0)
            return (1)

	    declare	@newsid	varbinary(85),
				@isgrp	bit

        -- OBTAIN NT SID FOR THIS USER (SET STATUS BITS) 
	    select @newsid = get_sid('\U'+@ntname)	    -- NT user
	    if (@newsid is Null)
	    begin
	        select @isgrp = 1, @newsid = get_sid('\G'+@ntname)    -- NT group
	        IF (@newsid IS Null)
		        return (1)
	    end
        else
            select @isgrp = 0	-- NTUser

        -- FAIL IF SID ALREADY IN SYSUSERS 
        if exists (select sid from sysusers where sid = @newsid)
            return (1)

		BEGIN TRANSACTION

        -- ADD IMPLICIT SYSUSERS ENTRY & INVALIDATE UID CACHE FOR THIS DB 
		EXEC %%Owner().NewUserOrGroup(Name = @ntname, SID = @newsid,
			IsExternal = 1, IsGroup = @isgrp)

		-- RETURN FAILURE/SUCCESS 
		select @ret = @@error
		if @ret <> 0
		begin
			COMMIT TRANSACTION
			return @ret
		end

		COMMIT TRANSACTION
    end

    -- SUCCESS 
    return (0) -- sp_MSadduser_implicit_ntlogin

 
Last revision 2008RTM
See also

  sp_addrolemember (Procedure)
sp_changeobjectowner (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