Revision 020c18fe
Added by Marc Dequènes over 14 years ago
- ID 020c18fef17a781c2687cf73c9fcf02865432fb0
lib/ldap_shadows/manipulation_helper.rb | ||
---|---|---|
end
|
||
end
|
||
|
||
def self.looks_like_full_handle?(full_handle)
|
||
full_handle =~ LdapShadows::Elements::LdapObject::FULL_HANDLE_PATTERN
|
||
res = $~
|
||
res = res.to_a if res
|
||
res
|
||
end
|
||
|
||
def self.find_item_by_full_handle(shadow, full_handle)
|
||
if full_handle == "root"
|
||
raw_item_dn = ActiveLdap::Base.base.to_s
|
||
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?
|
||
raise PreProcessingError, _("No such item 'root'")
|
||
elsif info[:object].nil?
|
||
raise PreProcessingError, _("Root item found, but no corresponding object defined")
|
||
else
|
||
full_handle = info[:full_handle]
|
||
end
|
||
end
|
||
|
||
m = looks_like_full_handle?(full_handle)
|
||
raise SyntaxError, _("Bad handle '%s'") % full_handle unless m
|
||
obj_hdl = m[1].downcase.singularize
|
||
item_hdl = m[2]
|
||
|
||
obj_klass = shadow.get_object(obj_hdl)
|
||
raise PreProcessingError, _("No such object '%s'") % obj_hdl if obj_klass.nil?
|
||
|
||
begin
|
||
obj_klass.find(item_hdl, :attributes => [""])
|
||
rescue ActiveLdap::EntryNotFound
|
||
raise PreProcessingError, _("No such item '%s/%s'") % [obj_klass.handle, item_hdl]
|
||
end
|
||
end
|
||
|
||
protected
|
||
|
||
def self.ldap_search_string_field(field, op, val)
|
Also available in: Unified diff
[fix/cleanup] handle the 'root' element better (even if ActiveLdap seems not to behave properly with the root DSA)