X Tutup
Skip to content

Commit fe06432

Browse files
author
stroeder
committed
Attribute charset not available in recent ldapurl anymore
1 parent 8274be6 commit fe06432

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Demo/Lib/ldapurl/urlsearch.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
Do a search with the LDAP URL specified at command-line.
3+
4+
No output of LDAP data is produced except trace output.
5+
"""
6+
7+
import sys,getpass,ldap,ldapurl
8+
9+
try:
10+
ldapUrl = ldapurl.LDAPUrl(ldapUrl=sys.argv[1])
11+
except IndexError:
12+
print 'Usage: %s [LDAP URL]' % (sys.argv[0])
13+
sys.exit(1)
14+
15+
for a in [
16+
'urlscheme','hostport','dn','attrs','scope',
17+
'filterstr','extensions','who','cred'
18+
]:
19+
print a,repr(getattr(ldapUrl,a))
20+
21+
l = ldap.initialize(ldapUrl.initializeUrl(),trace_level=1)
22+
if ldapUrl.who!=None:
23+
if ldapUrl.cred!=None:
24+
cred=ldapUrl.cred
25+
else:
26+
print 'Enter password for simple bind with',repr(ldapUrl.who)
27+
cred=getpass.getpass()
28+
l.simple_bind_s(ldapUrl.who,cred)
29+
30+
res = l.search_s(ldapUrl.dn,ldapUrl.scope,ldapUrl.filterstr,ldapUrl.attrs)
31+
32+
print len(res),'search results'

0 commit comments

Comments
 (0)
X Tutup