WindowsAuthenticationEventArgs 类   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为 WindowsAuthentication_OnAuthenticate 事件提供数据。 此类不能被继承。
public ref class WindowsAuthenticationEventArgs sealed : EventArgspublic sealed class WindowsAuthenticationEventArgs : EventArgstype WindowsAuthenticationEventArgs = class
    inherit EventArgsPublic NotInheritable Class WindowsAuthenticationEventArgs
Inherits EventArgs- 继承
示例
下面的代码示例使用 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
注解
类 WindowsAuthenticationEventArgs 用于向 WindowsAuthentication_OnAuthenticate 事件提供事件值,并使你能够为当前请求指定自定义 Windows 标识。
WindowsAuthenticationModule WindowsAuthenticationEventArgs使用 IIS 提供的 Windows 标识和当前 HttpContext 构造 对象,并将其传递给 WindowsAuthentication_OnAuthenticate 事件。
可以使用User提供给 WindowsAuthentication_OnAuthenticate 事件的 对象的 属性WindowsAuthenticationEventArgs将当前 HttpContext 的 属性设置为User自定义IPrincipal对象。 如果在WindowsAuthentication_OnAuthenticate事件期间未指定 User 属性的值,IIS 提供的 Windows 标识将用作当前请求的标识。 如果 IIS 使用匿名身份验证,则 属性 Identity 设置为 方法返回的 GetAnonymous 标识。
仅当身份验证Mode设置为 Windows 并且 是应用程序的活动 HTTP 模块时,WindowsAuthenticationModule才会引发 WindowsAuthentication_OnAuthenticate 事件。
构造函数
| WindowsAuthenticationEventArgs(WindowsIdentity, HttpContext) | 初始化新创建的 WindowsAuthenticationEventArgs 类实例。 | 
属性
| Context | 为当前 HTTP 请求获取 HttpContext 对象。 | 
| Identity | 获取传递给 WindowsAuthenticationEventArgs 构造函数的 Windows 标识。 | 
| User | 获取或设置要与当前请求关联的 IPrincipal 对象。 | 
方法
| Equals(Object) | 确定指定对象是否等于当前对象。(继承自 Object) | 
| GetHashCode() | 作为默认哈希函数。(继承自 Object) | 
| GetType() | 获取当前实例的 Type。(继承自 Object) | 
| MemberwiseClone() | 创建当前 Object 的浅表副本。(继承自 Object) | 
| ToString() | 返回表示当前对象的字符串。(继承自 Object) |