Revision 35b342c1
Added by Marc Dequènes over 14 years ago
- ID 35b342c16e599b0eb59e3fcc2944a923334676b3
lib/ldap_shadows/manipulation_helper.rb | ||
---|---|---|
ldap_search_objects = "(objectClass=*)"
|
||
ldap_search_aspects = ""
|
||
ldap_search_fields = []
|
||
ldap_search_where = []
|
||
ldap_search_exclude = []
|
||
str_list.each do |str|
|
||
unless str =~ /^([a-zA-Z]*(?::[a-zA-Z]+)?)(=|~=)(.*)$/
|
||
raise SyntaxError, _("search parameter '%s' is invalid") % str
|
||
... | ... | |
ldap_search_objects = ldap_search_string_objects(shadow, field, op, val)
|
||
when 'aspects'
|
||
ldap_search_aspects = ldap_search_string_aspects(shadow, field, op, val)
|
||
when 'parents'
|
||
val.split(",").each do |parent_fh|
|
||
parent = find_item_by_full_handle(shadow, parent_fh)
|
||
ldap_search_where << [parent.dn.to_s, :one]
|
||
end
|
||
when 'siblings'
|
||
val.split(",").each do |sibling_fh|
|
||
sibling = find_item_by_full_handle(shadow, sibling_fh)
|
||
ldap_search_where << [sibling.family_parent_dn.to_s, :one]
|
||
ldap_search_exclude << sibling.dn.to_s
|
||
end
|
||
when 'children'
|
||
val.split(",").each do |child_fh|
|
||
child = find_item_by_full_handle(shadow, child_fh)
|
||
ldap_search_where << [child.family_parent_dn.to_s, :base]
|
||
end
|
||
when 'ancestors'
|
||
val.split(",").each do |parent_fh|
|
||
parent = find_item_by_full_handle(shadow, parent_fh)
|
||
ldap_search_where << [parent.dn.to_s, :sub]
|
||
ldap_search_exclude << parent.dn.to_s
|
||
end
|
||
when 'successors'
|
||
val.split(",").each do |child_fh|
|
||
child = find_item_by_full_handle(shadow, child_fh)
|
||
dn = child.dn_obj.dup
|
||
while dn.to_s != ActiveLdap::Base.base.to_s
|
||
dn.shift
|
||
ldap_search_where << [dn.to_s, :base]
|
||
end
|
||
end
|
||
else
|
||
raise PreProcessingError, _("Unknown core field '%s'") % field
|
||
end
|
||
... | ... | |
end
|
||
ldap_search_string = "(&" + ldap_search_objects + ldap_search_aspects + ldap_search_fields.join + ")"
|
||
|
||
ActiveLdap::Base.find(:all, :scope => :sub, :filter => ldap_search_string, :attributes => ["objectClass"])
|
||
if ldap_search_where.empty?
|
||
ldap_search_where << [ActiveLdap::Base.base.to_s, :sub]
|
||
end
|
||
res = []
|
||
ldap_search_where.each do |where|
|
||
res += ActiveLdap::Base.find(:all, :base => where[0], :scope => where[1], :filter => ldap_search_string, :attributes => ["objectClass"])
|
||
end
|
||
|
||
res.uniq.select {|item| not ldap_search_exclude.include?(item.dn.to_s) }
|
||
end
|
||
|
||
def self.find_raw_item_object(shadow, raw_item)
|
Also available in: Unified diff
[evol] search can use family relationship as criterias