Lingua

IAuthenticationExtension.GetUserInfo(IIdentity, IntPtr) Metodo

Definizione

Restituisce l'identità attuale dell'utente.

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)

Parametri

userIdentity
IIdentity

[fuori] L'identità dell'utente attuale. Il valore di IIdentity può apparire in un'interfaccia utente e dovrebbe essere leggibile per l'umano.

userId
IntPtr

nativeint

[fuori] Un token dell'account utente. Questo token è utilizzato principalmente dal server di report come handle per un account Windows a supporto della gestione delle credenziali per l'autenticazione Windows.

Esempio

Il seguente esempio di codice implementa il GetUserInfo metodo restituendo l'identità principale della richiesta HTTP corrente.

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;  
}  

Commenti

Il server di report chiama il GetUserInfo metodo per ogni richiesta per recuperare l'identità utente corrente.

Si applica a