Project

General

Profile

« Previous | Next » 

Revision bbe89518

Added by Marc Dequènes about 15 years ago

  • ID bbe8951879f7c0b7b74df85f94c7de5b712cf78c

[cleanup] internal rework #1

View differences:

bin/shadowwalker
config = LdapShadows::Config.instance
config.load_global_config([File.join(ENV['HOME'], ".shadowwalker")])
begin
$ldapctl = config.load_shadow($program_options[:shadow_name])
$shadow = config.load_shadow($program_options[:shadow_name])
rescue ActiveLdap::Error => e
STDERR.puts _("LDAP connection error: %s") % e.to_s
exit 2
......
raise SyntaxError, _("no object name given") if args.empty?
obj_hdl = args.shift.downcase.singularize
obj_klass = $ldapctl.find_klass(obj_hdl)
obj_klass = $shadow.find_klass(obj_hdl)
raise PreProcessingError, _("No such object '%s'") % obj_hdl if obj_klass.nil?
obj_klass
end
......
obj_hdl = args.shift.downcase.singularize
case obj_hdl
when ':object'
list = $ldapctl.objects
list = $shadow.objects
puts "=== List of LDAP objects (#{list.size}) ==="
list.each do |obj_name|
puts " - #{obj_name}"
......
end
else
dn_list = []
sconfig = $ldapctl.get_shadow_config()
sconfig = $shadow.get_config()
(sconfig[:tree_objects] || []).each do |obj_hdl|
obj_klass = $ldapctl.find_klass(obj_hdl.downcase)
(sconfig[:presentation][:tree_objects] || []).each do |obj_hdl|
obj_klass = $shadow.find_klass(obj_hdl.downcase)
unless obj_klass
raise PreProcessingError, _("Location object '%s' not defined") % obj_hdl
end
......
end
end
base_dn = ActiveLdap::DistinguishedName.parse(LdapObject.base)
base_dn = ActiveLdap::DistinguishedName.parse(Elements::LdapObject.base)
tree = {}
dn_list.each do |dn|
......
raise SyntaxError, _("no search arguments") if args.empty?
res = LdapObject.items_find_from_strings(args)
res = Elements::LdapObject.items_find_from_strings($shadow, args)
unless res.empty?
display_lines = []
res.each do |raw_item|
display_lines << LdapObject.raw_item_info(raw_item)[:name]
display_lines << Elements::LdapObject.raw_item_info($shadow, raw_item)[:name]
end
puts display_lines.join("\n")
end

Also available in: Unified diff