python-ldap-test | Easy to setup in-memory LDAP server for tests | Identity Management library
kandi X-RAY | python-ldap-test Summary
Support
Quality
Security
License
Reuse
- Read the content of the file .
python-ldap-test Key Features
python-ldap-test Examples and Code Snippets
Trending Discussions on python-ldap-test
Trending Discussions on python-ldap-test
QUESTION
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
ANSWER
Answered 2020-Oct-19 at 18:00The immediate cause of your error is that the ldapadd
method expects to receive LDIF-format content, but you are passing it a filename. So you want something more like:
with slapdtest.SlapdObject() as server:
with open('ldap_dump.ldif') as fd:
server.ldapadd(fd.read())
You seem to be calling server.start()
after ldapadd
, and I think you need those lines in the reverse order.
Lastly, your sample file is probably invalid because it doesn't define the higher-level containers (e.g., dc=institute.edu
) to contain the objects described in your example.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install python-ldap-test
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page