mirror of
https://github.com/kakwa/ldapcherry
synced 2025-02-16 15:43:19 +01:00
fix add/del groups
This commit is contained in:
parent
60a7329937
commit
0d766d3303
@ -255,10 +255,14 @@ class Backend(ldapcherry.backend.Backend):
|
|||||||
attrs = tmp[1]
|
attrs = tmp[1]
|
||||||
attrs['dn'] = dn
|
attrs['dn'] = dn
|
||||||
for group in groups:
|
for group in groups:
|
||||||
|
group = self._str(group)
|
||||||
for attr in self.group_attrs:
|
for attr in self.group_attrs:
|
||||||
content = self.group_attrs[attr] % attrs
|
content = self._str(self.group_attrs[attr] % attrs)
|
||||||
ldif = modlist.addModlist({ attr : content })
|
ldif = modlist.modifyModlist({}, { attr : content })
|
||||||
ldap_client.add_s(group,ldif)
|
try:
|
||||||
|
ldap_client.modify_s(group, ldif)
|
||||||
|
except ldap.TYPE_OR_VALUE_EXISTS as e:
|
||||||
|
pass
|
||||||
ldap_client.unbind_s()
|
ldap_client.unbind_s()
|
||||||
|
|
||||||
def del_from_groups(self, username, groups):
|
def del_from_groups(self, username, groups):
|
||||||
@ -268,10 +272,14 @@ class Backend(ldapcherry.backend.Backend):
|
|||||||
attrs = tmp[1]
|
attrs = tmp[1]
|
||||||
attrs['dn'] = dn
|
attrs['dn'] = dn
|
||||||
for group in groups:
|
for group in groups:
|
||||||
|
group = self._str(group)
|
||||||
for attr in self.group_attrs:
|
for attr in self.group_attrs:
|
||||||
content = self.group_attrs[attr] % attrs
|
content = self._str(self.group_attrs[attr] % attrs)
|
||||||
ldif = modlist.addModlist({ attr : content })
|
ldif = [(ldap.MOD_DELETE, attr, content)]
|
||||||
ldap_client.delete_s(group,ldif)
|
try:
|
||||||
|
ldap_client.modify_s(group, ldif)
|
||||||
|
except ldap.NO_SUCH_ATTRIBUTE as e:
|
||||||
|
pass
|
||||||
ldap_client.unbind_s()
|
ldap_client.unbind_s()
|
||||||
|
|
||||||
def search(self, searchstring):
|
def search(self, searchstring):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user