Commit ec9b1071 authored by Recteur LP's avatar Recteur LP
Browse files

fix python 2

parent 7d8a2f28
...@@ -78,10 +78,9 @@ class auth(): ...@@ -78,10 +78,9 @@ class auth():
attributes=ALL_ATTRIBUTES, attributes=ALL_ATTRIBUTES,
get_operational_attributes=True get_operational_attributes=True
) )
results = self.connection.response return self.connection.response
else: else:
results = self.ld.search_s(group,ldap.SCOPE_SUBTREE) return self.ld.search_s(group,ldap.SCOPE_SUBTREE)
return results
def getusersfromgroup(self, group): def getusersfromgroup(self, group):
users = [] users = []
...@@ -92,7 +91,8 @@ class auth(): ...@@ -92,7 +91,8 @@ class auth():
users.append({ "name": attrs.get('sAMAccountName', [ 'Guest' ])[0], "uid": attrs.get('uidNumber', [ 'None' ])[0] }) users.append({ "name": attrs.get('sAMAccountName', [ 'Guest' ])[0], "uid": attrs.get('uidNumber', [ 'None' ])[0] })
else: else:
for dn, attrs in self.__getresults(group): for dn, attrs in self.__getresults(group):
users.append({ "name": attrs.get('sAMAccountName', [ 'Guest' ])[0], "uid": attrs.get('uidNumber', [ 'None' ])[0] }) if dn and attrs:
users.append({ "name": attrs.get('sAMAccountName', [ 'Guest' ])[0], "uid": attrs.get('uidNumber', [ 'None' ])[0] })
return users return users
def get(self, name): def get(self, name):
...@@ -145,7 +145,7 @@ class auth(): ...@@ -145,7 +145,7 @@ class auth():
isadmin = False isadmin = False
admins = [] admins = []
for group in self.config['admin']: for group in self.config['admin']:
admins = self.getusersfromgroup("(&(memberOf=" + group + "))") admins = self.getusersfromgroup("memberOf=" + group)
for admin in admins: for admin in admins:
pyrmin.log.debug(admin) pyrmin.log.debug(admin)
if 'name' in admin and name.lower() == admin['name'].lower(): if 'name' in admin and name.lower() == admin['name'].lower():
...@@ -163,4 +163,4 @@ class auth(): ...@@ -163,4 +163,4 @@ class auth():
"company": company, "company": company,
"mail": mail, "mail": mail,
"img": gravatar_url "img": gravatar_url
} }
\ No newline at end of file
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