WindowsAuthenticationModule 类

定义

启用 Windows 身份验证的情况下设置 ASP.NET 应用程序用户的标识。 此类不能被继承。

public ref class WindowsAuthenticationModule sealed : System::Web::IHttpModule
public sealed class WindowsAuthenticationModule : System.Web.IHttpModule
type WindowsAuthenticationModule = class
    interface IHttpModule
Public NotInheritable Class WindowsAuthenticationModule
Implements IHttpModule
继承
WindowsAuthenticationModule
实现

示例

下面的代码示例使用 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

注解

当身份验证Mode设置为 Windows时,将WindowsAuthenticationModule当前 HttpContext 的 属性设置为User一个 IPrincipal 对象,该对象表示 IIS 为当前请求提供的 Windows 标识。 如果 IIS 使用匿名身份验证,则 WindowsAuthenticationModule 使用 方法返回的 GetAnonymous 标识。

公开WindowsAuthenticationModule一个Authenticate事件,使你能够为当前 HttpContext的 属性提供自定义IPrincipal对象User。 通过在 Authenticate ASP.NET 应用程序的 Global.asax 文件中指定名为 WindowsAuthentication_OnAuthenticate 的子例程来访问该事件。

备注

在 IIS 7.0 中,不支持将 类与 类一起使用WindowsAuthenticationModuleFormsAuthenticationModule。 有关集成模式下兼容性问题的详细信息,请参阅 将 ASP.NET 应用程序从 IIS 6.0 移动到 IIS 7.0

构造函数

WindowsAuthenticationModule()

创建 WindowsAuthenticationModule 类的实例。

方法

Dispose()

释放 WindowsAuthenticationModule 使用的所有资源,内存除外。

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
Init(HttpApplication)

初始化 WindowsAuthenticationModule 对象。

MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

事件

Authenticate

应用程序对当前请求进行身份验证时发生。

适用于

另请参阅