mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-25 08:21:05 -06:00
Add separate var for search attributes and config attribute for search fields
Add an optional search_attributes variable in case the attributes you want to display by default aren't what you want to search on. Also link in any cn=ipaconfig attributes that contain a comma-separated list of attributes to search on.
This commit is contained in:
parent
ccaf537aa6
commit
371a4b2c72
@ -67,6 +67,8 @@ class LDAPObject(Object):
|
||||
object_name_plural = 'entries'
|
||||
object_class = []
|
||||
object_class_config = None
|
||||
search_attributes = []
|
||||
search_attributes_config = None
|
||||
default_attributes = []
|
||||
hidden_attributes = ['objectclass', 'aci']
|
||||
uuid_attribute = ''
|
||||
@ -819,11 +821,23 @@ class LDAPSearch(CallbackInterface, crud.Search):
|
||||
set(self.obj.default_attributes + search_kw.keys())
|
||||
)
|
||||
|
||||
if self.obj.search_attributes:
|
||||
search_attrs = self.obj.search_attributes
|
||||
else:
|
||||
search_attrs = self.obj.default_attributes
|
||||
if self.obj.search_attributes_config:
|
||||
config = ldap.get_ipa_config()[1]
|
||||
config_attrs = config.get(
|
||||
self.obj.search_attributes_config, [])
|
||||
if len(config_attrs) == 1 and (
|
||||
isinstance(config_attrs[0], basestring)):
|
||||
search_attrs = config_attrs[0].split(',')
|
||||
|
||||
search_kw['objectclass'] = self.obj.object_class
|
||||
attr_filter = ldap.make_filter(search_kw, rules=ldap.MATCH_ALL)
|
||||
|
||||
search_kw = {}
|
||||
for a in self.obj.default_attributes:
|
||||
for a in search_attrs:
|
||||
search_kw[a] = term
|
||||
term_filter = ldap.make_filter(search_kw, exact=False)
|
||||
|
||||
|
@ -75,6 +75,7 @@ class group(LDAPObject):
|
||||
object_name_plural = 'groups'
|
||||
object_class = ['ipausergroup']
|
||||
object_class_config = 'ipagroupobjectclasses'
|
||||
search_attributes_config = 'ipagroupsearchfields'
|
||||
default_attributes = [
|
||||
'cn', 'description', 'gidnumber', 'member', 'memberof'
|
||||
]
|
||||
|
@ -58,6 +58,7 @@ class user(LDAPObject):
|
||||
object_name_plural = 'users'
|
||||
object_class = ['posixaccount']
|
||||
object_class_config = 'ipauserobjectclasses'
|
||||
search_attributes_config = 'ipausersearchfields'
|
||||
default_attributes = [
|
||||
'uid', 'givenname', 'sn', 'homedirectory', 'loginshell', 'ou',
|
||||
'telephonenumber', 'title', 'memberof',
|
||||
|
Loading…
Reference in New Issue
Block a user