[python-ldap] qeustion searching underlying OU with python-ldap

Joey Hendricks joeyhendricks20 at gmail.com
Sat Nov 26 09:11:40 EST 2016

Dear subscribers of the python LDAP mailing list,

I have a qeustion on how to modify a password of a AD user.
I have been doing it until now this way:

      name_search = "Test.Test"
      SEARCH_LOCATION = "OU=Assengraaf,DC=assengraaf,DC=nl"
      user_dn = ("CN=%s," + (SEARCH_LOCATION)) % name_search
      server = "ldaps://Server01.assengraaf.nl:636"
      ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
      conn = ldap.initialize(server)
      conn.set_option(ldap.OPT_REFERRALS, 0)
      conn.set_option(ldap.OPT_PROTOCOL_VERSION, 3)
      conn.set_option( ldap.OPT_X_TLS_DEMAND, True )
      conn.set_option( ldap.OPT_DEBUG_LEVEL, 4095)
      conn.simple_bind_s("Administrator at assengraaf.nl", "password")
      password_value1 = '"{0}\"'.format(password).encode("utf-16-le")
      add_pass = [(ldap.MOD_REPLACE, "UnicodePwd", password_value1)]
      conn.modify_s(user_dn, add_pass)

But i want to be able to modify a user password without specifying the
location of the user, i just want it to search the entire AD for that user.
What would be the best way to achieve  this?

Hope you guys can help me out :)

Kind regards

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20161126/4d232a39/attachment.html>

More information about the python-ldap mailing list