-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attribute charset not available in recent ldapurl anymore
- Loading branch information
stroeder
committed
Feb 2, 2003
1 parent
8274be6
commit fe06432
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
Do a search with the LDAP URL specified at command-line. | ||
No output of LDAP data is produced except trace output. | ||
""" | ||
|
||
import sys,getpass,ldap,ldapurl | ||
|
||
try: | ||
ldapUrl = ldapurl.LDAPUrl(ldapUrl=sys.argv[1]) | ||
except IndexError: | ||
print 'Usage: %s [LDAP URL]' % (sys.argv[0]) | ||
sys.exit(1) | ||
|
||
for a in [ | ||
'urlscheme','hostport','dn','attrs','scope', | ||
'filterstr','extensions','who','cred' | ||
]: | ||
print a,repr(getattr(ldapUrl,a)) | ||
|
||
l = ldap.initialize(ldapUrl.initializeUrl(),trace_level=1) | ||
if ldapUrl.who!=None: | ||
if ldapUrl.cred!=None: | ||
cred=ldapUrl.cred | ||
else: | ||
print 'Enter password for simple bind with',repr(ldapUrl.who) | ||
cred=getpass.getpass() | ||
l.simple_bind_s(ldapUrl.who,cred) | ||
|
||
res = l.search_s(ldapUrl.dn,ldapUrl.scope,ldapUrl.filterstr,ldapUrl.attrs) | ||
|
||
print len(res),'search results' |