NewUser() private method

private NewUser ( ) : DataObject
return CsDO.Lib.DataObject
Beispiel #1
0
        public override void RemoveUsersFromRoles(string[] usernames, string[] rolenames)
        {
            foreach (string rolename in rolenames)
            {
                if (!RoleExists(rolename))
                {
                    throw new ProviderException("Role name not found.");
                }
            }

            foreach (string username in usernames)
            {
                foreach (string rolename in rolenames)
                {
                    if (!IsUserInRole(username, rolename))
                    {
                        throw new ProviderException("User is not in role.");
                    }
                }
            }

            CsDOMembershipProvider mp = new CsDOMembershipProvider();
            mp.SetupParameters(assemblyName, userType);

            foreach (string username in usernames)
            {
                foreach (string rolename in rolenames)
                {
                    DataObject role = NewRole();
                    _Role_Name.SetValue(role, rolename, null);
                    role.find();
                    role.fetch();
                    DataObject user = mp.NewUser();
                    mp._User_Name.SetValue(user, username, null);
                    role.find();
                    role.fetch();
                    DataObject usersInRoles = NewUsersInRoles();
                    _UsersInRoles_Role.SetValue(usersInRoles, role, null);
                    _UsersInRoles_User.SetValue(usersInRoles, user, null);
                    IList users = usersInRoles.ToArray(true);

                    foreach (DataObject item in users)
                        item.delete();
                }
            }
        }
Beispiel #2
0
        public override string[] FindUsersInRole(string rolename, string usernameToMatch)
        {
            string tmpUserNames = "";

            CsDOMembershipProvider mp = new CsDOMembershipProvider();
            mp.SetupParameters(assemblyName, userType);

            DataObject role = NewRole();
            _Role_Name.SetValue(role, rolename, null);
            role.find();
            role.fetch();
            DataObject user = mp.NewUser();
            mp._User_Name.SetValue(user, usernameToMatch, null);
            role.find();
            role.fetch();
            DataObject usersInRoles = NewUsersInRoles();
            _UsersInRoles_Role.SetValue(usersInRoles, role, null);
            _UsersInRoles_User.SetValue(usersInRoles, user, null);
            IList users = usersInRoles.ToArray(true);

            foreach(DataObject item in users)
            {
                tmpUserNames += mp._User_Name.GetValue(item, null).ToString() + ",";
            }

            if (tmpUserNames.Length > 0)
            {
                // Remove trailing comma.
                tmpUserNames = tmpUserNames.Substring(0, tmpUserNames.Length - 1);
                return tmpUserNames.Split(',');
            }

            return new string[0];
        }