mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Support attributes with multiple names in LDAPEntry.
This commit is contained in:
committed by
Martin Kosek
parent
f17aa00ff0
commit
3aa39547df
@@ -412,7 +412,6 @@ class host_add(LDAPCreate):
|
|||||||
util.validate_host_dns(self.log, keys[-1])
|
util.validate_host_dns(self.log, keys[-1])
|
||||||
if 'locality' in entry_attrs:
|
if 'locality' in entry_attrs:
|
||||||
entry_attrs['l'] = entry_attrs['locality']
|
entry_attrs['l'] = entry_attrs['locality']
|
||||||
del entry_attrs['locality']
|
|
||||||
entry_attrs['cn'] = keys[-1]
|
entry_attrs['cn'] = keys[-1]
|
||||||
entry_attrs['serverhostname'] = keys[-1].split('.', 1)[0]
|
entry_attrs['serverhostname'] = keys[-1].split('.', 1)[0]
|
||||||
if 'userpassword' not in entry_attrs and not options.get('random', False):
|
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'))
|
raise errors.ACIError(info=_('cn is immutable'))
|
||||||
if 'locality' in entry_attrs:
|
if 'locality' in entry_attrs:
|
||||||
entry_attrs['l'] = entry_attrs['locality']
|
entry_attrs['l'] = entry_attrs['locality']
|
||||||
del entry_attrs['locality']
|
|
||||||
if 'krbprincipalname' in entry_attrs:
|
if 'krbprincipalname' in entry_attrs:
|
||||||
(dn, entry_attrs_old) = ldap.get_entry(
|
(dn, entry_attrs_old) = ldap.get_entry(
|
||||||
dn, ['objectclass', 'krbprincipalname']
|
dn, ['objectclass', 'krbprincipalname']
|
||||||
|
|||||||
@@ -708,6 +708,18 @@ class LDAPEntry(dict):
|
|||||||
else:
|
else:
|
||||||
self._names[name] = name
|
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)
|
super(LDAPEntry, self).__setitem__(name, value)
|
||||||
|
|
||||||
def setdefault(self, name, default):
|
def setdefault(self, name, default):
|
||||||
|
|||||||
@@ -165,17 +165,21 @@ class test_ldap(object):
|
|||||||
assert u'cn' in e.keys()
|
assert u'cn' in e.keys()
|
||||||
assert 'CN' in e
|
assert 'CN' in e
|
||||||
assert 'CN' not in e.keys()
|
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 cn1
|
||||||
assert e['CN'] is e[u'cn']
|
assert e['CN'] is e[u'cn']
|
||||||
|
|
||||||
e.dn = dn2
|
e.dn = dn2
|
||||||
assert e.dn is dn2
|
assert e.dn is dn2
|
||||||
|
|
||||||
e['CN'] = cn2
|
e['commonName'] = cn2
|
||||||
assert u'cn' in e
|
assert u'cn' in e
|
||||||
assert u'cn' not in e.keys()
|
assert u'cn' not in e.keys()
|
||||||
assert 'CN' in e
|
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 cn2
|
||||||
assert e['CN'] is e[u'cn']
|
assert e['CN'] is e[u'cn']
|
||||||
|
|
||||||
@@ -184,3 +188,5 @@ class test_ldap(object):
|
|||||||
assert 'CN' not in e.keys()
|
assert 'CN' not in e.keys()
|
||||||
assert u'cn' not in e
|
assert u'cn' not in e
|
||||||
assert u'cn' not in e.keys()
|
assert u'cn' not in e.keys()
|
||||||
|
assert 'commonName' not in e
|
||||||
|
assert 'commonName' not in e.keys()
|
||||||
|
|||||||
Reference in New Issue
Block a user