示例#1
0
        private void ExecuteRenameUserCommand(UserInfo obj)
        {
            try
            {
                EditStringWindow dlg = new EditStringWindow();
                dlg.Title = "Rename User";
                dlg.Header = "Enter new user name";
                dlg.TextItem = obj.User.Account;
                dlg.Owner = Application.Current.MainWindow;
                dlg.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                if (dlg.ShowDialog() == true)
                {
                    obj.User.Name = dlg.TextItem;
                    obj.User.Account = dlg.TextItem;

                    (MainWindow as MainWindow).lbUsers.Items.SortDescriptions.Clear();
                    (MainWindow as MainWindow).lbUsers.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("User.Account", System.ComponentModel.ListSortDirection.Ascending));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            RaiseCanExecuteChanged();
        }
示例#2
0
 private void ExecuteRemoveUserCommand(UserInfo obj)
 {
     try
     {
         if (MessageBox.Show("Do you really want to delete the user '" + obj + "'?", "Delete User", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             RemoveUser(obj.User);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     RaiseCanExecuteChanged();
 }
示例#3
0
        private void ExecuteRemoveUserFromActualGroupCommand(UserInfo obj)
        {
            try
            {
                if (ActualGroup == null) return;
                if (obj == null) return;

                var x = from gi in obj.Groups
                        where gi.Group.Name == ActualGroup.Name && gi.IsMember == true
                        select gi;

                GroupMembershipInfo groupInfo = x.FirstOrDefault<GroupMembershipInfo>();
                if (groupInfo == null) return;

                if (MessageBox.Show("Do you really want to remove the user from this group?", "Delete Group Member", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    groupInfo.IsMember = false;

                    SecurityFramework.UpdateUser(groupInfo.User);
                }

                Group g = ActualGroup;
                ActualGroup = null;
                _Users = null;
                NotifyPropertyChanged("Users");
                NotifyPropertyChanged("GroupInfos");
                ActualGroup = g;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            RaiseCanExecuteChanged();
        }
示例#4
0
 private void ExecuteChangeUserPasswordCommand(UserInfo obj)
 {
     try
     {
         UserAuth dlg = new UserAuth(obj.User);
         dlg.Title = "Change User Authentification";
         dlg.Owner = Application.Current.MainWindow;
         dlg.WindowStartupLocation = WindowStartupLocation.CenterOwner;
         if (dlg.ShowDialog() == true)
         {
             if (obj.User.Type == UserAuthType.FormsAuthentication)
                 obj.User.Password = dlg.tbString.Text;
             else
                 obj.User.Password = string.Empty;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     RaiseCanExecuteChanged();
 }
示例#5
0
 private bool CanRenameUserCommand(UserInfo obj)
 {
     return true;
 }
示例#6
0
 private bool CanRemoveUserFromActualGroupCommand(UserInfo obj)
 {
     return true;
 }
示例#7
0
 private bool CanChangeUserPasswordCommand(UserInfo obj)
 {
     return true;
 }
示例#8
0
        public void AddUser(string name, string password, UserAuthType type)
        {
            try
            {
                name = name.ToLower(); //only lower case usernames are allowed

                User user = SecurityFramework.AddNewUser(name, password, type);
                if (_Users != null)
                {
                    if (string.IsNullOrEmpty(UsernameFilter))
                    {
                        UserInfo u = new UserInfo(user, SecurityFramework.Groups);
                        if (_Users.Count(ui => ui.User.Account == u.User.Account) > 0)
                        {
                            MessageBox.Show(String.Format("The given username '{0}' already exists.", u.User.Account),
                                "Execution was aborted", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                        else
                        {
                            _Users.Add(new UserInfo(user, SecurityFramework.Groups));
                        }
                    }
                    else if (user.Account.Contains(UsernameFilter))
                    {
                        _Users.Add(new UserInfo(user, SecurityFramework.Groups));
                        (MainWindow as MainWindow).ListBoxUsers.GetBindingExpression(System.Windows.Controls.ListBox.ItemsSourceProperty).UpdateTarget();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }