Revision aa4e021c
Added by Marc Dequènes about 15 years ago
- ID aa4e021cfd1249780f42bed7118e8697c06b21c2
TODO | ||
---|---|---|
- ensure removing an aspect also remove reverse-depends
|
||
- replace DNs with recognized objects in show command (if not in debug mode)
|
||
- improve configuration:
|
||
* allow global relations to share them among objects ???
|
||
- select parent at creation with :parent if present, or use
|
bin/shadowwalker | ||
---|---|---|
|
||
result = field_data[file_no]
|
||
result_is_binary = attr_info.binary?
|
||
|
||
unless result_is_binary or $program_options[:debug]
|
||
result = LdapShadows::Manipulation.interpret_field_value($shadow, attr_info.syntax.to_param, result)
|
||
end
|
||
end
|
||
|
||
if args.empty?
|
lib/ldap_shadows/display_helper.rb | ||
---|---|---|
#++
|
||
|
||
require 'active_support'
|
||
require 'ldap_shadows/manipulation_helper'
|
||
|
||
|
||
module LdapShadows
|
||
... | ... | |
end
|
||
|
||
module Display
|
||
def self.display_fields(attr_data, options = {})
|
||
def self.display_fields(shadow, attr_data, options = {})
|
||
attr_data.each_pair do |key, val|
|
||
next if val[:expert] and not options[:expert]
|
||
next if val[:admin] and not options[:admin]
|
||
... | ... | |
if val[:binary] and options[:skip_binary]
|
||
str += " -> #{val[:value].size} file(s) available"
|
||
else
|
||
str += ": " + (val[:multiple] ? val[:value].sort.collect{|v| v.to_s }.join(", ") : val[:value].to_s)
|
||
str += ": " + (val[:multiple] ?
|
||
val[:value].sort.collect{|v| LdapShadows::Manipulation.interpret_field_value(shadow, val[:syntax], v).to_s }.join(", ") :
|
||
LdapShadows::Manipulation.interpret_field_value(shadow, val[:syntax], val[:value]).to_s)
|
||
end
|
||
|
||
puts str
|
||
... | ... | |
else
|
||
obj_info, obj_aspects = item.organized_data
|
||
|
||
display_fields(obj_info, options)
|
||
display_fields(item.class.shadow, obj_info, options)
|
||
|
||
obj_aspects.each_pair do |aspect_name, aspect_data|
|
||
name = Translator.translate_aspect_name(aspect_name)
|
||
name += " [#{aspect_name}]" if options[:handles]
|
||
puts "--- #{name} ---"
|
||
display_fields(aspect_data, options)
|
||
display_fields(item.class.shadow, aspect_data, options)
|
||
end
|
||
|
||
if options[:show_family_members]
|
lib/ldap_shadows/elements/object.rb | ||
---|---|---|
def fetch_attributes_data(attr_list, expert_attributes, admin_attributes)
|
||
attr_data = self.attributes.collect do |key, val|
|
||
if attr_list.include?(key)
|
||
attr_info = ActiveLdap::Base.schema.attribute(key)
|
||
[key, {
|
||
:syntax => attr_info.syntax.to_param,
|
||
:value => val,
|
||
:multiple => (val.is_a?(Array) ? val.size : 1),
|
||
:expert => expert_attributes.include?(key),
|
||
:admin => admin_attributes.include?(key),
|
||
:binary => ActiveLdap::Base.schema.attribute(key).binary?
|
||
:binary => attr_info.binary?
|
||
}]
|
||
else
|
||
nil
|
||
... | ... | |
else
|
||
rel_key = "rel:" + rel
|
||
[rel_key, {
|
||
:syntax => nil,
|
||
:value => value,
|
||
:multiple => multiple,
|
||
:expert => expert_attributes.include?(rel_key),
|
lib/ldap_shadows/manipulation_helper.rb | ||
---|---|---|
nil
|
||
end
|
||
|
||
def self.raw_item_info(shadow, raw_item)
|
||
obj_hdl = self.find_raw_item_object(shadow, raw_item)
|
||
if obj_hdl
|
||
obj_klass = shadow.get_object(obj_hdl)
|
||
item = obj_klass.new(raw_item.dn)
|
||
{:name => item.full_handle, :item => item, :object => obj_klass}
|
||
def self.raw_item_info(shadow, raw_item, dn = nil)
|
||
if raw_item
|
||
obj_hdl = self.find_raw_item_object(shadow, raw_item)
|
||
if obj_hdl
|
||
obj_klass = shadow.get_object(obj_hdl)
|
||
item = obj_klass.new(raw_item.dn)
|
||
return {:name => item.full_handle, :item => item, :object => obj_klass}
|
||
end
|
||
|
||
item_fake_hdl = raw_item.dn
|
||
else
|
||
item_fake_hdl = dn || "???"
|
||
end
|
||
|
||
{:name => "unknown/#{item_fake_hdl}"}
|
||
end
|
||
|
||
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)
|
||
LdapShadows::Manipulation.raw_item_info($shadow, raw_item, val.to_s)[:name]
|
||
else
|
||
{:name => "unknown/#{raw_item.dn}"}
|
||
val
|
||
end
|
||
end
|
||
|
Also available in: Unified diff
[evol] replace DNs with recognized objects in show command (if not in debug mode)