コード例 #1
0
        /// <summary>
        /// Changes the password for a connector space object
        /// </summary>
        /// <param name="oldPassword">The user's old password</param>
        /// <param name="newPassword">The user's new password</param>
        public void ChangePassword(string oldPassword, string newPassword)
        {
            ManagementObject mo = CSObject.GetWmiObject(this.ID);

            string result = mo.InvokeMethod("ChangePassword", new object[] { oldPassword, newPassword }) as string;

            if (result == "access-denied")
            {
                throw new UnauthorizedAccessException();
            }
            else if (result != "success")
            {
                throw new MiiserverException($"The operation returned {result}");
            }
        }
コード例 #2
0
        /// <summary>
        /// Sets the password for the connector space object
        /// </summary>
        /// <param name="password">The password to set</param>
        /// <param name="forceChangeAtLogin">A value that indicates whether the password should be changed at the next login</param>
        /// <param name="unlockAccount">A value that indicates whether the account should be unlocked</param>
        /// <param name="enforcePasswordPolicy">A value that indicates whether the password policy should be enforced</param>
        public void SetPassword(string password, bool forceChangeAtLogin, bool unlockAccount, bool enforcePasswordPolicy)
        {
            ManagementObject mo = CSObject.GetWmiObject(this.ID);

            string result = mo.InvokeMethod("SetPassword", new object[] { password, forceChangeAtLogin, unlockAccount, enforcePasswordPolicy }) as string;

            if (result == "access-denied")
            {
                throw new UnauthorizedAccessException();
            }
            else if (result != "success")
            {
                throw new MiiserverException($"The operation returned {result}");
            }
        }