-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathbug551198.py
39 lines (31 loc) · 891 Bytes
/
bug551198.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from bug_harness import DSAdminHarness as DSAdmin
from dsadmin import Entry
import os
import time
import ldap
import ldapurl
import ldif
import tempfile
from ldap.ldapobject import SimpleLDAPObject
import pprint
host1 = "localhost.localdomain"
port1 = 1110
basedn = 'dc=example,dc=com'
ldapifilepath = os.environ.get('PREFIX', "") + "/var/run/slapd-srv.socket"
os.environ['USE_GDB'] = "1"
srv = DSAdmin.createInstance({
'newrootpw': 'password',
'newhost': host1,
'newport': port1,
'newinst': 'srv',
'newsuffix': basedn,
'no_admin': True,
'ldapifilepath': ldapifilepath
})
del os.environ['USE_GDB']
ldapiurl = ldapurl.LDAPUrl(None, "ldapi", ldapifilepath)
conn = SimpleLDAPObject(ldapiurl.initializeUrl())
print "connecting to", ldapiurl.initializeUrl()
conn.simple_bind_s("cn=directory manager", "password")
ents = conn.search_s("", ldap.SCOPE_BASE)
pprint.pprint(ents)