public AuthorizationDialog(string url, string application, string user) : this()
        {
            m_Url = url;
            m_ApplicationTextBox.Text = application;
            m_UserComboBox.Text       = user;

            IRoleManager roleManager = UserManagerProviderFactory.CreateRoleManager();

            string[] roles = roleManager.GetRolesForUser(application, user);

            m_RoleComboBox.Items.AddRange(roles);
            if (roles.Length > 0)
            {
                m_RoleComboBox.Text = roles[roles.Length - 1];
            }

            IMembershipManager membershipManager = roleManager as IMembershipManager;

            string[] users = membershipManager.GetAllUsers(application);

            m_UserComboBox.Items.AddRange(users);
            if (users.Length > 0)
            {
                m_UserComboBox.Text = users[users.Length - 1];
            }
        }
예제 #2
0
        void IMembershipManager.DeleteAllUsers(string application, bool deleteAllRelatedData)
        {
            IMembershipManager membershipManager = this;

            string[] users = membershipManager.GetAllUsers(application);

            Action <string> deleteUser =
                delegate(string user) { membershipManager.DeleteUser(application, user, deleteAllRelatedData); };

            Array.ForEach(users, deleteUser);
        }
예제 #3
0
        void RefreshUsersListView()
        {
            m_UsersListView.ClearItems();
            if (ApplicationName == String.Empty)
            {
                return;
            }
            IMembershipManager membershipManager = UserManagerProviderFactory.CreateMembershipManager(); // new AspNetSqlProviderService(ServiceAddress);

            string[] users = membershipManager.GetAllUsers(ApplicationName);
            m_UsersListView.AddItems(users, true);
        }
예제 #4
0
        void OnUpdateUser(object sender, EventArgs e)
        {
            IMembershipManager membershipManager = UserManagerProviderFactory.CreateMembershipManager();// new AspNetSqlProviderService(m_Url);

            string[]           users  = membershipManager.GetAllUsers(m_Application);
            Predicate <string> exists = delegate(string user)
            {
                return(user == m_UserNameTextBox.Text);
            };

            if (Array.Exists(users, exists) == false)
            {
                m_Validator.SetError(m_UserNameTextBox, "User name does not exist");
                return;
            }
            m_Validator.Clear();

            if (m_EmailTextBox.Text == String.Empty)
            {
                m_Validator.SetError(m_EmailTextBox, "Email cannot be empty");
                return;
            }
            m_Validator.Clear();
            if (m_OldAnswerTextBox.Text == String.Empty && m_OldAnswerTextBox.Enabled)
            {
                m_Validator.SetError(m_OldAnswerTextBox, "Old answer cannot be empty");
                return;
            }
            m_Validator.Clear();
            if (m_NewQuestionTextBox.Text == String.Empty && m_NewQuestionTextBox.Enabled)
            {
                m_Validator.SetError(m_NewQuestionTextBox, "New question cannot be empty");
                return;
            }
            m_Validator.Clear();
            if (m_NewAnswerTextBox.Text == String.Empty && m_NewAnswerTextBox.Enabled)
            {
                m_Validator.SetError(m_NewAnswerTextBox, "New answer cannot be empty");
                return;
            }
            m_Validator.Clear();

            membershipManager.UpdateUser(m_Application, m_UserNameTextBox.Text, m_EmailTextBox.Text, m_OldAnswerTextBox.Text, m_NewQuestionTextBox.Text, m_NewAnswerTextBox.Text, m_ActiveUserCheckbox.Checked, m_LcokedOutCheckBox.Checked);

            Close();
        }
        void OnCreateUser(object sender, EventArgs e)
        {
            IMembershipManager membershipManager = UserManagerProviderFactory.CreateMembershipManager(); // new AspNetSqlProviderService(m_Url);

            string[]           users  = membershipManager.GetAllUsers(m_Application);
            Predicate <string> exists = delegate(string user)
            {
                return(user == m_UserNameTextBox.Text);
            };

            if (Array.Exists(users, exists))
            {
                m_Validator.SetError(m_UserNameTextBox, "User name already exists");
                return;
            }
            m_Validator.Clear();

            if (m_PasswordTextbox.Text == String.Empty)
            {
                m_Validator.SetError(m_PasswordTextbox, "Password cannot be empty");
                return;
            }
            m_Validator.Clear();

            if (m_PasswordTextbox.Text != m_ConfirmedPasswordTextBox.Text)
            {
                m_Validator.SetError(m_ConfirmedPasswordTextBox, "Confirmed password does not match");
                return;
            }
            m_Validator.Clear();

            if (m_UserNameTextBox.Text == String.Empty)
            {
                m_Validator.SetError(m_UserNameTextBox, "User name cannot be empty");
                return;
            }
            m_Validator.Clear();

            if (m_EmailTextBox.Text == String.Empty)
            {
                m_Validator.SetError(m_EmailTextBox, "Email cannot be empty");
                return;
            }
            m_Validator.Clear();

            if (m_SecurityQuestionTextBox.Text == String.Empty)
            {
                m_Validator.SetError(m_SecurityQuestionTextBox, "Security question cannot be empty");
                return;
            }
            m_Validator.Clear();

            if (m_SecurityAnswerTextbox.Text == String.Empty)
            {
                m_Validator.SetError(m_SecurityAnswerTextbox, "Security question cannot be empty");
                return;
            }
            m_Validator.Clear();

            MembershipCreateStatus status = membershipManager.CreateUser(m_Application, m_UserNameTextBox.Text, m_PasswordTextbox.Text, m_EmailTextBox.Text, m_SecurityQuestionTextBox.Text, m_SecurityAnswerTextbox.Text, m_ActiveUserCheckBox.Checked);

            if (status != MembershipCreateStatus.Success)
            {
                MessageBox.Show(status.ToString(), "Credentials Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                m_Users.Add(m_UserNameTextBox.Text);
                m_CreatedUsersListView.AddItem(m_UserNameTextBox.Text, true);
                m_UserNameTextBox.Text = String.Empty;
                m_UserNameTextBox.Focus();
                m_GeneratePasswordCheckBox.Checked = false;
                m_PasswordTextbox.Text             = String.Empty;
                m_ConfirmedPasswordTextBox.Text    = String.Empty;
            }
        }
 public IEnumerable <IUser> GetAllUsers()
 {
     return(membershipUserMapper.MapAll(membershipManager.GetAllUsers()));
 }