title: Reset Active Directory password using Python and ldap3
body: <p>I seem to be running into the classic error with resetting passwords in AD even though everything I have found online points generally towards the fact that I should be golden.</p>
  
  <p>Code first.</p>
  
  <pre><code>from ldap3 import *
  
  username = '&lt;account with the proper permissions&gt;'
  password = '&lt;totally@realpassword&gt;'
  
  server = Server('&lt;fqdn of server&gt;', use_ssl=True, get_info=ALL)
  conn = Connection(server, user='&lt;domain&gt;\\' + username, password=password, authentication=NTLM, auto_bind=True)
  
  print(conn)
  
  user_dn = 'CN=Test,OU=US,OU=NA,OU=Employees,OU=Users,DC=domain,DC=com'
  new_pass = 'U^mod2olla'
  
  r = conn.extend.microsoft.modify_password(user_dn, new_pass)
  
  print(conn.result)
  </code></pre>
  
  <p>This seems to be the proper way to instantiate a connection to my LDAP server over SSL as corroborated by this Connection printout:</p>
  
  <pre><code>ldaps://ldap.domain.com:636 - ssl - user: domain.com\samaccountname - not lazy - bound - open - &lt;local: IP:62368 - remote: IP:636&gt; - tls not started - listening - SyncStrategy - internal decoder
  </code></pre>
  
  <p>But I am still receiving this error:</p>
  
  <pre><code>{'result': 53, 'description': 'unwillingToPerform', 'dn': '', 'message': '0000001F: SvcErr: DSID-031A1248, problem 5003 (WILL_NOT_PERFORM), data 0\n\x00', 'referrals': None, 'type': 'modifyResponse'}
  </code></pre>
  
  <p>From my Googling this usually means that either the password is not being encoded properly, or the connection is not sufficiently secure according to the LDAP server.</p>
  
  <p>I'm lost at this point. Thoughts?</p>
  
  <p>@cannatag if you are out there...I need you :)</p>
  
  <h1>My Research links:</h1>
  
  <p><a href="https://github.com/cannatag/ldap3/issues/130" rel="nofollow noreferrer">https://github.com/cannatag/ldap3/issues/130</a></p>
  
  <p><a href="https://stackoverflow.com/questions/41816278/python-3-5-ldap3-and-modify-password/41833022">Python 3.5, ldap3 and modify_password()</a></p>
  
  <p><a href="https://stackoverflow.com/questions/38164544/unable-to-change-users-password-via-ldap3-python3/38171370#38171370">Unable to change user&#39;s password via ldap3 Python3</a></p>
  
  <p><a href="https://stackoverflow.com/questions/37847042/changing-active-directory-user-password-in-python-3-x/37890705#37890705">Changing Active Directory user password in Python 3.x</a></p>