appy.bin: improvements in ldapchecker.py; appy.pod: solved bug https://bugs.launchpad.net/appy/+bug/740290 (concurrent work on the same POD template), also tied to question https://answers.launchpad.net/appy/+question/149443.
This commit is contained in:
parent
b9e07f8c1c
commit
7f02ee3914
3 changed files with 24 additions and 15 deletions
|
@ -3,16 +3,27 @@ import sys, ldap
|
|||
|
||||
# ------------------------------------------------------------------------------
|
||||
class LdapTester:
|
||||
'''Usage: python checkldap.py ldapUri login password base.'''
|
||||
'''Usage: python checkldap.py ldapUri login password base attrs filter
|
||||
|
||||
ldapUri is, for example, "ldap://127.0.0.1:389"
|
||||
login is the login user DN, ie: "cn=gdy,o=geezteem"
|
||||
password is the password for this login
|
||||
base is the base DN where to perform the search, ie "ou=hr,o=GeezTeem"
|
||||
attrs is a comma-separated list of attrs we will retrieve in the LDAP,
|
||||
ie "uid,login"
|
||||
filter is the query filter, ie "(&(attr1=Geez*)(status=OK))"
|
||||
'''
|
||||
def __init__(self):
|
||||
# Get params from shell args.
|
||||
if len(sys.argv) != 5:
|
||||
if len(sys.argv) != 7:
|
||||
print LdapTester.__doc__
|
||||
sys.exit(0)
|
||||
self.uri, self.login, self.password, self.base = sys.argv[1:]
|
||||
s = self
|
||||
s.uri, s.login, s.password, s.base, s.attrs, s.filter = sys.argv[1:]
|
||||
self.attrs = self.attrs.split(',')
|
||||
self.tentatives = 5
|
||||
self.timeout = 5
|
||||
self.attrList = ['uid']
|
||||
self.attrList = ['cfwbV2cn', 'logindisabled']
|
||||
self.ssl = False
|
||||
|
||||
def test(self):
|
||||
|
@ -28,9 +39,9 @@ class LdapTester:
|
|||
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
|
||||
self.base, ldap.SCOPE_ONELEVEL, filterstr=self.filter,
|
||||
attrlist=self.attrs, timeout=5)
|
||||
print 'Got %d entries' % len(res)
|
||||
break
|
||||
except ldap.TIMEOUT:
|
||||
print 'Got timeout.'
|
||||
|
@ -40,4 +51,5 @@ class LdapTester:
|
|||
# ------------------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
LdapTester().test()
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue