Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



dbo.sp_validate_user

  No additional text.


Syntax
CREATE PROCEDURE [dbo].[sp_validate_user]
    @send_request_user sysname,
    @user_sid varbinary(85) OUTPUT
  WITH EXECUTE AS 'dbo'
AS
BEGIN
    SET NOCOUNT ON
    -- And make sure ARITHABORT is on. This is the default for yukon DB's
    SET ARITHABORT ON

    declare @groupSid varbinary(85)
    declare @temp table
    ([account name] sysname,
    [type] char(8),
    [privilege] char(9),
    [mapped login name] sysname,
    [permission path] sysname)

    SET @user_sid = NULL
    SET @groupSid = NULL

    -- Lookup the Windows Group membership, if any, that grants this
    -- user access to SQL Server. xp_logininfo may fail if the sql
    -- server service account cannot talk to the domain controller to
    -- validate the windows username, or it may fail if the
    -- @send_request_user is not a valid windows user or group name.
    BEGIN TRY
        insert @temp exec master.dbo.xp_logininfo @send_request_user
        select @groupSid = suser_sid([permission path]) from @temp
    END TRY
    BEGIN CATCH
        RETURN 2
    END CATCH

    -- Lookup a default profile for the Group. If there is one,
    -- then use the group's mail profile.
    IF ((@groupSid IS NOT NULL) AND (EXISTS(SELECT *
                                            FROM msdb.dbo.sysmail_principalprofile as pp
                                            WHERE (pp.is_default = 1) AND
                                            (pp.principal_sid = @groupSid))))
    BEGIN
        SET @user_sid = @groupSid
        RETURN 0
    END
    RETURN 1
END

 
Last revision 2008RTM
See also

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