mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Remove DN normalization from the baseldap plugin.
This commit is contained in:
committed by
Martin Kosek
parent
a09c50671e
commit
5b2e0e2ba5
@@ -303,8 +303,7 @@ class automember_add_condition(LDAPUpdate):
|
||||
entry_attrs[attr] = [key + condition for condition in options[attr]]
|
||||
completed += len(entry_attrs[attr])
|
||||
try:
|
||||
(dn, old_entry) = ldap.get_entry(
|
||||
dn, [attr], normalize=self.obj.normalize_dn)
|
||||
(dn, old_entry) = ldap.get_entry(dn, [attr])
|
||||
for regex in old_entry.keys():
|
||||
if not isinstance(entry_attrs[regex], (list, tuple)):
|
||||
entry_attrs[regex] = [entry_attrs[regex]]
|
||||
@@ -325,9 +324,7 @@ class automember_add_condition(LDAPUpdate):
|
||||
|
||||
# Make sure to returned the failed results if there is nothing to remove
|
||||
if completed == 0:
|
||||
(dn, entry_attrs) = ldap.get_entry(
|
||||
dn, attrs_list, normalize=self.obj.normalize_dn
|
||||
)
|
||||
(dn, entry_attrs) = ldap.get_entry(dn, attrs_list)
|
||||
raise errors.EmptyModlist
|
||||
return dn
|
||||
|
||||
@@ -390,16 +387,13 @@ class automember_remove_condition(LDAPUpdate):
|
||||
failed = {'failed': {}}
|
||||
|
||||
# Check to see if there are existing exclusive conditions present.
|
||||
(dn, exclude_present) = ldap.get_entry(
|
||||
dn, [EXCLUDE_RE], normalize=self.obj.normalize_dn)
|
||||
(dn, exclude_present) = ldap.get_entry(dn, [EXCLUDE_RE])
|
||||
|
||||
for attr in (INCLUDE_RE, EXCLUDE_RE):
|
||||
failed['failed'][attr] = []
|
||||
if attr in options and options[attr]:
|
||||
entry_attrs[attr] = [key + condition for condition in options[attr]]
|
||||
(dn, entry_attrs_) = ldap.get_entry(
|
||||
dn, [attr], normalize=self.obj.normalize_dn
|
||||
)
|
||||
(dn, entry_attrs_) = ldap.get_entry(dn, [attr])
|
||||
old_entry = entry_attrs_.get(attr, [])
|
||||
for regex in entry_attrs[attr]:
|
||||
if regex in old_entry:
|
||||
@@ -418,9 +412,7 @@ class automember_remove_condition(LDAPUpdate):
|
||||
|
||||
# Make sure to returned the failed results if there is nothing to remove
|
||||
if completed == 0:
|
||||
(dn, entry_attrs) = ldap.get_entry(
|
||||
dn, attrs_list, normalize=self.obj.normalize_dn
|
||||
)
|
||||
(dn, entry_attrs) = ldap.get_entry(dn, attrs_list)
|
||||
raise errors.EmptyModlist
|
||||
return dn
|
||||
|
||||
@@ -550,9 +542,7 @@ class automember_default_group_remove(LDAPUpdate):
|
||||
api.env.basedn)
|
||||
attr = 'automemberdefaultgroup'
|
||||
|
||||
(dn, entry_attrs_) = ldap.get_entry(
|
||||
dn, [attr], normalize=self.obj.normalize_dn
|
||||
)
|
||||
(dn, entry_attrs_) = ldap.get_entry(dn, [attr])
|
||||
|
||||
if attr not in entry_attrs_:
|
||||
raise errors.NotFound(reason=_(u'No default (fallback) group set'))
|
||||
|
||||
@@ -715,9 +715,7 @@ class automountkey(LDAPObject):
|
||||
# First we look with the information given, then try to search for
|
||||
# the right entry.
|
||||
try:
|
||||
(dn, entry_attrs) = ldap.get_entry(
|
||||
dn, ['*'], normalize=self.normalize_dn
|
||||
)
|
||||
(dn, entry_attrs) = ldap.get_entry(dn, ['*'])
|
||||
except errors.NotFound:
|
||||
if kwargs.get('automountinformation', False):
|
||||
sfilter = '(&(automountkey=%s)(automountinformation=%s))' % \
|
||||
|
||||
@@ -424,7 +424,6 @@ class LDAPObject(Object):
|
||||
|
||||
parent_object = ''
|
||||
container_dn = ''
|
||||
normalize_dn = True
|
||||
object_name = _('entry')
|
||||
object_name_plural = _('entries')
|
||||
object_class = []
|
||||
@@ -868,7 +867,7 @@ last, after all sets and adds."""),
|
||||
if needldapattrs:
|
||||
try:
|
||||
(dn, old_entry) = self._exc_wrapper(keys, options, ldap.get_entry)(
|
||||
dn, needldapattrs, normalize=self.obj.normalize_dn
|
||||
dn, needldapattrs
|
||||
)
|
||||
except errors.NotFound:
|
||||
self.obj.handle_not_found(*keys)
|
||||
@@ -1034,7 +1033,7 @@ class LDAPCreate(BaseLDAPCommand, crud.Create):
|
||||
_check_limit_object_class(self.api.Backend.ldap2.schema.attribute_types(self.obj.disallow_object_classes), entry_attrs.keys(), allow_only=False)
|
||||
|
||||
try:
|
||||
self._exc_wrapper(keys, options, ldap.add_entry)(dn, entry_attrs, normalize=self.obj.normalize_dn)
|
||||
self._exc_wrapper(keys, options, ldap.add_entry)(dn, entry_attrs)
|
||||
except errors.NotFound:
|
||||
parent = self.obj.parent_object
|
||||
if parent:
|
||||
@@ -1066,7 +1065,7 @@ class LDAPCreate(BaseLDAPCommand, crud.Create):
|
||||
assert isinstance(dn, DN)
|
||||
else:
|
||||
(dn, entry_attrs) = self._exc_wrapper(keys, options, ldap.get_entry)(
|
||||
dn, attrs_list, normalize=self.obj.normalize_dn
|
||||
dn, attrs_list
|
||||
)
|
||||
assert isinstance(dn, DN)
|
||||
except errors.NotFound:
|
||||
@@ -1190,7 +1189,7 @@ class LDAPRetrieve(LDAPQuery):
|
||||
|
||||
try:
|
||||
(dn, entry_attrs) = self._exc_wrapper(keys, options, ldap.get_entry)(
|
||||
dn, attrs_list, normalize=self.obj.normalize_dn
|
||||
dn, attrs_list
|
||||
)
|
||||
assert isinstance(dn, DN)
|
||||
except errors.NotFound:
|
||||
@@ -1315,7 +1314,7 @@ class LDAPUpdate(LDAPQuery, crud.Update):
|
||||
# mean an error occurred, just that there were no other updates to
|
||||
# perform.
|
||||
assert isinstance(dn, DN)
|
||||
self._exc_wrapper(keys, options, ldap.update_entry)(dn, entry_attrs, normalize=self.obj.normalize_dn)
|
||||
self._exc_wrapper(keys, options, ldap.update_entry)(dn, entry_attrs)
|
||||
except errors.EmptyModlist, e:
|
||||
if not rdnupdate:
|
||||
raise e
|
||||
@@ -1324,7 +1323,7 @@ class LDAPUpdate(LDAPQuery, crud.Update):
|
||||
|
||||
try:
|
||||
(dn, entry_attrs) = self._exc_wrapper(keys, options, ldap.get_entry)(
|
||||
dn, attrs_list, normalize=self.obj.normalize_dn
|
||||
dn, attrs_list
|
||||
)
|
||||
except errors.NotFound:
|
||||
raise errors.MidairCollision(
|
||||
@@ -1395,12 +1394,12 @@ class LDAPDelete(LDAPMultiQuery):
|
||||
for (dn_, entry_attrs) in subentries:
|
||||
delete_subtree(dn_)
|
||||
try:
|
||||
self._exc_wrapper(nkeys, options, ldap.delete_entry)(base_dn, normalize=self.obj.normalize_dn)
|
||||
self._exc_wrapper(nkeys, options, ldap.delete_entry)(base_dn)
|
||||
except errors.NotFound:
|
||||
self.obj.handle_not_found(*nkeys)
|
||||
|
||||
try:
|
||||
self._exc_wrapper(nkeys, options, ldap.delete_entry)(dn, normalize=self.obj.normalize_dn)
|
||||
self._exc_wrapper(nkeys, options, ldap.delete_entry)(dn)
|
||||
except errors.NotFound:
|
||||
self.obj.handle_not_found(*nkeys)
|
||||
except errors.NotAllowedOnNonLeaf:
|
||||
@@ -1554,7 +1553,7 @@ class LDAPAddMember(LDAPModMember):
|
||||
|
||||
try:
|
||||
(dn, entry_attrs) = self._exc_wrapper(keys, options, ldap.get_entry)(
|
||||
dn, attrs_list, normalize=self.obj.normalize_dn
|
||||
dn, attrs_list
|
||||
)
|
||||
except errors.NotFound:
|
||||
self.obj.handle_not_found(*keys)
|
||||
@@ -1655,7 +1654,7 @@ class LDAPRemoveMember(LDAPModMember):
|
||||
|
||||
try:
|
||||
(dn, entry_attrs) = self._exc_wrapper(keys, options, ldap.get_entry)(
|
||||
dn, attrs_list, normalize=self.obj.normalize_dn
|
||||
dn, attrs_list
|
||||
)
|
||||
except errors.NotFound:
|
||||
self.obj.handle_not_found(*keys)
|
||||
|
||||
@@ -2431,9 +2431,7 @@ class dnsrecord_add(LDAPCreate):
|
||||
# We always want to retrieve all DNS record attributes to test for
|
||||
# record type collisions (#2601)
|
||||
try:
|
||||
(dn_, old_entry) = ldap.get_entry(
|
||||
dn, _record_attributes,
|
||||
normalize=self.obj.normalize_dn)
|
||||
(dn_, old_entry) = ldap.get_entry(dn, _record_attributes)
|
||||
except errors.NotFound:
|
||||
pass
|
||||
else:
|
||||
@@ -2527,8 +2525,7 @@ class dnsrecord_mod(LDAPUpdate):
|
||||
# current entry is needed in case of per-dns-record-part updates and
|
||||
# for record type collision check
|
||||
try:
|
||||
(dn_, old_entry) = ldap.get_entry(dn, _record_attributes,
|
||||
normalize=self.obj.normalize_dn)
|
||||
(dn_, old_entry) = ldap.get_entry(dn, _record_attributes)
|
||||
except errors.NotFound:
|
||||
self.obj.handle_not_found(*keys)
|
||||
|
||||
@@ -2563,9 +2560,7 @@ class dnsrecord_mod(LDAPUpdate):
|
||||
keys = keys[:-1] + (rename,)
|
||||
dn = self.obj.get_dn(*keys, **options)
|
||||
ldap = self.obj.backend
|
||||
(dn_, old_entry) = ldap.get_entry(
|
||||
dn, _record_attributes,
|
||||
normalize=self.obj.normalize_dn)
|
||||
(dn_, old_entry) = ldap.get_entry(dn, _record_attributes)
|
||||
|
||||
del_all = True
|
||||
for attr in old_entry.keys():
|
||||
@@ -2680,9 +2675,7 @@ class dnsrecord_del(LDAPUpdate):
|
||||
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
|
||||
assert isinstance(dn, DN)
|
||||
try:
|
||||
(dn_, old_entry) = ldap.get_entry(
|
||||
dn, _record_attributes,
|
||||
normalize=self.obj.normalize_dn)
|
||||
(dn_, old_entry) = ldap.get_entry(dn, _record_attributes)
|
||||
except errors.NotFound:
|
||||
self.obj.handle_not_found(*keys)
|
||||
|
||||
@@ -2957,8 +2950,7 @@ class dnsconfig(LDAPObject):
|
||||
return DN(api.env.container_dns, api.env.basedn)
|
||||
|
||||
def get_dnsconfig(self, ldap):
|
||||
(dn, entry) = ldap.get_entry(self.get_dn(), None,
|
||||
normalize=self.normalize_dn)
|
||||
(dn, entry) = ldap.get_entry(self.get_dn(), None)
|
||||
|
||||
return entry
|
||||
|
||||
|
||||
@@ -633,9 +633,7 @@ class entitle_import(LDAPUpdate):
|
||||
except M2Crypto.X509.X509Error:
|
||||
raise errors.CertificateFormatError(error=_('Not an entitlement certificate'))
|
||||
dn = DN(('ipaentitlementid', entry_attrs['ipaentitlementid']), dn)
|
||||
(dn, current_attrs) = ldap.get_entry(
|
||||
dn, ['*'], normalize=self.obj.normalize_dn
|
||||
)
|
||||
(dn, current_attrs) = ldap.get_entry(dn, ['*'])
|
||||
entry_attrs['usercertificate'] = current_attrs['usercertificate']
|
||||
entry_attrs['usercertificate'].append(newcert)
|
||||
except errors.NotFound:
|
||||
|
||||
@@ -330,9 +330,7 @@ class permission_mod(LDAPUpdate):
|
||||
|
||||
# check if permission is in LDAP
|
||||
try:
|
||||
(dn, attrs) = ldap.get_entry(
|
||||
dn, attrs_list, normalize=self.obj.normalize_dn
|
||||
)
|
||||
(dn, attrs) = ldap.get_entry(dn, attrs_list)
|
||||
except errors.NotFound:
|
||||
self.obj.handle_not_found(*keys)
|
||||
|
||||
@@ -347,7 +345,7 @@ class permission_mod(LDAPUpdate):
|
||||
except (IndexError, KeyError), e:
|
||||
raise ValueError("expected dn starting with 'cn=' but got '%s'" % dn)
|
||||
new_dn[0].value = options['rename']
|
||||
(new_dn, attrs) = ldap.get_entry(new_dn, attrs_list, normalize=self.obj.normalize_dn)
|
||||
(new_dn, attrs) = ldap.get_entry(new_dn, attrs_list)
|
||||
raise errors.DuplicateEntry()
|
||||
except errors.NotFound:
|
||||
pass # permission may be renamed, continue
|
||||
|
||||
@@ -638,9 +638,7 @@ class sudorule_add_option(LDAPQuery):
|
||||
self.obj.handle_not_found(cn)
|
||||
|
||||
attrs_list = self.obj.default_attributes
|
||||
(dn, entry_attrs) = ldap.get_entry(
|
||||
dn, attrs_list, normalize=self.obj.normalize_dn
|
||||
)
|
||||
(dn, entry_attrs) = ldap.get_entry(dn, attrs_list)
|
||||
|
||||
entry_attrs = entry_to_dict(entry_attrs, **options)
|
||||
|
||||
@@ -695,9 +693,7 @@ class sudorule_remove_option(LDAPQuery):
|
||||
self.obj.handle_not_found(cn)
|
||||
|
||||
attrs_list = self.obj.default_attributes
|
||||
(dn, entry_attrs) = ldap.get_entry(
|
||||
dn, attrs_list, normalize=self.obj.normalize_dn
|
||||
)
|
||||
(dn, entry_attrs) = ldap.get_entry(dn, attrs_list)
|
||||
|
||||
entry_attrs = entry_to_dict(entry_attrs, **options)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user