static public void RemoveUsersFromRole(string[] usernames, string roleName) { EnsureEnabled(); SecUtility.CheckParameter(ref roleName, true, true, true, 0, "roleName"); SecUtility.CheckArrayParameter(ref usernames, true, true, true, 0, "usernames"); Provider.RemoveUsersFromRoles(usernames, new string[] { roleName }); try { RolePrincipal user = GetCurrentUser() as RolePrincipal; if (user != null && user.ProviderName == Provider.Name && user.IsRoleListCached) { foreach (string username in usernames) { if (StringUtil.EqualsIgnoreCase(user.Identity.Name, username)) { user.SetDirty(); break; } } } } catch { } }
public static void AddUsersToRoles(string[] usernames, string[] roleNames) { EnsureEnabled(); SecUtility.CheckArrayParameter(ref roleNames, true, true, true, 0, "roleNames"); SecUtility.CheckArrayParameter(ref usernames, true, true, true, 0, "usernames"); Provider.AddUsersToRoles(usernames, roleNames); try { RolePrincipal currentUser = GetCurrentUser() as RolePrincipal; if (((currentUser != null) && (currentUser.ProviderName == Provider.Name)) && currentUser.IsRoleListCached) { foreach (string str in usernames) { if (System.Web.Util.StringUtil.EqualsIgnoreCase(currentUser.Identity.Name, str)) { currentUser.SetDirty(); return; } } } } catch { } }
static public void AddUserToRole(string username, string roleName) { EnsureEnabled(); SecUtility.CheckParameter(ref roleName, true, true, true, 0, "roleName"); SecUtility.CheckParameter(ref username, true, true, true, 0, "username"); Provider.AddUsersToRoles(new string [] { username }, new string [] { roleName }); try { RolePrincipal user = GetCurrentUser() as RolePrincipal; if (user != null && user.ProviderName == Provider.Name && user.IsRoleListCached && StringUtil.EqualsIgnoreCase(user.Identity.Name, username)) { user.SetDirty(); } } catch { } }
static public bool DeleteRole(string roleName, bool throwOnPopulatedRole) { EnsureEnabled(); SecUtility.CheckParameter(ref roleName, true, true, true, 0, "roleName"); bool roleDeleted = Provider.DeleteRole(roleName, throwOnPopulatedRole); try { RolePrincipal user = GetCurrentUser() as RolePrincipal; if (user != null && user.ProviderName == Provider.Name && user.IsRoleListCached && user.IsInRole(roleName)) { user.SetDirty(); } } catch { } return(roleDeleted); }
public static void RemoveUserFromRoles(string username, string[] roleNames) { EnsureEnabled(); SecUtility.CheckParameter(ref username, true, true, true, 0, "username"); SecUtility.CheckArrayParameter(ref roleNames, true, true, true, 0, "roleNames"); Provider.RemoveUsersFromRoles(new string[] { username }, roleNames); try { RolePrincipal currentUser = GetCurrentUser() as RolePrincipal; if (((currentUser != null) && (currentUser.ProviderName == Provider.Name)) && (currentUser.IsRoleListCached && System.Web.Util.StringUtil.EqualsIgnoreCase(currentUser.Identity.Name, username))) { currentUser.SetDirty(); } } catch { } }