protected override bool AuthorizeCore(HttpContextBase httpContext) { Groups = ConfigurationManager.AppSettings["UserAuthADGroup"]; _authenticated = base.AuthorizeCore(httpContext); if (_authenticated) { if (string.IsNullOrEmpty(Groups)) { _authorized = true; return(_authorized); } var groups = Groups.Split(','); string username = httpContext.User.Identity.Name; try { _authorized = LDAPHelper.UserIsMemberOfGroups(username, groups); return(_authorized); } catch (Exception ex) { this.Log().Error(() => "Error attempting to authorize user", ex); _authorized = false; return(_authorized); } } _authorized = false; return(_authorized); }
public static PrincipalContext BuildPrincipalContext() { string container = LDAPHelper.GetLDAPContainer(); return(new PrincipalContext(ContextType.Domain, null, container)); }