WindowsAuthenticationEventArgs 类

定义

为 WindowsAuthentication_OnAuthenticate 事件提供数据。 此类不能被继承。

public ref class WindowsAuthenticationEventArgs sealed : EventArgs
public sealed class WindowsAuthenticationEventArgs : EventArgs
type WindowsAuthenticationEventArgs = class
    inherit EventArgs
Public NotInheritable Class WindowsAuthenticationEventArgs
Inherits EventArgs
继承
WindowsAuthenticationEventArgs

示例

下面的代码示例使用 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 IIS 提供的 Windows 标识和当前 HttpContext 构造WindowsAuthenticationEventArgs对象,并将其传递给 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)

适用于

另请参阅