WindowsAuthenticationEventArgs 类
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为 WindowsAuthentication_OnAuthenticate 事件提供数据。 此类不能被继承。
public ref class WindowsAuthenticationEventArgs sealed : EventArgs
public sealed class WindowsAuthenticationEventArgs : EventArgs
type WindowsAuthenticationEventArgs = class
inherit EventArgs
Public 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 事件。
Windows |
初始化新创建的 WindowsAuthenticationEventArgs 类实例。 |
Context |
为当前 HTTP 请求获取 HttpContext 对象。 |
Identity |
获取传递给 WindowsAuthenticationEventArgs 构造函数的 Windows 标识。 |
User |
获取或设置要与当前请求关联的 IPrincipal 对象。 |
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
Get |
作为默认哈希函数。 (继承自 Object) |
Get |
获取当前实例的 Type。 (继承自 Object) |
Memberwise |
创建当前 Object 的浅表副本。 (继承自 Object) |
To |
返回表示当前对象的字符串。 (继承自 Object) |
产品 | 版本 |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |