Project

General

Profile

« Previous | Next » 

Revision 98217996

Added by Marc Dequènes almost 14 years ago

  • ID 9821799643b84c1515f3c342036686bd3a266f73

[evol] switched to a higher activeldap library (closes #27)

View differences:

lib/ldap_shadows/manipulation_helper.rb
def self.items_find_from_strings(shadow, str_list)
ldap_search_objects = "(objectClass=*)"
ldap_search_aspects = ""
ldap_search_fields = []
ldap_search_where = []
ldap_search_exclude = []
ldap_search_fields = Set.new
ldap_search_where =Set.new
ldap_search_exclude =Set.new
str_list.each do |str|
unless str =~ /^([a-zA-Z]*(?::[a-zA-Z]+)?)(=|~=)(.*)$/
raise SyntaxError, _("search parameter '%s' is invalid") % str
......
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]
ldap_search_where << [parent.dn, :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
ldap_search_where << [sibling.family_parent_dn, :one]
ldap_search_exclude << sibling.dn
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]
ldap_search_where << [child.family_parent_dn, :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
ldap_search_where << [parent.dn, :sub]
ldap_search_exclude << parent.dn
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 = child.dn.dup
while dn != ActiveLdap::Base.base
dn.shift
ldap_search_where << [dn.to_s, :base]
ldap_search_where << [dn, :base]
end
end
else
......
raise PreProcessingError, _("Unknown type '%s' for field '%s'") % [type, field]
end
end
ldap_search_string = "(&" + ldap_search_objects + ldap_search_aspects + ldap_search_fields.join + ")"
ldap_search_string = "(&" + ldap_search_objects + ldap_search_aspects + ldap_search_fields.to_a.join + ")"
if ldap_search_where.empty?
ldap_search_where << [ActiveLdap::Base.base.to_s, :sub]
ldap_search_where << [ActiveLdap::Base.base, :sub]
end
res = []
res = Set.new
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) }
return res.select {|item| not ldap_search_exclude.include?(item.dn) }
end
def self.find_raw_item_object(shadow, raw_item)
......
return {:full_handle => item.full_handle, :name => name, :item => item, :object => obj_klass, :is_root => is_root}
end
item_fake_hdl = raw_item.dn
item_fake_hdl = raw_item.dn.to_s
else
item_fake_hdl = dn || "???"
item_fake_hdl = dn.to_s || "???"
end
{:full_handle => nil, :name => "unknown/#{item_fake_hdl}", :is_root => is_root}
......
def self.interpret_field_value(shadow, syntax, val)
case syntax
when "1.3.6.1.4.1.1466.115.121.1.12"
raw_item = ActiveLdap::Base.find(:first, :base => val.to_s, :scope => :base)
raw_item = ActiveLdap::Base.find(:first, :base => val, :scope => :base)
LdapShadows::Manipulation.raw_item_info(shadow, raw_item, val.to_s)[:full_handle]
else
val
......
def self.find_item_by_full_handle(shadow, full_handle, with_admin_fields = false)
if full_handle == "root"
raw_item_dn = ActiveLdap::Base.base.to_s
raw_item_dn = ActiveLdap::Base.base
raw_item = ActiveLdap::Base.find(:first, :base => raw_item_dn, :scope => :base)
info = raw_item_info(shadow, raw_item, raw_item_dn)
if info.nil?

Also available in: Unified diff