diff options
author | Jan Cholasta <jcholast@redhat.com> | 2013-01-31 11:57:02 +0100 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2013-03-01 16:59:47 +0100 |
commit | 3aa39547df18bc77ba49720f8a3a1a0052907859 (patch) | |
tree | a067e432ecc35f483afbd0b946c89a55345db294 | |
parent | f17aa00ff01e3fff35d3b3ac75f001d076827ec8 (diff) | |
download | freeipa-3aa39547df18bc77ba49720f8a3a1a0052907859.tar.gz freeipa-3aa39547df18bc77ba49720f8a3a1a0052907859.tar.xz freeipa-3aa39547df18bc77ba49720f8a3a1a0052907859.zip |
Support attributes with multiple names in LDAPEntry.
-rw-r--r-- | ipalib/plugins/host.py | 2 | ||||
-rw-r--r-- | ipaserver/ipaldap.py | 12 | ||||
-rw-r--r-- | tests/test_ipaserver/test_ldap.py | 10 |
3 files changed, 20 insertions, 4 deletions
diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index f464127d9..affc3d77c 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -412,7 +412,6 @@ class host_add(LDAPCreate): util.validate_host_dns(self.log, keys[-1]) if 'locality' in entry_attrs: entry_attrs['l'] = entry_attrs['locality'] - del entry_attrs['locality'] entry_attrs['cn'] = keys[-1] entry_attrs['serverhostname'] = keys[-1].split('.', 1)[0] if 'userpassword' not in entry_attrs and not options.get('random', False): @@ -635,7 +634,6 @@ class host_mod(LDAPUpdate): raise errors.ACIError(info=_('cn is immutable')) if 'locality' in entry_attrs: entry_attrs['l'] = entry_attrs['locality'] - del entry_attrs['locality'] if 'krbprincipalname' in entry_attrs: (dn, entry_attrs_old) = ldap.get_entry( dn, ['objectclass', 'krbprincipalname'] diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py index 9cff10169..10deca787 100644 --- a/ipaserver/ipaldap.py +++ b/ipaserver/ipaldap.py @@ -708,6 +708,18 @@ class LDAPEntry(dict): else: self._names[name] = name + try: + schema = self._conn.schema + except: + pass + else: + attrtype = schema.get_obj(ldap.schema.AttributeType, + name.encode('utf-8')) + if attrtype is not None: + for altname in attrtype.names: + altname = altname.decode('utf-8') + self._names[altname] = name + super(LDAPEntry, self).__setitem__(name, value) def setdefault(self, name, default): diff --git a/tests/test_ipaserver/test_ldap.py b/tests/test_ipaserver/test_ldap.py index 7e5ba3906..a35f7830d 100644 --- a/tests/test_ipaserver/test_ldap.py +++ b/tests/test_ipaserver/test_ldap.py @@ -165,17 +165,21 @@ class test_ldap(object): assert u'cn' in e.keys() assert 'CN' in e assert 'CN' not in e.keys() + assert 'commonName' in e + assert 'commonName' not in e.keys() assert e['CN'] is cn1 assert e['CN'] is e[u'cn'] e.dn = dn2 assert e.dn is dn2 - e['CN'] = cn2 + e['commonName'] = cn2 assert u'cn' in e assert u'cn' not in e.keys() assert 'CN' in e - assert 'CN' in e.keys() + assert 'CN' not in e.keys() + assert 'commonName' in e + assert 'commonName' in e.keys() assert e['CN'] is cn2 assert e['CN'] is e[u'cn'] @@ -184,3 +188,5 @@ class test_ldap(object): assert 'CN' not in e.keys() assert u'cn' not in e assert u'cn' not in e.keys() + assert 'commonName' not in e + assert 'commonName' not in e.keys() |