Sometimes you have to restrict the visitor of a page to a username, if you don’t want to take the time to build a database you can simply use the username on the domain.
In the code below make sure you replace “<DOMAIN>” with your companies domain
protected void Page_Load(object sender, EventArgs e) { System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal; string sEmployee = p.Identity.Name.Replace("<DOMAIN>", "").ToLower(); //Response.Write(sEmployee); switch (sEmployee) { default: Response.Redirect("http://www.kittell.net"); break; case "dkittell": case "testuser1": case "testuser2": break; } }
Last Updated on October 26, 2015