Пример #1
0
 public SecurityUserDetails(User user, Login p)
 {
     parent = p;
     InitializeComponent();
     _user = user;
     populateFormFromUser(user);
 }
Пример #2
0
 private void populateFormFromUser(User user)
 {
     txtFirstName.Text = user.FirstName;
     txtSurname.Text = user.Surname;
     txtUsername.Text = user.UserName;
     //txtNotes.Text =
     cbxAssignedRole.SelectedItem = user.UserRole.RoleName;
     lblUserId.Text = user.UserId;
     txtPassword.Text = SecurityServiceProvider.getUserPassword(user.UserId);
 }
Пример #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            User tmpUser =
                new User(lblUserId.Text, txtUsername.Text, txtFirstName.Text, txtSurname.Text,
                         SecurityServiceProvider.GetRoleFromName(cbxAssignedRole.Text));
            if (_user != null)
            {
                string opwd = SecurityServiceProvider.getUserPassword(_user.UserId);

                SecurityServiceProvider.UpdateUser(tmpUser, txtPassword.Text, _user, opwd);

                tmpUser = null;
            }
            else
            {
                SecurityServiceProvider.AddNewUser(tmpUser, txtPassword.Text);
            }

            parent.SetUserControl(new SecurityMgmtUI(parent));
        }
Пример #4
0
 public static bool CompareUserObjects(User user_1, User user_2)
 {
     if (user_1.UserRole != user_2.UserRole)
     {
         return false;
     }
     else if (user_1.UserName != user_2.UserName)
     {
         return false;
     }
     else if(user_1.FirstName != user_2.FirstName)
     {
         return false;
     }
     else if(user_1.Surname != user_2.Surname)
     {
         return false;
     }
     else
     {
         return true;
     }
 }
Пример #5
0
 public static void AddNewUser(User user,string password)
 {
     AddNewUser(user.UserName, user.FirstName, user.Surname, Int32.Parse(user.UserRole.RoleId), password);
 }
Пример #6
0
        public static void UpdateUser(User newUser, string newPassword, User oldUser, string oPassword)
        {
            string updateUserDetail;

            bool update = false;

            if (!CompareUserObjects(newUser, oldUser))
            {
                update = true;
            }
            if(!newPassword.Equals(oPassword))
            {
                newPassword = Utility.encryptString(newPassword);
                update = true;
            }
            if(update)
            {
                updateUserDetail = string.Format(@"UPDATE LOGIN set username = '******', password = '******', firstname = '{2}', surname = '{3}', roleid = {4} WHERE id = {5}", Utility.parseString(newUser.UserName), newPassword,
                              Utility.parseString(newUser.FirstName), Utility.parseString(newUser.Surname), newUser.UserRole.RoleId,newUser.UserId);

                db.runNonQuery(updateUserDetail);
            }
        }
Пример #7
0
        public static User LoadUser(int userID)
        {
            string getUserNamesSQL =
                string.Format(@"SELECT id,username, firstname, surname,roleid from login where id = {0}", userID);

            string[] result = db.singleRow(getUserNamesSQL);
            SecurityRole role = getSecurityRole(Int32.Parse(result[4]));
            User tmpUser = new User(result[0], result[1], result[2],result[3] ,role);

            return tmpUser;
        }
Пример #8
0
 public static string GetUserPassword(User user)
 {
     string getuserpasswordsql = string.Format("SELECT password from login where id = {0}",Int32.Parse(user.UserId));
     return db.scalarValue(getuserpasswordsql);
 }
Пример #9
0
 public static void EditUser(User user,string password)
 {
     EditUser(user.UserId, user.UserName, user.FirstName, user.Surname, Int32.Parse(user.UserId), password);
 }
Пример #10
0
 public static void DeleteUser(User user)
 {
     DeleteUser(Int32.Parse(user.UserId));
 }
Пример #11
0
 public static bool verifyUsernamePassword(string txtUsername, string txtPassword)
 {
     try
        {
        //IPassword encrypt = new OpenhbcMd5();
        int i = db.getUserId(txtUsername, txtPassword);
        Entity.CurrentUserId = i;
        _currentUser = LoadUser(i);
        return true;
        }catch(Exception ex)
        {
        return false;
        }
 }