From: Goucher, A. <ada...@hp...> - 2004-01-13 15:46:42
|
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 =3D "cn=3Dadam,ou=3Dtest,dc=3Dads" password =3D "foo" password_attr =3D "unicodePwd" unicode_step1 =3D unicode("\"" + password + "\"", "iso-8859-1") unicode_step2 =3D unicode_step1.encode("utf-16-le") password_value =3D unicode_step2 mods =3D [(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=20 |