summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2010-12-08 13:26:27 -0500
committerRob Crittenden <rcritten@redhat.com>2010-12-10 13:42:47 -0500
commite8e274c9e0a9fb9d2ef775f99c763d97b23050b1 (patch)
tree74ce17aa1891f94c9d41d7c32e9bb70851964e74 /ipalib
parent1a20d754216bafb82aa40ea584c7de7c9a5b0b07 (diff)
downloadfreeipa-e8e274c9e0a9fb9d2ef775f99c763d97b23050b1.tar.gz
freeipa-e8e274c9e0a9fb9d2ef775f99c763d97b23050b1.tar.xz
freeipa-e8e274c9e0a9fb9d2ef775f99c763d97b23050b1.zip
Properly handle multi-valued attributes when using setattr/addattr.
The problem was that the normalizer was returning each value as a tuple which we were then appending to a list, so it looked like [(u'value1',), (u'value2',),...]. If there was a single value we could end up adding a tuple to a list which would fail. Additionally python-ldap doesn't like lists of lists so it was failing later in the process as well. I've added some simple tests for setattr and addattr. ticket 565
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/frontend.py10
-rw-r--r--ipalib/plugins/baseldap.py2
2 files changed, 9 insertions, 3 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index ac1f67ee1..6be50ba52 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -538,9 +538,15 @@ class Command(HasParam):
if attr in self.params:
value = self.params[attr](value)
if append and attr in newdict:
- newdict[attr].append(value)
+ if type(value) in (tuple,):
+ newdict[attr] += list(value)
+ else:
+ newdict[attr].append(value)
else:
- newdict[attr] = [value]
+ if type(value) in (tuple,):
+ newdict[attr] = list(value)
+ else:
+ newdict[attr] = [value]
return newdict
def __attributes_2_entry(self, kw):
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index 6b7153b51..3299f8015 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -700,7 +700,7 @@ class LDAPUpdate(LDAPQuery, crud.Update):
for a in old_entry:
if not isinstance(entry_attrs[a], (list, tuple)):
entry_attrs[a] = [entry_attrs[a]]
- entry_attrs[a] += old_entry[a]
+ entry_attrs[a] = list(entry_attrs[a]) + old_entry[a]
if options.get('all', False):
attrs_list = ['*'] + self.obj.default_attributes