HttpRequest.LogonUserIdentity プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HttpRequest.LogonUserIdentity プロパティの意味・解説 

HttpRequest.LogonUserIdentity プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

現在のユーザー対する WindowsIdentity の種類取得します

名前空間: System.Web
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public ReadOnly Property
 LogonUserIdentity As WindowsIdentity
Dim instance As HttpRequest
Dim value As WindowsIdentity

value = instance.LogonUserIdentity
public WindowsIdentity LogonUserIdentity { get;
 }
public:
property WindowsIdentity^ LogonUserIdentity {
    WindowsIdentity^ get ();
}
/** @property */
public WindowsIdentity get_LogonUserIdentity ()
public function get LogonUserIdentity
 () : WindowsIdentity

プロパティ
現在の Microsoft Internet Information Services (IIS) の認証設定対応する WindowsIdentity

解説解説

LogonUserIdentity プロパティによって、Microsoft Internet Information Services (IIS) に現在接続しているユーザーWindowsIdentity オブジェクトプロパティメソッド公開されます。LogonUserIdentity によって公開される WindowsIdentity クラスインスタンスは、IIS 要求トークン追跡しASP.NET内部処理されている現在の HTTP 要求対するこのトークン簡単にアクセスできるようにします。WindowsIdentity クラスインスタンス自動的に作成されるため、そのメソッドプロパティアクセスするために構築する要はありません。

使用例使用例

現在のユーザーLogonUserIdentity プロパティ取得し、各項目の値をテキスト ファイル出力する方法次のコード例示します。このコードは、フォームACTION 属性参照されている ASP.NET ページ上に配置します

<%@ Page Language="VB" %>
<%@ import Namespace="System.IO"
 %>

<script runat="server">
    
    ' * NOTE: To use this sample, create a c:\temp  folder,
    ' *  add the ASP.NET account (in IIS 5.x <machinename>\ASPNET
,
    ' *  in IIS 6.x NETWORK SERVICE), and give it write permissions
    ' *  to the folder.

    Private Const INFO_DIR As
 String = "c:\temp\"

    Private Sub Page_Load(sender As
 Object, e As System.EventArgs)
   
        ' Validate that user is authenticated
        If Not (Request.LogonUserIdentity.IsAuthenticated)
 Then
            Response.Redirect("LoginPage.aspx")
        End If
        
        ' Create a string that contains the file path
        Dim strFilePath As String
 = INFO_DIR & "VB_Log.txt"
        
        Response.Write("Writing log file to " &
 strFilePath & "...")
        
        ' Create stream writer object and pass it the file path
        Dim sw As StreamWriter = File.CreateText(strFilePath)
        
        ' Write user info to log
        sw.WriteLine("Access log from " & DateTime.Now.ToString())
        sw.WriteLine("User: " & Request.LogonUserIdentity.User.ToString())
        sw.WriteLine("Name: " & Request.LogonUserIdentity.Name)
        sw.WriteLine("AuthenticationType: " &
 Request.LogonUserIdentity.AuthenticationType)
        sw.WriteLine("ImpersonationLevel: " &
 Request.LogonUserIdentity.ImpersonationLevel)
        sw.WriteLine("IsAnonymous: " & Request.LogonUserIdentity.IsAnonymous)
        sw.WriteLine("IsGuest: " & Request.LogonUserIdentity.IsGuest)
        sw.WriteLine("IsSystem: " & Request.LogonUserIdentity.IsSystem)
        sw.WriteLine("Owner: " & Request.LogonUserIdentity.Owner.ToString())
        sw.WriteLine("Token: " & Request.LogonUserIdentity.Token.ToString())

        ' Close the stream to the file.
        sw.Close()
    End Sub

</script>

<%@ Page Language="C#" %>
<%@ import Namespace="System.IO" %>

<script runat="server">
    
    /* NOTE: To use this sample, create a c:\temp  folder,
    *  add the ASP.NET account (in IIS 5.x <machinename>\ASPNET
,
    *  in IIS 6.x NETWORK SERVICE), and give it write permissions
    *  to the folder.*/

    private const string
 INFO_DIR = @"c:\temp\";

    private void Page_Load(object sender, System.EventArgs
 e)
    {
        // Validate that user is authenticated
        if (!Request.LogonUserIdentity.IsAuthenticated)
            Response.Redirect("LoginPage.aspx");
        
        // Create a string that contains the file path
        string strFilePath = INFO_DIR + "CS_Log.txt";
        
        Response.Write("Writing log file to " + strFilePath + "...");
        
        // Create stream writer object and pass it the file path
        StreamWriter sw = File.CreateText(strFilePath);
        
        // Write user info to log
        sw.WriteLine("Access log from " + DateTime.Now.ToString());
        sw.WriteLine("User: " + Request.LogonUserIdentity.User);
        sw.WriteLine("Name: " + Request.LogonUserIdentity.Name);
        sw.WriteLine("AuthenticationType: " + Request.LogonUserIdentity.AuthenticationType);
        sw.WriteLine("ImpersonationLevel: " + Request.LogonUserIdentity.ImpersonationLevel);
        sw.WriteLine("IsAnonymous: " + Request.LogonUserIdentity.IsAnonymous);
        sw.WriteLine("IsGuest: " + Request.LogonUserIdentity.IsGuest);
        sw.WriteLine("IsSystem: " + Request.LogonUserIdentity.IsSystem);
        sw.WriteLine("Owner: " + Request.LogonUserIdentity.Owner);
        sw.WriteLine("Token: " + Request.LogonUserIdentity.Token);

        // Close the stream to the file.
        sw.Close();
    }  
</script>
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からHttpRequest.LogonUserIdentity プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からHttpRequest.LogonUserIdentity プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からHttpRequest.LogonUserIdentity プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

HttpRequest.LogonUserIdentity プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



HttpRequest.LogonUserIdentity プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS