<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Untitled Page
File: Web.config
cacheRolesInCookie="false"
defaultProvider="WindowsRoles">
type="System.Web.Security.WindowsTokenRoleProvider" />
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if ((User != null) && (User.Identity.IsAuthenticated))
{
RolePrincipal rp = (RolePrincipal)User;
StringBuilder Info = new StringBuilder();
Info.AppendFormat("Welcome {0}!
", User.Identity.Name);
Info.AppendFormat("Provider: {0}
", rp.ProviderName);
Info.AppendFormat("Version: {0}
", rp.Version);
Info.AppendFormat("Expiration: {0}
", rp.ExpireDate);
Info.AppendFormat("Roles:
");
string[] Roles = rp.GetRoles();
foreach (string role in Roles)
{
if (!role.Equals(string.Empty))
Info.AppendFormat("-) {0}
", role);
}
LabelPrincipalInfo.Text = Info.ToString();
}
}
}