File: ldapcontrols.py

package info (click to toggle)
python-ldap-doc 2.3-2.1
  • links: PTS
  • area: contrib
  • in suites: squeeze
  • size: 200 kB
  • ctags: 121
  • sloc: python: 661; makefile: 44
file content (33 lines) | stat: -rw-r--r-- 831 bytes parent folder | download | duplicates (9)
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*'#'