mirror of
https://github.com/kakwa/ldapcherry
synced 2025-07-01 19:18:10 +02:00
Merge 7c5aa5b3b5a6238b4f5ba4a1ba53c43d622d4e2c into 00a4d22dd9c902d4a5794c26f9b22e29b69729f8
This commit is contained in:
commit
9425f26396
@ -327,6 +327,19 @@ class Backend(ldapcherry.backend.Backend):
|
||||
return None
|
||||
return s.decode('utf-8', 'ignore')
|
||||
|
||||
def _extract_content(self, args, formatting):
|
||||
match_object = re.search('\((.+)\)', formatting)
|
||||
|
||||
if not match_object:
|
||||
raise Exception
|
||||
|
||||
arg_key = match_object.group(1)
|
||||
|
||||
if isinstance(args[arg_key], list):
|
||||
return args[arg_key][0]
|
||||
else:
|
||||
return args[arg_key]
|
||||
|
||||
def auth(self, username, password):
|
||||
"""Authentication of a user"""
|
||||
|
||||
@ -452,7 +465,7 @@ class Backend(ldapcherry.backend.Backend):
|
||||
# iterate on group membership attributes
|
||||
for attr in self.group_attrs:
|
||||
# fill the content template
|
||||
content = self._str(self.group_attrs[attr] % attrs)
|
||||
content = self._str(self._extract_content(attrs, self.group_attrs[attr]))
|
||||
self._logger(
|
||||
severity=logging.DEBUG,
|
||||
msg="%(backend)s: adding user '%(user)s'"
|
||||
@ -505,7 +518,7 @@ class Backend(ldapcherry.backend.Backend):
|
||||
for group in groups:
|
||||
group = self._str(group)
|
||||
for attr in self.group_attrs:
|
||||
content = self._str(self.group_attrs[attr] % attrs)
|
||||
content = self._str(self._extract_content(attrs, self.group_attrs[attr]))
|
||||
ldif = [(ldap.MOD_DELETE, attr, content)]
|
||||
try:
|
||||
ldap_client.modify_s(group, ldif)
|
||||
|
Loading…
x
Reference in New Issue
Block a user