Lenguaje

IAuthenticationExtension.GetUserInfo(IIdentity, IntPtr) Método

Definición

Devuelve la identidad actual del usuario.

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)

Parámetros

userIdentity
IIdentity

[fuera] La identidad del usuario actual. El valor de IIdentity puede aparecer en una interfaz de usuario y debe ser legible para humanos.

userId
IntPtr

nativeint

[fuera] Un token de cuenta de usuario. Este token es utilizado principalmente por el servidor de informes como un handle para una cuenta de Windows en soporte para la gestión de credenciales para la autenticación de Windows.

Ejemplos

El siguiente código de ejemplo implementa el GetUserInfo método devolviendo la identidad principal de la solicitud HTTP actual.

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

Comentarios

El servidor de informes llama al GetUserInfo método para cada solicitud para recuperar la identidad actual del usuario.

Se aplica a