mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Remove legacy toDict and origDataDict methods of LDAPEntry.
https://fedorahosted.org/freeipa/ticket/3521
This commit is contained in:
committed by
Martin Kosek
parent
463407ac6f
commit
a7180ed021
@@ -1015,26 +1015,6 @@ class LDAPEntry(collections.MutableMapping):
|
|||||||
|
|
||||||
return name, self.pop(name)
|
return name, self.pop(name)
|
||||||
|
|
||||||
def toDict(self):
|
|
||||||
# FIXME: for backwards compatibility only
|
|
||||||
"""Convert the attrs and values to a dict. The dict is keyed on the
|
|
||||||
attribute name. The value is either single value or a list of values."""
|
|
||||||
assert isinstance(self.dn, DN)
|
|
||||||
result = ipautil.CIDict(self.data)
|
|
||||||
for i in result.keys():
|
|
||||||
result[i] = ipautil.utf8_encode_values(result[i])
|
|
||||||
result['dn'] = self.dn
|
|
||||||
return result
|
|
||||||
|
|
||||||
def origDataDict(self):
|
|
||||||
"""Returns a dict of the original values of the user.
|
|
||||||
|
|
||||||
Used for updates.
|
|
||||||
"""
|
|
||||||
result = ipautil.CIDict(self.orig_data)
|
|
||||||
result['dn'] = self.dn
|
|
||||||
return result
|
|
||||||
|
|
||||||
class LDAPEntryView(collections.MutableMapping):
|
class LDAPEntryView(collections.MutableMapping):
|
||||||
__slots__ = ('_entry',)
|
__slots__ = ('_entry',)
|
||||||
|
|
||||||
@@ -1974,11 +1954,8 @@ class IPAdmin(LDAPClient):
|
|||||||
FORCE_REPLACE_ON_UPDATE_ATTRS = ('nsslapd-ssl-check-hostname', 'nsslapd-lookthroughlimit', 'nsslapd-idlistscanlimit', 'nsslapd-anonlimitsdn', 'nsslapd-minssf-exclude-rootdse')
|
FORCE_REPLACE_ON_UPDATE_ATTRS = ('nsslapd-ssl-check-hostname', 'nsslapd-lookthroughlimit', 'nsslapd-idlistscanlimit', 'nsslapd-anonlimitsdn', 'nsslapd-minssf-exclude-rootdse')
|
||||||
modlist = []
|
modlist = []
|
||||||
|
|
||||||
old_entry = ipautil.CIDict(old_entry)
|
keys = set(old_entry.keys())
|
||||||
new_entry = ipautil.CIDict(new_entry)
|
keys.update(new_entry.keys())
|
||||||
|
|
||||||
keys = set(map(string.lower, old_entry.keys()))
|
|
||||||
keys.update(map(string.lower, new_entry.keys()))
|
|
||||||
|
|
||||||
for key in keys:
|
for key in keys:
|
||||||
new_values = new_entry.get(key, [])
|
new_values = new_entry.get(key, [])
|
||||||
@@ -2007,9 +1984,9 @@ class IPAdmin(LDAPClient):
|
|||||||
|
|
||||||
# You can't remove schema online. An add will automatically
|
# You can't remove schema online. An add will automatically
|
||||||
# replace any existing schema.
|
# replace any existing schema.
|
||||||
if old_entry.get('dn', DN()) == DN(('cn', 'schema')):
|
if old_entry.dn == DN(('cn', 'schema')):
|
||||||
if len(adds) > 0:
|
if len(adds) > 0:
|
||||||
if key == 'attributetypes':
|
if key.lower() == 'attributetypes':
|
||||||
modlist.insert(0, (ldap.MOD_ADD, key, adds))
|
modlist.insert(0, (ldap.MOD_ADD, key, adds))
|
||||||
else:
|
else:
|
||||||
modlist.append((ldap.MOD_ADD, key, adds))
|
modlist.append((ldap.MOD_ADD, key, adds))
|
||||||
|
|||||||
@@ -123,10 +123,10 @@ class KrbInstance(service.Service):
|
|||||||
ipauniqueid=['autogenerate'],
|
ipauniqueid=['autogenerate'],
|
||||||
managedby=[host_dn],
|
managedby=[host_dn],
|
||||||
)
|
)
|
||||||
if 'krbpasswordexpiration' in service_entry.toDict():
|
if 'krbpasswordexpiration' in service_entry:
|
||||||
host_entry['krbpasswordexpiration'] = service_entry[
|
host_entry['krbpasswordexpiration'] = service_entry[
|
||||||
'krbpasswordexpiration']
|
'krbpasswordexpiration']
|
||||||
if 'krbticketflags' in service_entry.toDict():
|
if 'krbticketflags' in service_entry:
|
||||||
host_entry['krbticketflags'] = service_entry['krbticketflags']
|
host_entry['krbticketflags'] = service_entry['krbticketflags']
|
||||||
self.admin_conn.add_entry(host_entry)
|
self.admin_conn.add_entry(host_entry)
|
||||||
|
|
||||||
|
|||||||
@@ -809,11 +809,10 @@ class LDAPUpdate:
|
|||||||
else:
|
else:
|
||||||
# Update LDAP
|
# Update LDAP
|
||||||
try:
|
try:
|
||||||
changes = self.conn.generateModList(entry.origDataDict(), entry.toDict())
|
changes = self.conn.generateModList(entry.orig_data, entry)
|
||||||
if (entry.dn == DN(('cn', 'schema'))):
|
if (entry.dn == DN(('cn', 'schema'))):
|
||||||
d = dict()
|
d = dict()
|
||||||
e = entry.toDict()
|
for k,v in entry.items():
|
||||||
for k,v in e.items():
|
|
||||||
d[k] = [str(x) for x in v]
|
d[k] = [str(x) for x in v]
|
||||||
updated = self.is_schema_updated(d)
|
updated = self.is_schema_updated(d)
|
||||||
else:
|
else:
|
||||||
@@ -825,7 +824,7 @@ class LDAPUpdate:
|
|||||||
self.debug("%s" % safe_changes)
|
self.debug("%s" % safe_changes)
|
||||||
self.debug("Live %d, updated %d" % (self.live_run, updated))
|
self.debug("Live %d, updated %d" % (self.live_run, updated))
|
||||||
if self.live_run and updated:
|
if self.live_run and updated:
|
||||||
self.conn.updateEntry(entry.dn, entry.origDataDict(), entry.toDict())
|
self.conn.updateEntry(entry.dn, entry.orig_data, entry)
|
||||||
self.info("Done")
|
self.info("Done")
|
||||||
except errors.EmptyModlist:
|
except errors.EmptyModlist:
|
||||||
self.info("Entry already up-to-date")
|
self.info("Entry already up-to-date")
|
||||||
|
|||||||
Reference in New Issue
Block a user