Commit ec9b1071 authored by Recteur LP's avatar Recteur LP

fix python 2

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