public List<UserRowData> GetAllUsers()
        {
            List<UserRowData> data;
            
            using(UserManagement service = new UserManagement())
            {
                data = CollectionUtils.Map(
                    service.FindUsers(new ListUsersRequest()),
                    delegate(UserSummary summary)
                    {
                        UserRowData user = new UserRowData(summary, null);
                        return user;
                    });
            }

            return data;
        }
        public bool AddUser(UserRowData user)
        {
            bool success = false;

            using(var service = new UserManagement())
            {
                try
                {
	                var newUser = new UserDetail
		                {
			                UserName = user.UserName,
			                DisplayName = user.DisplayName,
			                Enabled = user.Enabled,
			                CreationTime = Platform.Time,
			                PasswordExpiryTime = Platform.Time,
			                EmailAddress = user.EmailAddress,
			                ResetPassword = true // TODO: Why do we need to reset password here?
		                };


                    var groups = new List<AuthorityGroupSummary>();

                    foreach (UserGroup userGroup in user.UserGroups)
                    {
                        groups.Add(new AuthorityGroupSummary(new EntityRef(userGroup.UserGroupRef), userGroup.Name,userGroup.Name, false, false));
                    }

                    newUser.AuthorityGroups = groups;
                    service.AddUser(newUser);
                    success = true;

                }
                catch (Exception ex)
                {
                	Platform.Log(LogLevel.Error, ex, "Unexpected exception adding user: {0}", user.DisplayName);
                }
            }

            return success;
        }
Example #3
0
        public bool UpdateUser(UserRowData user)
        {
            bool success = false;

            using(UserManagement service = new UserManagement())
            {
                try
                {
                    UserDetail updateUser = new UserDetail
                                                {
                                                    UserName = user.UserName,
                                                    DisplayName = user.DisplayName,
                                                    EmailAddress = user.EmailAddress,
                                                    Enabled = user.Enabled
                                                };

                    List<AuthorityGroupSummary> groups = new List<AuthorityGroupSummary>();

                    foreach(UserGroup userGroup in user.UserGroups)
                    {
                        groups.Add(new AuthorityGroupSummary(new EntityRef(userGroup.UserGroupRef), userGroup.Name, userGroup.Name,false));
                    }

                    updateUser.AuthorityGroups = groups;

                    service.UpdateUserDetail(updateUser);
                    success = true;
                }
                catch (Exception ex)
                {
                	Platform.Log(LogLevel.Error, ex, "Unexpected exception updating user: {0}", user.DisplayName);
                }
            }

            return success;
        }
Example #4
0
        private void SaveData()
        {
            if (User == null)
            {
                User = new UserRowData();
            }
            
            if(EditMode)
            {
                User.Enabled = UserEnabledCheckbox.Checked;
            } 
            else
            {
                User.UserName = UserLoginId.Text;
                User.Enabled = true;
            }

            User.DisplayName = DisplayName.Text;
            User.EmailAddress = EmailAddressId.Text;

            User.UserGroups.Clear();
            foreach (ListItem item in UserGroupListBox.Items)
            {
                if (item.Selected)
                {
                    User.UserGroups.Add(new UserGroup(
                        item.Value, item.Text));
                }
            }
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                using (var service = new AuthorityManagement())
                 {
                    IList<AuthorityGroupSummary> list = service.ListAllAuthorityGroups();
                    IList<ListItem> items = CollectionUtils.Map(
                        list,
                        delegate(AuthorityGroupSummary summary)
                        {
                            return new ListItem(summary.Name, summary.AuthorityGroupRef.Serialize());
                        }
                        );
                    UserGroupListBox.Items.AddRange(CollectionUtils.ToArray(items));
                };
            }
            else
            {
                if (ViewState[ "EditMode"] != null)
                    _editMode = (bool) ViewState[ "EditMode"];

                if (ViewState[ "EditedUser"] != null)
                    _user = ViewState[ "EditedUser"] as UserRowData;
            }
        }
Example #6
0
 public void OnResetPassword(UserRowData userRowData)
 {
     if (_controller.ResetPassword(userRowData))
     {
         PasswordResetConfirmation.Message = string.Format(SR.AdminUser_PasswordReset, userRowData.UserName);
     } else {
         PasswordResetConfirmation.Message = ErrorMessages.PasswordResetFailed;
         }
     PasswordResetConfirmation.Title = Titles.AdminUser_PasswordResetDialogTitle;
     PasswordResetConfirmation.MessageType = MessageBox.MessageTypeEnum.INFORMATION;
     PasswordResetConfirmation.Show();
 }
Example #7
0
 public void OnDeleteUser(UserRowData userRowData)
 {
     DeleteConfirmation.Message = string.Format(SR.AdminUser_DeleteDialog_AreYouSure, userRowData.DisplayName, userRowData.UserName);
     DeleteConfirmation.MessageType = MessageBox.MessageTypeEnum.YESNO;
     DeleteConfirmation.Data = userRowData;
     DeleteConfirmation.Show();
 }
Example #8
0
 public void OnEditUser(UserRowData userRowData)
 {
     AddEditUserDialog.EditMode = true;
     AddEditUserDialog.User = userRowData;
     AddEditUserDialog.Show(true);
 }
        public bool DeleteUser(UserRowData user)
        {
            bool success = false;

            using(UserManagement service = new UserManagement())
            {
                try
                {
                    service.DeleteUser(user.UserName);
                    success = true;
                }
                catch (Exception ex)
                {
					Platform.Log(LogLevel.Error, ex, "Unexpected exception deleting user: {0}",
								 user.DisplayName);
                }
            }

            return success;
        }
        public bool ResetPassword(UserRowData user)
        {
            bool success = false;

            using(UserManagement service = new UserManagement())
            {
                try
                {
                    service.ResetPassword(user.UserName);
                    success = true;
                }
                catch (Exception ex)
                {
                	Platform.Log(LogLevel.Error, ex, "Unexpected exception resetting password for user: {0}",
                	             user.DisplayName);
                }
            }

            return success;
        }