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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -