Ejemplo n.º 1
0
        static public void AddUsersToRole(string[] usernames, string roleName)
        {
            EnsureEnabled();

            SecUtility.CheckParameter(ref roleName, true, true, true, 0, "roleName");

            SecUtility.CheckArrayParameter(ref usernames,
                                           true,
                                           true,
                                           true,
                                           0,
                                           "usernames");

            Provider.AddUsersToRoles(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 { }
        }
Ejemplo n.º 2
0
 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
     {
     }
 }
Ejemplo n.º 3
0
 public static 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 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
     {
     }
 }
Ejemplo n.º 4
0
 public static void AddUserToRoles(string username, string [] roleNames)
 {
     Provider.AddUsersToRoles(new string[] { username }, roleNames);
 }
Ejemplo n.º 5
0
 public static void AddUserToRole(string username, string roleName)
 {
     Provider.AddUsersToRoles(new string[] { username }, new string[] { roleName });
 }
Ejemplo n.º 6
0
 public static void AddUsersToRoles(string [] usernames, string [] roleNames)
 {
     Provider.AddUsersToRoles(usernames, roleNames);
 }
Ejemplo n.º 7
0
 public static void AddUsersToRole(string [] usernames, string roleName)
 {
     Provider.AddUsersToRoles(usernames, new string[] { roleName });
 }