WindowsAuthenticationEventArgs.User プロパティ
現在の要求に関連付ける IPrincipal オブジェクトを取得または設定します。
名前空間: System.Web.Security
アセンブリ: System.Web (system.web.dll 内)
構文
'宣言
Public Property User As IPrincipal
'使用
Dim instance As WindowsAuthenticationEventArgs
Dim value As IPrincipal
value = instance.User
instance.User = value
public IPrincipal User { get; set; }
public:
property IPrincipal^ User {
IPrincipal^ get ();
void set (IPrincipal^ value);
}
/** @property */
public IPrincipal get_User ()
/** @property */
public void set_User (IPrincipal value)
public function get User () : IPrincipal
public function set User (value : IPrincipal)
適用できません。
プロパティ値
現在の要求に関連付ける IPrincipal オブジェクト。
解説
User プロパティを使用して、現在の HttpContext の User プロパティにカスタム IPrincipal オブジェクトを設定できます。
WindowsAuthentication_OnAuthenticate イベント中に User プロパティ値が指定されない場合、IIS によって提供される Windows ID が現在の要求に対する ID として使用されます。IIS が匿名認証を使用する場合、Identity プロパティには、GetAnonymous メソッドによって返される ID が設定されます。
使用例
WindowsAuthentication_OnAuthenticate イベントを使用して、現在の HttpContext の User プロパティにカスタム IPrincipal オブジェクトを設定するコード例を次に示します。
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
public void WindowsAuthentication_OnAuthenticate(object sender, WindowsAuthenticationEventArgs args)
{
if (!args.Identity.IsAnonymous)
{
args.User = new Samples.AspNet.Security.MyPrincipal(args.Identity);
}
}
.NET Framework のセキュリティ
- SecurityPermission (User プロパティを設定するために必要なアクセス許可)。要求値 : Demand。
プラットフォーム
Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition
Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。
バージョン情報
.NET Framework
サポート対象 : 3.0,2.0,1.1,1.0
参照
関連項目
WindowsAuthenticationEventArgs クラス
WindowsAuthenticationEventArgs メンバ
System.Web.Security 名前空間