-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathldapcontrols.py
More file actions
33 lines (26 loc) · 835 Bytes
/
ldapcontrols.py
File metadata and controls
33 lines (26 loc) · 835 Bytes
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
import ldap,ldapurl,pprint
from ldap.controls import LDAPControl,BooleanControl
l = ldap.initialize('ldap://localhost:1390',trace_level=2)
print(60*'#')
pprint.pprint(l.get_option(ldap.OPT_SERVER_CONTROLS))
l.manage_dsa_it(1,1)
pprint.pprint(l.get_option(ldap.OPT_SERVER_CONTROLS))
print(60*'#')
# Search with ManageDsaIT control (which has no value)
pprint.pprint(l.search_ext_s(
'cn=Test-Referral,ou=Testing,dc=stroeder,dc=de',
ldap.SCOPE_BASE,
'(objectClass=*)',
['*','+'],
serverctrls = [ LDAPControl('2.16.840.1.113730.3.4.2',1,None) ],
))
print(60*'#')
# Search with Subentries control (which has boolean value)
pprint.pprint(l.search_ext_s(
'dc=stroeder,dc=de',
ldap.SCOPE_SUBTREE,
'(objectClass=subentry)',
['*','+'],
serverctrls = [ BooleanControl('1.3.6.1.4.1.4203.1.10.1',1,1) ],
))
print(60*'#')