1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-22 09:24:21 +01:00

typo + add/del group in AD backend

* implementing add_to_group and del_from_group in AD backend.
* fixing typo self.objetclasses => self.objectclasses
This commit is contained in:
kakwa 2015-07-28 20:36:06 +02:00
parent e5d97cf8ff
commit 95d6a0e6a4

View File

@ -104,7 +104,7 @@ class Backend(ldapcherry.backend.backendLdap.Backend):
')'
self.dn_user_attr = 'cn'
self.key = 'sAMAccountName'
self.objectlasses = [
self.objectclasses = [
'top',
'person',
'organizationalPerson',
@ -142,6 +142,23 @@ class Backend(ldapcherry.backend.backendLdap.Backend):
ldap_client.unbind_s()
return r
def _build_groupdn(self, groups):
ad_groups = []
for group in groups:
if group in AD_BUILTIN_GROUPS:
ad_groups.append('cn=' + group + ',' + self.builtin)
else:
ad_groups.append('cn=' + group + ',' +self.groupdn)
return ad_groups
def add_to_groups(self, username, groups):
ad_groups = self._build_groupdn(groups)
super(Backend, self).add_to_groups(username, ad_groups)
def del_from_groups(self, username, groups):
ad_groups = self._build_groupdn(groups)
super(Backend, self).del_from_groups(username, ad_groups)
def get_groups(self, username):
username = ldap.filter.escape_filter_chars(username)
userdn = self._get_user(username, NO_ATTR)