Changing password in Active Directory
Goucher, Adam
adam.goucher at hp.com
Tue Jan 13 16:46:17 CET 2004
I gave up for the moment on getting ldaps working on win32 and moved to
solaris with some success. Thought I would share some code for resetting
passwords in Active Directory (which isnt as straight forward as it
seems). I had initially tried to use ldap.modlist to make the modlist,
but it kept trying to do an add, when you need to do a replace in the
case where you bind as administrator (which I am).
# assumptions:
# a) its active directory
# b) you've bound to the ssl port
# c) you've bound as administrator
# d) your connection is called ldap_handle
account_dn = "cn=adam,ou=test,dc=ads"
password = "foo"
password_attr = "unicodePwd"
unicode_step1 = unicode("\"" + password + "\"", "iso-8859-1")
unicode_step2 = unicode_step1.encode("utf-16-le")
password_value = unicode_step2
mods = [(ldap.MOD_REPLACE, password_attr, [password_value])]
ldap_handle.modify(account_dn, mods)
Thought it might be handy to have this able to be found by the mailing
list search.
______________________________
Adam Goucher
Testing Group
HP OpenView Select Access
Hewlett-Packard
901 King St W.
Toronto, Ontario
M5V 3H5
Phone: +1-416-309-5208
Fax: +1-416-309-4406
More information about the python-ldap
mailing list