Use the search fields from the configuration when searching

Generalize the attribute -> objectclass search helper
This commit is contained in:
Rob Crittenden
2008-10-16 15:00:30 -04:00
parent 5748fce84c
commit f777f72de6
4 changed files with 51 additions and 19 deletions

View File

@@ -155,9 +155,20 @@ api.register(group_mod)
class group_find(crud.Find):
'Search the groups.'
def execute(self, cn, **kw):
def execute(self, term, **kw):
ldap = self.api.Backend.ldap
kw['cn'] = cn
# Pull the list of searchable attributes out of the configuration.
config = ldap.get_ipa_config()
search_fields_conf_str = config.get('ipagroupsearchfields')
search_fields = search_fields_conf_str.split(",")
for s in search_fields:
kw[s] = term
object_type = ldap.get_object_type("cn")
if object_type and not kw.get('objectclass'):
kw['objectclass'] = ldap.get_object_type("cn")
return ldap.search(**kw)
def output_for_cli(self, groups):