Hi all,
I'd like to protect my c#-based web-application with windows authentication.
In order to achieve this I'd like to read the username and the
windows-role(administrator, User, Guest etc.) of the user. In the IIS I use
Basic Authentication (due to browser issues). Knowing the user's role I
could present the content according to the user's rights. So far I've only
managed to get the user-name and the authenication-type but not the
users-role. Can anyone give me a hint how to pick out the user-role?
Here's the source:
<%@ Page language="c#" debug="True" %>
<% @ Import Namespace = System.Security.Principal %>
<% @ Import Namespace = System.Threading %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<script language="C#" runat=server>
void Page_Load(Object Src, EventArgs E )
{
AuthUser.Text = User.Identity.Name;
AuthType.Text = User.Identity.AuthenticationType;
AuthTrueFalse.Text = User.Identity.IsAuthenticated.ToString();
//AuthGuest.Text = StrGast;
}
</script>
<body>
<h3><font face="Verdana">Windows Authentication</font></h3>
<table Width="700" rules="all" bordercolor="Black"
style="background-color:#ccccff;bordercolor:black;font-family:Verdana;font-s
ize:8pt;border-collapse:collapse;">
<tr>
<td>Benutzer:</td>
<td><asp:label id=AuthUser runat=server/>
</tr>
<tr>
<td>Authentication Typ:</td>
<td><asp:label id=AuthType runat=server/>
</tr>
<tr>
<td>Authenticated:</td>
<td><asp:label id="AuthTrueFalse" runat=server/>
</tr>
<tr>
<td>Authentication Rolle:</td>
<td><asp:label id="AuthGuest" runat=server/>
</tr>
</table>
</body>
</html>
Thanks in advance
Kind regards
Frank Tichy
Web7