private void SetPrincipal(string username) { var roles = _membershipProvider.GetRolesForUser(username); var user = _membershipProvider.GetUser(username); var identity = CreateIdentity(user); var principal = new GenericPrincipal(identity, roles); Thread.CurrentPrincipal = principal; if (HttpContext.Current != null) { HttpContext.Current.User = principal; } }
public List <string> GetRolesForUser(string userName) { var roles = _membershipProvider.GetRolesForUser(userName); return(roles.ToList()); }
private void SetPrincipal(IMembershipProvider membershipProvider, string username) { var roles = membershipProvider.GetRolesForUser(username); var user = membershipProvider.GetUser(username); var identity = CreateIdentity(user); var principal = new GenericPrincipal(identity, roles); Thread.CurrentPrincipal = principal; if (HttpContext.Current != null) { HttpContext.Current.User = principal; } }