From: Bjorn O. G. <bjo...@it...> - 2005-05-23 11:14:37
|
Daniel LB: > Hi >=20 > Is it possible to set a user's password without knowing the old > password with python-ldap? >=20 > I have only come across the passwd(user,oldpw,newpw) function, which > requires the old password, but if you are logged in as Administrator > you should be able to *set* the users' password directly, no? Just use the function modify_s to do such modifications. import ldap import ldap.modlist as modlist newattrs =3D {'userPassword': '1337secret'} old =3D l.search_s(base,ldap.SCOPE_SUBTREE,"uid=3Dsomeuser",[])[0][1]['us= erPassword'][0] # Given that you're binding with a user with read-priv to userPassword. attrs =3D modlist.modifyModlist(old,newattrs) l.modify_s(dn,attrs) # Alternatively, make a list of change-commands. I think its documented # in the module, so just play along with help(ldap.modify_s) or # something. --=20 Regards =20 Bj=F8rn Ove Gr=F8tan |