Error Message in Active Directory: One or more input parameters are invalid RRS feed

  • Question

  • I am writing code to change password for the user in Active Directory by following the instructions below:

    Many of the function are working but as soon as I use the functions "SetPassword()" or "ChangePassword()", then I get an error.
    "One or more input parameters are invalid".

    I cannot understand as I am even using the Admin username/password.........

    public class PasswordModifier


            String userName1 = "user1";

            String userName2 = "user2";
            String userName3 = "user3";
            String password1 = "password111";
            String password2 = "password222";
            String ldapServer = "";
            String rootContainer = "CN=USERS,DC=abc,DC=ad";

            String ADUser = "adminUser";
            String ADPassword = "adminPassword";

           public void AccountMgmt()


                    PrincipalContext _context = GetPrincipalContext();

                    Boolean isLockedUser1 = IsAccountLocked(userName1);
                    Boolean isLockedUser2 = IsAccountLocked(userName2);
                    Boolean isLockedUser3 = IsAccountLocked(userName3);

                    Boolean isValidUser1_1 = ValidateCredentials(userName1, password1);
                    Boolean isValidUser1_2 = ValidateCredentials(userName1, password2);

                    UserPrincipal _user1 = UserPrincipal.FindByIdentity(_context, userName1);
                    UserPrincipal _user2 = UserPrincipal.FindByIdentity(_context, userName2);
                    UserPrincipal _user3 = UserPrincipal.FindByIdentity(_context, userName3);

                    _user1.SetPassword(password2);  //==>  Gives Error  
                    _user1.ChangePassword(password1, password2);  //==>  Gives Error  
                catch (Exception ex)
                    MessageBox.Show("An error occured: " + ex.ToString());


           public PrincipalContext GetPrincipalContext()


               PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, ldapServer, rootContainer, ContextOptions.SimpleBind, ADUser, ADPassword);

               return oPrincipalContext;




    Can you help me with this error as this seems completely illogical !!!!
    What am i doing wrong ??

    Wednesday, August 31, 2016 4:17 PM

All replies

  • Hello Shanchat972,

    This error does not tell you much but it normally comes when you do not meet the Password policies set in the Server. This may be because of using the same passwords, can you try using a whole new password and meeting all the complexities or requirements and share if it worked :)


    Wednesday, December 13, 2017 5:01 PM
  • Hello rakz0186,

    It 2021 and I have the same issue. I have been trying to use a password which is meet the password policy but my application throw the same exception:

    "One or more input parameters are invalid".

    Do you have another solution for this error?

    Thanks in advance !

    Thursday, September 3, 2020 6:46 AM