1

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?

2 Answers 2

1
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
Sign up to request clarification or add additional context in comments.

Comments

0

The short answer is what @azmeuk has written before.

The long answer is: it depends on the format of your LDIF file. If it contains modify statements then you cannot easily parse the file with python-ldap.

Please check my question at Process LDIF modify records with python-ldap to see what I'm talking about.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.