title: python LDAP modify password
body: <p>I have a Windows 2012 R2 server and a LDAP server on it. I wrote a python script to modify the password of user (the user, who isn't admin, want to modify is own password. I have an other function which modify the password when you're admin, but I don't want to set a password, but modify it). This is a sample of my code :</p>
  
  <pre><code>#!/usr/bin/env python
  #coding:utf-8
  
  import ldap
  import ldap.modlist as modlist
  
  ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
  ld = ldap.initialize('ldaps://xxx.xxx.xxx.xxx:636')
  ld.simple_bind_s('XXXXXX@ad2012.local', 'XXXXXXX')
  
  new = {'unicodePwd':[str('"XXXXXXXX"').decode('utf8').encode('utf-16-le')]}
  old = {'unicodePwd':[str('"YYYYYYYY"').decode('utf8').encode('utf-16-le')]}
  
  ldif = modlist.modifyModlist(old, new)
  ld.modify_s('A DN',ldif)
  </code></pre>
  
  <p>But when I run it, I have an error :</p>
  
  <blockquote>
    <p>ldap.CONSTRAINT_VIOLATION: {'info': '0000052D: AtrErr: DSID-03191083, #1:\n\t0: 0000052D: DSID-03191083, problem 1005 (CONSTRAINT_ATT_TYPE), data 0, Att 9005a (unicodePwd)\n', 'desc': 'Constraint violation'}</p>
  </blockquote>
  
  <p>I tried with decode/encode or without. passwd_s() is not working either.
  I searched a lot on google, I found a lot of solutions for others people, but not working for me.</p>
  
  <p>If someone could help me, thanks in advance.</p>