appy.bin: added a script for checking a LDAP connection; appy.gen: bugfix in xhtml2odt conversion (algorithm for checking ODT-invalid subtag hierarchies); appy.gen: xhtml2odt conversion: force continue-numbering to 'false' for every numbered list.
This commit is contained in:
parent
bce384e2da
commit
b9e07f8c1c
9 changed files with 673 additions and 595 deletions
43
bin/checkldap.py
Normal file
43
bin/checkldap.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
'''This script allows to check a LDAP connection.'''
|
||||
import sys, ldap
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
class LdapTester:
|
||||
'''Usage: python checkldap.py ldapUri login password base.'''
|
||||
def __init__(self):
|
||||
# Get params from shell args.
|
||||
if len(sys.argv) != 5:
|
||||
print LdapTester.__doc__
|
||||
sys.exit(0)
|
||||
self.uri, self.login, self.password, self.base = sys.argv[1:]
|
||||
self.tentatives = 5
|
||||
self.timeout = 5
|
||||
self.attrList = ['uid']
|
||||
self.ssl = False
|
||||
|
||||
def test(self):
|
||||
# Connect the the LDAP
|
||||
print 'Creating server object for server %s...' % self.uri
|
||||
server = ldap.initialize(self.uri)
|
||||
print 'Done. Login with %s...' % self.login
|
||||
server.simple_bind(self.login, self.password)
|
||||
if self.ssl:
|
||||
server.start_tls_s()
|
||||
try:
|
||||
for i in range(self.tentatives):
|
||||
try:
|
||||
print 'Done. Performing a simple query on %s...' % self.base
|
||||
res = server.search_st(
|
||||
self.base, ldap.SCOPE_ONELEVEL, attrlist=self.attrList,
|
||||
timeout=5)
|
||||
print 'Got res', res
|
||||
break
|
||||
except ldap.TIMEOUT:
|
||||
print 'Got timeout.'
|
||||
except ldap.LDAPError, le:
|
||||
print le.__class__.__name__, le
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
LdapTester().test()
|
||||
# ------------------------------------------------------------------------------
|
Loading…
Add table
Add a link
Reference in a new issue