diff options
author | Rob Crittenden <rcritten@redhat.com> | 2009-01-16 10:20:23 -0500 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2009-01-19 10:40:11 -0500 |
commit | e4b9be209ef6349966cf1aeaff0f2438cee2e9a9 (patch) | |
tree | 6e92af2f15ee63fd5cad648709e6f6d8ea3bb985 /ipaserver/plugins/b_ldap.py | |
parent | 8154131ce1975c9e2109e408a0a25631ea797a8c (diff) | |
download | freeipa.git-e4b9be209ef6349966cf1aeaff0f2438cee2e9a9.tar.gz freeipa.git-e4b9be209ef6349966cf1aeaff0f2438cee2e9a9.tar.xz freeipa.git-e4b9be209ef6349966cf1aeaff0f2438cee2e9a9.zip |
Make the membership attribute an argument and add new method entry.delAttr()
We need a way to say "this attribute is blank, delete it." delAttr does this.
There are now several attributes to which we add "members" to so make the
attribute for storing members configurable, defaulting to 'member'
Diffstat (limited to 'ipaserver/plugins/b_ldap.py')
-rw-r--r-- | ipaserver/plugins/b_ldap.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/ipaserver/plugins/b_ldap.py b/ipaserver/plugins/b_ldap.py index 2d6ad625..9e06ce51 100644 --- a/ipaserver/plugins/b_ldap.py +++ b/ipaserver/plugins/b_ldap.py @@ -190,23 +190,23 @@ class ldap(CrudBackend): def modify_password(self, dn, **kw): return servercore.modify_password(dn, kw.get('oldpass'), kw.get('newpass')) - def add_member_to_group(self, memberdn, groupdn): + def add_member_to_group(self, memberdn, groupdn, memberattr='member'): """ Add a new member to a group. :param memberdn: the DN of the member to add :param groupdn: the DN of the group to add a member to """ - return servercore.add_member_to_group(memberdn, groupdn) + return servercore.add_member_to_group(memberdn, groupdn, memberattr) - def remove_member_from_group(self, memberdn, groupdn): + def remove_member_from_group(self, memberdn, groupdn, memberattr='member'): """ Remove a new member from a group. :param memberdn: the DN of the member to remove :param groupdn: the DN of the group to remove a member from """ - return servercore.remove_member_from_group(memberdn, groupdn) + return servercore.remove_member_from_group(memberdn, groupdn, memberattr) # The CRUD operations @@ -227,6 +227,7 @@ class ldap(CrudBackend): else: assert type(value) in (str, unicode, bool, int, float) yield (key, value) + yield (key, value) def create(self, **kw): if servercore.entry_exists(kw['dn']): @@ -251,13 +252,18 @@ class ldap(CrudBackend): def update(self, dn, **kw): result = self.retrieve(dn, ["*"]) + start_keys = kw.keys() entry = ipaldap.Entry((dn, servercore.convert_scalar_values(result))) kw = dict(self.strip_none(kw)) for k in kw: entry.setValues(k, kw[k]) - servercore.update_entry(entry.toDict()) + remove_keys = list(set(start_keys) - set(kw.keys())) + for k in remove_keys: + entry.delAttr(k) + + servercore.update_entry(entry.toDict(), remove_keys) return self.retrieve(dn) |