Exemple #1
0
        ////-------------------------------------------------------------------------------------------------------------------------------------------------------------
        ///// <summary>
        ///// If deleteExisting groups is true the entered group type will overwrite
        ///// any existing groups assigned to this user. (This is require where
        ///// a user can only belong to one group)
        ///// </summary>
        ///// <param name="updatedUser"></param>
        ///// <param name="groupType"></param>
        ///// <param name="deleteExistingGroups"></param>
        ///// <returns></returns>
        //public bool EditUserPassword(int userID, SecureString Password, MGGroupType groupType, bool p) {
        //    bool result = false;

        //    try {
        //        result = SecurityOperations.UpdateUserPassword(userID, Password, Authorisation.UseMGLRatherThanMySQLPasswordEncryption);

        //        if (result) {
        //            DateTime pWordChangeTimeStamp = DateTime.Now;

        //            SecurityOperations.UpdatePasswordChangeDate(userID, pWordChangeTimeStamp);
        //            // 13-Jul-2015 - lets email the user to confirm that their password has changed!
        //            MGUser u = null;
        //            Authorisation.GetUser(userID, out u);
        //            SecurityOperations.PasswordChangedEmailUser(u, pWordChangeTimeStamp);

        //        }
        //    } catch (Exception ex) {
        //        Logger.Log("Error in UserAdministration.AddUser." + ex.Message);
        //    } finally {
        //        SecurityOperations.Finish();
        //    }

        //    return result;
        //}


        //-------------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// If deleteExisting groups is true the entered group type will overwrite
        /// any existing groups assigned to this user. (This is require where
        /// a user can only belong to one group)
        /// </summary>
        /// <param name="updatedUser"></param>
        /// <param name="groupType"></param>
        /// <param name="deleteExistingGroups"></param>
        /// <returns></returns>
        public bool EditUserDetails(MGUser updatedUser, MGGroupType groupType, bool p)
        {
            bool result = false;

            try {
                result = SecurityOperations.UpdateUserDetails(updatedUser.ID, updatedUser.Username, updatedUser.Email, updatedUser.JobTitle,
                                                              updatedUser.Organisation, updatedUser.OrganisationID, updatedUser.Telephone);

                //need to add the user to the user_groups xref's
                result = result && SecurityOperations.DeleteUsersGroupXrefs(updatedUser.ID);
                result = result && SecurityOperations.UpdateUserToGroupXref(updatedUser.Username, groupType);

                //need to update the applications user to group to  xref's
                if (result)
                {
                    UserOperations userOps = new UserOperations(MGLApplicationSecurityInterface.Instance().DatabaseConfig);

                    Dictionary <int, List <int> > userGroupDict = userOps.UserGroupDictionary();
                    userOps.Finish();

                    MGLApplicationSecurityInterface.Instance().UserGroupXref = userGroupDict;
                }
            } catch (Exception ex) {
                Logger.LogError(8, "Error in UserAdministration.AddUser." + ex.Message);
            } finally {
                SecurityOperations.Finish();
            }

            return(result);
        }
Exemple #2
0
 public void Finish()
 {
     if (SecurityOperations != null)
     {
         SecurityOperations.Finish();
     }
 }
Exemple #3
0
        //--------------------------------------------------------------------------------------------------------------------------------------------------------------
        public bool UserNameAlreadyExists(SecureString username)
        {
            bool result = false;

            try {
                result = SecurityOperations.UserNameAlreadyExists(username);
            } catch (Exception ex) {
                Logger.LogError(8, "Problem checking if username exists at " + ex);
                return(true); // return true, in case they are trying to add this username.
            } finally {
                SecurityOperations.Finish();
            }

            return(result);
        }
Exemple #4
0
        //--------------------------------------------------------------------------------------------------------------------------------------------------------------
        public bool EmailAlreadyExists(SecureString emailAddress)
        {
            bool result = false;

            try {
                result = SecurityOperations.EmailAlreadyExists(emailAddress);
            } catch (Exception ex) {
                Logger.LogError(8, "Problem checking if email exists at " + ex);
                return(true); // return true, in case they are trying to add this email.
            } finally {
                SecurityOperations.Finish();
            }

            return(result);
        }