ASP.NET Tutorial/Authentication Authorization/WindowsPrincipal
Check Windows Principal
<source lang="csharp">
<%@Page language="C#" %> <%@Import Namespace="System.Security.Principal" %> <script runat="server"> protected void Page_Load(object o, EventArgs e) {
WindowsPrincipal principal = (WindowsPrincipal)HttpContext.Current.User; if(principal.IsInRole(WindowsBuiltInRole.Administrator)) { message.Text = "secret message for Administrators only"; }
}
</script>
<form runat="server">
<asp:Label runat="server" id="message" Text="the text everyone can see" />
</form></source>