mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Change signature of LDAPSearch.pre_callback.
Add the opportunity to change base DN and scope in the callback.
This commit is contained in:
@@ -1149,19 +1149,20 @@ class LDAPSearch(CallbackInterface, crud.Search):
|
||||
(term_filter, attr_filter), rules=ldap.MATCH_ALL
|
||||
)
|
||||
|
||||
scope = ldap.SCOPE_ONELEVEL
|
||||
for callback in self.PRE_CALLBACKS:
|
||||
if hasattr(callback, 'im_self'):
|
||||
filter = callback(
|
||||
ldap, filter, attrs_list, base_dn, *args, **options
|
||||
)
|
||||
(filter, base_dn, scope) = callback(
|
||||
ldap, filter, attrs_list, base_dn, scope, *args, **options
|
||||
)
|
||||
else:
|
||||
filter = callback(
|
||||
self, ldap, filter, attrs_list, base_dn, *args, **options
|
||||
(filter, base_dn, scope) = callback(
|
||||
self, ldap, filter, attrs_list, base_dn, scope, *args, **options
|
||||
)
|
||||
|
||||
try:
|
||||
(entries, truncated) = ldap.find_entries(
|
||||
filter, attrs_list, base_dn, scope=ldap.SCOPE_ONELEVEL,
|
||||
filter, attrs_list, base_dn, scope,
|
||||
time_limit=options.get('timelimit', None),
|
||||
size_limit=options.get('sizelimit', None)
|
||||
)
|
||||
@@ -1169,7 +1170,7 @@ class LDAPSearch(CallbackInterface, crud.Search):
|
||||
try:
|
||||
(entries, truncated) = self._call_exc_callbacks(
|
||||
args, options, e, ldap.find_entries, filter, attrs_list,
|
||||
base_dn, scoope=ldap.SCOPE_ONELEVEL,
|
||||
base_dn, scope=ldap.SCOPE_ONELEVEL,
|
||||
normalize=self.obj.normalize_dn
|
||||
)
|
||||
except errors.NotFound:
|
||||
@@ -1195,8 +1196,8 @@ class LDAPSearch(CallbackInterface, crud.Search):
|
||||
truncated=truncated,
|
||||
)
|
||||
|
||||
def pre_callback(self, ldap, filter, attrs_list, base_dn, *args, **options):
|
||||
return filter
|
||||
def pre_callback(self, ldap, filter, attrs_list, base_dn, scope, *args, **options):
|
||||
return (filter, base_dn, scope)
|
||||
|
||||
def post_callback(self, ldap, entries, truncated, *args, **options):
|
||||
pass
|
||||
|
@@ -223,7 +223,7 @@ class group_find(LDAPSearch):
|
||||
),
|
||||
)
|
||||
|
||||
def pre_callback(self, ldap, filter, attrs_list, base_dn, *args, **options):
|
||||
def pre_callback(self, ldap, filter, attrs_list, base_dn, scope, *args, **options):
|
||||
# if looking for private groups, we need to create a new search filter,
|
||||
# because private groups have different object classes
|
||||
if options['private']:
|
||||
@@ -243,7 +243,7 @@ class group_find(LDAPSearch):
|
||||
cflt = ldap.make_filter(search_kw, exact=False)
|
||||
|
||||
filter = ldap.combine_filters((oflt, cflt), rules=ldap.MATCH_ALL)
|
||||
return filter
|
||||
return (filter, base_dn, scope)
|
||||
|
||||
api.register(group_find)
|
||||
|
||||
|
@@ -556,11 +556,11 @@ class host_find(LDAPSearch):
|
||||
)
|
||||
member_attributes = ['managedby']
|
||||
|
||||
def pre_callback(self, ldap, filter, attrs_list, base_dn, *args, **options):
|
||||
def pre_callback(self, ldap, filter, attrs_list, base_dn, scope, *args, **options):
|
||||
if 'locality' in attrs_list:
|
||||
attrs_list.remove('locality')
|
||||
attrs_list.append('l')
|
||||
return filter.replace('locality', 'l')
|
||||
return (filter.replace('locality', 'l'), base_dn, scope)
|
||||
|
||||
def post_callback(self, ldap, entries, truncated, *args, **options):
|
||||
for entry in entries:
|
||||
|
@@ -109,6 +109,16 @@ class plugins(LocalOrRemote):
|
||||
'%(count)d plugin loaded', '%(count)d plugins loaded'
|
||||
)
|
||||
|
||||
takes_options = LocalOrRemote.takes_options + (
|
||||
Flag('all',
|
||||
cli_name='all',
|
||||
doc=_('retrieve and print all attributes from the server. Affects command output.'),
|
||||
exclude='webui',
|
||||
flags=['no_output'],
|
||||
default=True,
|
||||
),
|
||||
)
|
||||
|
||||
has_output = (
|
||||
Output('result', dict, 'Dictionary mapping plugin names to bases'),
|
||||
Output('count',
|
||||
|
@@ -377,7 +377,7 @@ class service_find(LDAPSearch):
|
||||
member_attributes = ['managedby']
|
||||
takes_options = LDAPSearch.takes_options
|
||||
has_output_params = LDAPSearch.has_output_params + output_params
|
||||
def pre_callback(self, ldap, filter, attrs_list, base_dn, *args, **options):
|
||||
def pre_callback(self, ldap, filter, attrs_list, base_dn, scope, *args, **options):
|
||||
# lisp style!
|
||||
custom_filter = '(&(objectclass=ipaService)' \
|
||||
'(!(objectClass=posixAccount))' \
|
||||
@@ -386,8 +386,9 @@ class service_find(LDAPSearch):
|
||||
'(krbprincipalname=krbtgt/*))' \
|
||||
')' \
|
||||
')'
|
||||
return ldap.combine_filters(
|
||||
(custom_filter, filter), rules=ldap.MATCH_ALL
|
||||
return (
|
||||
ldap.combine_filters((custom_filter, filter), rules=ldap.MATCH_ALL),
|
||||
base_dn, scope
|
||||
)
|
||||
|
||||
def post_callback(self, ldap, entries, truncated, *args, **options):
|
||||
|
@@ -251,11 +251,11 @@ class user_find(LDAPSearch):
|
||||
doc=_('Display user record for current Kerberos principal'),
|
||||
),
|
||||
)
|
||||
def pre_callback(self, ldap, filter, entry_attrs, attrs_list, *keys, **options):
|
||||
def pre_callback(self, ldap, filter, attrs_list, base_dn, scope, *keys, **options):
|
||||
if options.get('whoami'):
|
||||
return "(&(objectclass=posixaccount)(krbprincipalname=%s))"%\
|
||||
getattr(context, 'principal')
|
||||
return filter
|
||||
return (filter, base_dn, scope)
|
||||
|
||||
def post_callback(self, ldap, entries, truncated, *args, **options):
|
||||
for entry in entries:
|
||||
|
Reference in New Issue
Block a user