We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8274be6 commit fe06432Copy full SHA for fe06432
1 file changed
Demo/Lib/ldapurl/urlsearch.py
@@ -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