I have a LDAP schema in a .ldif
file that I would like to use python-ldap to install the schema on my LDAP server. My context is the installation process of a python application that needs some custom LDAP schemas.
There is a bit of documentation about ldif and schemas in python-ldap, but I do not know where to start.
How can I install a schema with python-ldap?
import ldap.modlist
import ldif
with open("myschema.ldif") as fd:
parser = ldif.LDIFRecordList(fd)
parser.parse()
for dn, entry in parser.all_records:
add_modlist = ldap.modlist.addModlist(entry)
conn.add_s(dn, add_modlist) # where 'conn' is a LDAP connection