Condividi tramite


IAuthenticationExtension.GetUserInfo(IIdentity, IntPtr) Method

Definition

Returns the current user identity.

public:
 void GetUserInfo([Runtime::InteropServices::Out] System::Security::Principal::IIdentity ^ % userIdentity, [Runtime::InteropServices::Out] IntPtr % userId);
public void GetUserInfo (out System.Security.Principal.IIdentity userIdentity, out IntPtr userId);
abstract member GetUserInfo : IIdentity * nativeint -> unit
Public Sub GetUserInfo (ByRef userIdentity As IIdentity, ByRef userId As IntPtr)

Parameters

userIdentity
IIdentity

[out] The identity of the current user. The value of IIdentity may appear in a user interface and should be human readable.

userId
IntPtr

nativeint

[out] A user account token. This token is primarily used by the report server as a handle to a Windows account in support of credential management for Windows Authentication.

Examples

The following example code implements the GetUserInfo method by returning the principal identity of the current HTTP request.

Public Sub GetUserInfo(ByRef userIdentity As IIdentity, ByRef userId As IntPtr)  
   ' If the current user identity is not null,  
   ' set the userIdentity parameter to that of the current user   
   If Not (HttpContext.Current Is Nothing) And Not (HttpContext.Current.User Is Nothing) Then  
      userIdentity = HttpContext.Current.User.Identity  
   Else  
      userIdentity = Nothing  
   End If   
   ' initialize a pointer to the current user id to zero  
   userId = IntPtr.Zero  
End Sub 'GetUserInfo  
public void GetUserInfo(out IIdentity userIdentity, out IntPtr userId)  
{  
   // If the current user identity is not null,  
   // set the userIdentity parameter to that of the current user   
   if (HttpContext.Current != null  
       && HttpContext.Current.User != null)  
   {  
       userIdentity = HttpContext.Current.User.Identity;  
   }  
   else  
      userIdentity = null;  

   // initialize a pointer to the current user id to zero  
   userId = IntPtr.Zero;  
}  

Remarks

The report server calls the GetUserInfo method for each request to retrieve the current user identity.

Applies to