Commit 456df757 authored by Lorenz Steinert's avatar Lorenz Steinert

fix ldap search

fixes #5
parent 9beba436
...@@ -92,8 +92,8 @@ class FsrLdap: ...@@ -92,8 +92,8 @@ class FsrLdap:
""" """
logging.info("Fetching Protokollant from LDAP ...") logging.info("Fetching Protokollant from LDAP ...")
try: try:
fil = "(uid="+current_user()+")" fil = "(objectClass=posixAccount)"
if self.conn.search('ou=people,' + self.base, fil, if self.conn.search('uid=' + current_user() + ',ou=people,' + self.base, fil, # noqa: E501
attributes=['displayName']): attributes=['displayName']):
logging.info("Done") logging.info("Done")
return " ".join(str(self.conn.entries[0]['displayName']).split(", ")[::-1]) # noqa: E501 return " ".join(str(self.conn.entries[0]['displayName']).split(", ")[::-1]) # noqa: E501
...@@ -157,10 +157,9 @@ class FsrLdap: ...@@ -157,10 +157,9 @@ class FsrLdap:
fil = '(cn=intern)' fil = '(cn=intern)'
fsr = [] fsr = []
if self.conn.search('ou=group,'+self.base, fil, if self.conn.search('ou=group,'+self.base, fil,
attributes=['memberUid']): attributes=['member']):
for i in self.conn.entries[0]['memberUid']: for i in self.conn.entries[0]['member']:
if self.conn.search('ou=people,' + self.base, if self.conn.search(i, '(objectClass=posixAccount)',
'(uid='+i+')',
attributes=['displayName']): attributes=['displayName']):
fsr += [str(self.conn.entries[0]['displayName'])] fsr += [str(self.conn.entries[0]['displayName'])]
fsr.sort() fsr.sort()
...@@ -232,10 +231,9 @@ class FsrLdap: ...@@ -232,10 +231,9 @@ class FsrLdap:
fil = '(cn=extern)' fil = '(cn=extern)'
fsr_extern = [] fsr_extern = []
if self.conn.search('ou=group,'+self.base, fil, if self.conn.search('ou=group,'+self.base, fil,
attributes=['memberUid']): attributes=['member']):
for i in self.conn.entries[0]['memberUid']: for i in self.conn.entries[0]['member']:
if self.conn.search('ou=people,' + self.base, if self.conn.search(i, '(objectClass=posixAccount)',
'(uid='+i+')',
attributes=['displayName']): attributes=['displayName']):
fsr_extern += [str(self.conn.entries[0]['displayName'])] # noqa: E501 fsr_extern += [str(self.conn.entries[0]['displayName'])] # noqa: E501
fsr_extern.sort() fsr_extern.sort()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment