lundi 19 octobre 2020

python-ldap: How to fix b'ldapadd: invalid format (line 1) entry: ""\n'

I want to create an ldap test server. So I dumped the ldap data with ldapsearch and created a .ldif file Now I want to create a test ldap server with this data. I want to use the slapdtest-module from python-ldap.

import slapdtest

with slapdtest.SlapdObject() as server:

    server.ldapadd("ldap_dump.ldif")
    server.start()

But I get the error message:

RuntimeError: ['/usr/bin/ldapadd', '-H', 'ldapi://../python-ldap-test-53974/ldapi', '-Y', 'EXTERNAL', '-Q', '-n'] process failed:
b''
b'ldapadd: invalid format (line 1) entry: ""\n'

$file ldap_dump.ldif returns ldap_dump.ldif: ASCII text. So the line endings shouldn't be a problem actually.

This is my reduced ldap_dump file:

dn: cn=User,dc=institute.edu
sn: User
objectClass: top
objectClass: user
cn: User

Aucun commentaire:

Enregistrer un commentaire