How to use python-ldap to modify configuration DIT of openldap? -
for example, can use following command change rootdn password:
sudo ldapmodify -h ldapi:// -y external -f newpasswd.ldif
the contend of newpasswd.ldif is:
dn: olcdatabase={1}mdb,cn=config changetype: modify replace: olcrootpw olcrootpw: {ssha}/z6e+b4l6ucglrli4ksnax142wdch6de
my question is, how can implement using python-ldap? searched while, not find answer.
i find solution, here code.
def ldap_modify_root(): conn = ldap.initialize("ldapi://") conn.sasl_external_bind_s() old = {'olcrootpw': 'xxx'} new = {'olcrootpw': '{ssha}/z6e+b4l6ucglrli4ksnax142wdch6de'} ldif = modlist.modifymodlist(old, new) dn = "olcdatabase={1}mdb,cn=config" conn.modify_s(dn, ldif) conn.unbind()
Comments
Post a Comment