From 95d6a0e6a48b746464cf37d456a913feddece2f1 Mon Sep 17 00:00:00 2001 From: kakwa Date: Tue, 28 Jul 2015 20:36:06 +0200 Subject: [PATCH] typo + add/del group in AD backend * implementing add_to_group and del_from_group in AD backend. * fixing typo self.objetclasses => self.objectclasses --- ldapcherry/backend/backendAD.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ldapcherry/backend/backendAD.py b/ldapcherry/backend/backendAD.py index 943494f..d15bb10 100644 --- a/ldapcherry/backend/backendAD.py +++ b/ldapcherry/backend/backendAD.py @@ -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)