public static string[] GetRolesForUser(string username) { string[] strArray2; if (HostingEnvironment.IsHosted && EtwTrace.IsTraceEnabled(4, 8)) { EtwTrace.Trace(EtwTraceType.ETW_TYPE_ROLE_BEGIN, HttpContext.Current.WorkerRequest); } EnsureEnabled(); string[] roles = null; bool flag = false; try { SecUtility.CheckParameter(ref username, true, false, true, 0, "username"); if (username.Length < 1) { return(new string[0]); } IPrincipal currentUser = GetCurrentUser(); if (((currentUser != null) && (currentUser is RolePrincipal)) && ((((RolePrincipal)currentUser).ProviderName == Provider.Name) && System.Web.Util.StringUtil.EqualsIgnoreCase(username, currentUser.Identity.Name))) { roles = ((RolePrincipal)currentUser).GetRoles(); flag = true; } else { roles = Provider.GetRolesForUser(username); } strArray2 = roles; } finally { if (HostingEnvironment.IsHosted && EtwTrace.IsTraceEnabled(4, 8)) { if (EtwTrace.IsTraceEnabled(5, 8)) { string str = null; if ((roles != null) && (roles.Length > 0)) { str = roles[0]; } for (int i = 1; i < roles.Length; i++) { str = str + "," + roles[i]; } EtwTrace.Trace(EtwTraceType.ETW_TYPE_ROLE_GET_USER_ROLES, HttpContext.Current.WorkerRequest, flag ? "RolePrincipal" : Provider.GetType().FullName, username, str, null); } EtwTrace.Trace(EtwTraceType.ETW_TYPE_ROLE_END, HttpContext.Current.WorkerRequest, flag ? "RolePrincipal" : Provider.GetType().FullName, username); } } return(strArray2); }
static public string[] GetRolesForUser(string username) { if (HostingEnvironment.IsHosted && EtwTrace.IsTraceEnabled(EtwTraceLevel.Information, EtwTraceFlags.AppSvc) && HttpContext.Current != null) { EtwTrace.Trace(EtwTraceType.ETW_TYPE_ROLE_BEGIN, HttpContext.Current.WorkerRequest); } EnsureEnabled(); string[] roles = null; bool isRolePrincipal = false; try { SecUtility.CheckParameter(ref username, true, false, true, 0, "username"); if (username.Length < 1) { roles = new string[0]; return(roles); } IPrincipal user = GetCurrentUser(); if (user != null && user is RolePrincipal && ((RolePrincipal)user).ProviderName == Provider.Name && StringUtil.EqualsIgnoreCase(username, user.Identity.Name)) { roles = ((RolePrincipal)user).GetRoles(); isRolePrincipal = true; } else { roles = Provider.GetRolesForUser(username); } return(roles); } finally { if (HostingEnvironment.IsHosted && EtwTrace.IsTraceEnabled(EtwTraceLevel.Information, EtwTraceFlags.AppSvc) && HttpContext.Current != null) { if (EtwTrace.IsTraceEnabled(EtwTraceLevel.Verbose, EtwTraceFlags.AppSvc)) { string roleNames = null; if (roles != null && roles.Length > 0) { roleNames = roles[0]; } for (int i = 1; i < roles.Length; i++) { roleNames += "," + roles[i]; } EtwTrace.Trace(EtwTraceType.ETW_TYPE_ROLE_GET_USER_ROLES, HttpContext.Current.WorkerRequest, isRolePrincipal ? "RolePrincipal" : Provider.GetType().FullName, username, roleNames, null); } EtwTrace.Trace(EtwTraceType.ETW_TYPE_ROLE_END, HttpContext.Current.WorkerRequest, isRolePrincipal ? "RolePrincipal" : Provider.GetType().FullName, username); } } }
public string [] GetRoles() { if (!_identity.IsAuthenticated) { return(new string[0]); } if (!IsRoleListCached || Expired) { _cachedArray = Provider.GetRolesForUser(_identity.Name); _cachedRoles = new HybridDictionary(true); foreach (string r in _cachedArray) { _cachedRoles.Add(r, r); } _listChanged = true; } return(_cachedArray); }
public static string [] GetRolesForUser(string username) { return(Provider.GetRolesForUser(username)); }
public static string [] GetRolesForUser() { return(Provider.GetRolesForUser(CurrentUser)); }