Project

General

Profile

« Previous | Next » 

Revision bf962db8

Added by Marc Dequènes over 14 years ago

  • ID bf962db82376a7e9af7541e52f3fb9cfb6413631

[fix] check parent full_handle/DN in the proper hook, so it is always validated

View differences:

lib/ldap_shadows/elements/object.rb
super(attributes)
@parent_changed = false
@latest_parent_full_handle = nil
end
def handle
......
parent_item = self.class.find_by_full_handle(parent_full_handle)
p_hdl_restr = self.class.parameters[:mapping][:parent_handle_restrictions]
unless p_hdl_restr.nil? or parent_full_handle =~ Regexp.new(p_hdl_restr)
raise PreProcessingError, _("This parent can't raise such a child (handle restrictions)")
end
p_dn_restr = self.class.parameters[:mapping][:parent_dn_restrictions]
unless p_dn_restr.nil? or parent_item.dn =~ Regexp.new(p_dn_restr)
raise PreProcessingError, _("This parent can't raise such a child (DN restrictions)")
end
if self.new_entry?
self.base = parent_item.dn_obj - parent_item.class.base_obj
else
......
end
@parent_changed = true
@latest_parent_full_handle = parent_full_handle
end
def self.find_by_full_handle(full_handle)
......
end
def check_parent
parent_full_handle = nil
parent_item_dn = nil
if self.new_entry? and not self.parent_changed
parent_full_handle = self.class.parameters[:mapping][:default_parent]
if parent_full_handle
......
rescue
raise PreProcessingError, _("Cannot create the item: bad default parent for this kind of object: %s") % $!
end
parent_item_dn = parent_item.dn.to_s
else
raise PreProcessingError, _("Cannot create the item: parent not specified and no default for such object")
end
end
parent_full_handle = @latest_parent_full_handle if parent_full_handle.nil?
parent_item_dn = self.base.to_s if parent_item_dn.nil?
p_hdl_restr = self.class.parameters[:mapping][:parent_handle_restrictions]
unless p_hdl_restr.nil? or parent_full_handle =~ Regexp.new(p_hdl_restr)
raise PreProcessingError, _("This parent can't raise such a child (handle restrictions)")
end
p_dn_restr = self.class.parameters[:mapping][:parent_dn_restrictions]
unless p_dn_restr.nil? or parent_item_dn =~ Regexp.new(p_dn_restr)
raise PreProcessingError, _("This parent can't raise such a child (DN restrictions)")
end
end
def after_save_jobs

Also available in: Unified diff