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 為 ,而且 WindowsAuthenticationModule 是應用程式的使用中 HTTP 模組時,才會引發 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)

適用於

另請參閱