|
From: Jens V. <je...@zo...> - 2004-01-13 20:47:19
|
> 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).
Does that really surprise you?
> 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.
Yeah, that's quite handy. For those people who are forced to use AD ;)
jens
|