Beispiel #1
0
        /// <summary>
        /// Used to unlock the specific user account
        /// </summary>
        /// <param name="dataAccess">Domain connection</param>
        /// <param name="userObject">User properties</param>
        /// <param name="objects">Object properties</param>
        /// <param name="domainObject">Domain properties</param>
        public void UnlockUserAccount(DirectoryEntry dataAccess, Users userObject, Objects objects, Domain domainObject)
        {
            try
            {
                var function_object             = new SecurityFunctions();
                var _distinguishedConnectionURL = function_object.DistinguishedConnectionURL(dataAccess, objects);
                var data_access_object          = new DirectoryServerDataAccess();

                var directoryEntry = data_access_object.ObjectConnection(_distinguishedConnectionURL, domainObject);
                directoryEntry.Properties["lockoutTime"].Value = 0;
                directoryEntry.CommitChanges();
                //Console.WriteLine("UnLock success");
            }
            catch (Exception ex)
            {
                //Console.WriteLine("Message:" + ex);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Used to change user passwords
        /// </summary>
        /// <param name="dataAccess">Domain connection</param>
        /// <param name="userObject">User properties</param>
        /// <param name="domainObject">Domain properties</param>
        /// <param name="objects">Object properties</param>
        public void PasswordChange(DirectoryEntry dataAccess, Users userObject, Domain domainObject, Objects objects)
        {
            try
            {
                var function_object             = new SecurityFunctions();
                var _distinguishedConnectionURL = function_object.DistinguishedConnectionURL(dataAccess, objects);
                var dataAccessObject            = new DirectoryServerDataAccess();

                var dirEntry = dataAccessObject.ObjectConnection(_distinguishedConnectionURL, domainObject);
                dirEntry.Invoke("SetPassword", new object[] { userObject.Password });
                dirEntry.Properties["LockOutTime"].Value = 0; //unlock account
                dirEntry.Close();
                //Console.WriteLine("Reset password success");
            }
            catch (Exception ex)
            {
                //Console.WriteLine("Message:" + ex);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Used to disable the specific user account
        /// </summary>
        /// <param name="dataAccess">Domain connection</param>
        /// <param name="userObject">User properties</param>
        /// <param name="objects">Object properties</param>
        /// <param name="domainObject">Domain properties</param>
        public void DisableUserAccount(DirectoryEntry dataAccess, Users userObject, Objects objects, Domain domainObject)
        {
            try
            {
                var function_object             = new SecurityFunctions();
                var _distinguishedConnectionURL = function_object.DistinguishedConnectionURL(dataAccess, objects);
                var data_access_object          = new DirectoryServerDataAccess();

                var dirEntry = data_access_object.ObjectConnection(_distinguishedConnectionURL, domainObject);
                var val      = (int)dirEntry.Properties["userAccountControl"].Value;
                dirEntry.Properties["userAccountControl"].Value = val | 0x2;;
                dirEntry.CommitChanges();
                dirEntry.Close();
                //Console.WriteLine("Disable success");
            }
            catch (Exception ex)
            {
                //Console.WriteLine("Message:" + ex);
            }
        }