RolePrincipal.Identity プロパティ
アセンブリ: System.Web (system.web.dll 内)


ロール管理が有効になっている場合に、現在のユーザーのロールのキャッシュ情報を表示する例を次に示します。ロール管理の有効化の詳細については、Roles クラスのトピックを参照してください。
<%@ Page Language="VB" %> <%@ Import Namespace="System.Web.Security" %> <script runat="server"> Public Sub Page_Load() Try Dim r As RolePrincipal = CType(User, RolePrincipal) IsCachedLabel.Text = r.IsRoleListCached.ToString() CacheChangedLabel.Text = r.CachedListChanged.ToString() ExpiredLabel.Text = r.Expired.ToString() VersionLabel.Text = r.Version.ToString() IssueDateLabel.Text = r.IssueDate.ToString() ExpireDateLabel.Text = r.ExpireDate.ToString() CookiePathLabel.Text = r.CookiePath Msg.Text = "" Catch e As InvalidCastException Msg.Text = "User is not of type RolePrincipal. Are roles enabled?" End Try End Sub </script> <html> <head> <title>Role Information</title> </head> <body> <form runat="server"> Role Information for <B><%=User.Identity.Name%></B>.<BR> <asp:Label id="Msg" runat="Server" ForeColor="maroon" /><BR> <table border=1 cellpadding=4 cellspacing=4> <tr> <td>IsRoleListCached</td> <td><asp:Label id="IsCachedLabel" runat="Server" /></td> </tr> <tr> <td>CachedListChanged</td> <td><asp:Label id="CacheChangedLabel" runat="Server" /></td> </tr> <tr> <td>Expired</td> <td><asp:Label id="ExpiredLabel" runat="Server" /></td> </tr> <tr> <td>Version</td> <td><asp:Label id="VersionLabel" runat="Server" /></td> </tr> <tr> <td>IssueDate</td> <td><asp:Label id="IssueDateLabel" runat="Server" /></td> </tr> <tr> <td>ExpireDate</td> <td><asp:Label id="ExpireDateLabel" runat="Server" /></td> </tr> <tr> <td>CookiePath</td> <td><asp:Label id="CookiePathLabel" runat="Server" /></td> </tr> </table> </form> </body> </html>
<%@ Page Language="C#" %> <%@ Import Namespace="System.Web.Security" %> <script runat="server"> public void Page_Load() { try { RolePrincipal r = (RolePrincipal)User; IsCachedLabel.Text = r.IsRoleListCached.ToString(); CacheChangedLabel.Text = r.CachedListChanged.ToString(); ExpiredLabel.Text = r.Expired.ToString(); VersionLabel.Text = r.Version.ToString(); IssueDateLabel.Text = r.IssueDate.ToString(); ExpireDateLabel.Text = r.ExpireDate.ToString(); CookiePathLabel.Text = r.CookiePath; Msg.Text = ""; } catch (InvalidCastException) { Msg.Text = "User is not of type RolePrincipal. Are roles enabled?"; } } </script> <html> <head> <title>Role Information</title> </head> <body> <form runat="server"> Role Information for <B><%=User.Identity.Name%></B>.<BR> <asp:Label id="Msg" runat="Server" ForeColor="maroon" /><BR> <table border=1 cellpadding=4 cellspacing=4> <tr> <td>IsRoleListCached</td> <td><asp:Label id="IsCachedLabel" runat="Server" /></td> </tr> <tr> <td>CachedListChanged</td> <td><asp:Label id="CacheChangedLabel" runat="Server" /></td> </tr> <tr> <td>Expired</td> <td><asp:Label id="ExpiredLabel" runat="Server" /></td> </tr> <tr> <td>Version</td> <td><asp:Label id="VersionLabel" runat="Server" /></td> </tr> <tr> <td>IssueDate</td> <td><asp:Label id="IssueDateLabel" runat="Server" /></td> </tr> <tr> <td>ExpireDate</td> <td><asp:Label id="ExpireDateLabel" runat="Server" /></td> </tr> <tr> <td>CookiePath</td> <td><asp:Label id="CookiePathLabel" runat="Server" /></td> </tr> </table> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- RolePrincipal.Identity プロパティのページへのリンク