WindowsAuthenticationEventArgs.Identity 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取传递给 WindowsAuthenticationEventArgs 构造函数的 Windows 标识。
public:
property System::Security::Principal::WindowsIdentity ^ Identity { System::Security::Principal::WindowsIdentity ^ get(); };
public System.Security.Principal.WindowsIdentity Identity { get; }
member this.Identity : System.Security.Principal.WindowsIdentity
Public ReadOnly Property Identity As WindowsIdentity
属性值
传递给 WindowsAuthenticationEventArgs 构造函数的 Windows 标识。
示例
下面的代码示例使用 WindowsAuthentication_OnAuthenticate 事件将当前HttpContext对象的属性设置为User自定义IPrincipal对象。
public void WindowsAuthentication_OnAuthenticate(object sender, WindowsAuthenticationEventArgs args)
{
if (!args.Identity.IsAnonymous)
{
args.User = new Samples.AspNet.Security.MyPrincipal(args.Identity);
}
}
Public Sub WindowsAuthentication_OnAuthenticate(sender As Object, args As WindowsAuthenticationEventArgs)
If Not args.Identity.IsAnonymous Then
args.User = New Samples.AspNet.Security.MyPrincipal(args.Identity)
End If
End Sub
注解
该WindowsAuthenticationModule对象使用 IIS 和当前HttpContext提供的Windows标识构造WindowsAuthenticationEventArgs对象,并将其传递给 WindowsAuthentication_OnAuthenticate 事件。
如果 IIS 使用匿名身份验证,则 Identity 此属性设置为方法返回 GetAnonymous 的标识。