Mega Code Archive

 
Categories / ASP.Net Tutorial / Authentication Authorization
 

Check Windows Principal

<%@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" /><br>  </form>