Revision b0304d30
Added by Marc Dequènes over 15 years ago
- ID b0304d3003b2a568db3af0e21fa958a3ebdb509e
bin/shadowwalker | ||
---|---|---|
|
||
include LdapShadows
|
||
|
||
|
||
config_str = IO.read(File.join(LdapShadows::Config::CFG_DIR, "test.conf"))
|
||
config = YAML.load(config_str)
|
||
config_str_prv_filelist = [
|
||
... | ... | |
exit 1
|
||
end
|
||
|
||
obj_hdl = args[0].singularize
|
||
obj_hdl = args.shift.singularize
|
||
obj_klass = ldapctl.find_klass(obj_hdl)
|
||
if obj_klass.nil?
|
||
STDERR.puts "No such object '#{obj_hdl}'."
|
||
... | ... | |
exit 1
|
||
end
|
||
|
||
obj_hdl = args[0]
|
||
obj_hdl = args.shift
|
||
obj_klass = ldapctl.find_klass(obj_hdl)
|
||
if obj_klass.nil?
|
||
STDERR.puts "No such object '#{obj_hdl}'."
|
||
exit 2
|
||
end
|
||
|
||
item_hdl = args[1]
|
||
item_hdl = args.shift
|
||
begin
|
||
item = obj_klass.find(item_hdl, :attributes => ["*", "+"])
|
||
rescue ActiveLdap::EntryNotFound
|
||
... | ... | |
end
|
||
cmdparser.add_command(cmd)
|
||
|
||
cmd = CmdParse::Command.new('mod', false)
|
||
cmd.short_desc = "Modify attributes of an object"
|
||
cmd.set_execution_block do |args|
|
||
if args.size < 1
|
||
STDERR.puts "syntax error: no object name given"
|
||
exit 1
|
||
end
|
||
if args.size < 2
|
||
STDERR.puts "syntax error: no item name given"
|
||
exit 1
|
||
end
|
||
|
||
obj_hdl = args.shift
|
||
obj_klass = ldapctl.find_klass(obj_hdl)
|
||
if obj_klass.nil?
|
||
STDERR.puts "No such object '#{obj_hdl}'."
|
||
exit 2
|
||
end
|
||
|
||
item_hdl = args.shift
|
||
begin
|
||
item = obj_klass.find(item_hdl, :attributes => ["*", "+"])
|
||
rescue ActiveLdap::EntryNotFound
|
||
STDERR.puts "No such item '#{obj_hdl}/#{item_hdl}'"
|
||
exit 2
|
||
end
|
||
|
||
puts "COIN"
|
||
p args
|
||
args.each do |mod_info|
|
||
key, val = mod_info.split("=")
|
||
raise "Syntax error in modification parameters" if val.nil?
|
||
|
||
# TODO: manage relations (harder)
|
||
raise "No such field '#{key}' in object '#{obj_hdl}'" unless item.has_attribute?(key)
|
||
|
||
item[key] = val
|
||
end
|
||
p item.valid?
|
||
item.save!
|
||
|
||
Display.display_item(item, $program_options)
|
||
end
|
||
cmdparser.add_command(cmd)
|
||
|
||
cmdparser.parse
|
||
|
Also available in: Unified diff
[evol] first experimental attempt for field modifications (with activeldap workaround for #26720)