protected void Page_Load(object sender, EventArgs e) { bool validated = false; AD ad = new AD("LDAP://utl.co.ug", "utl\\utl030530", "resetpassword"); Dictionary<string,object> userDetails = ad.getUserDetails(Page.User.Identity.Name.Split(new char[]{'\\'})[1]); string[] Dls = (string [])userDetails["dls"]; List<string> allowedProfiles = new List<string>() { "DL-Callcen-Back office", "DL-CUSTOMER SERVICE ADVISORS", "DL-CallCen Msente", "DL-CallCen The Royals", "DL-IT VAS&TI", "DL-Service Centre Team Leaders" }; foreach (string dl in Dls) { if (allowedProfiles.Contains(dl)) { validated = true; break; } } if (!validated) { Response.StatusCode = 403; Response.Write("Access Denied"); Response.End(); } }