Revision edb319df
Added by Marc Dequènes over 15 years ago
- ID edb319dfcbf6bda3861f15dd902ecbd3310fd86a
test.rb | ||
---|---|---|
cmdparser.add_command(CmdParse::VersionCommand.new)
|
||
|
||
|
||
module ActiveLdap
|
||
class DistinguishedName
|
||
def shift
|
||
@rdns.shift
|
||
end
|
||
end
|
||
end
|
||
|
||
module LdapMapper
|
||
class LdapObject < ActiveLdap::Base
|
||
class_inheritable_accessor :presentation, :mapper
|
||
|
||
ldap_mapping :prefix => '', :classes => ['top'], :scope => :sub
|
||
|
||
# temporary method until active_ldap is fixed: return a DN object (see #23932)
|
||
def dn_obj
|
||
ActiveLdap::DistinguishedName.parse(self.dn)
|
||
end
|
||
|
||
def name
|
||
name = self[dn_attribute].is_a?(Array) ? self[dn_attribute][0] : self[dn_attribute]
|
||
name.strip
|
||
... | ... | |
[obj_info, obj_aspects]
|
||
end
|
||
|
||
def family_parent_dn
|
||
pdn = self.dn_obj.dup
|
||
pdn.shift
|
||
pdn
|
||
end
|
||
|
||
def family_children
|
||
LdapObject.find(:all, :base => self.dn, :scope => :one)
|
||
end
|
||
|
||
def family_children_dn
|
||
self.family_children.collect {|obj| obj.dn }
|
||
end
|
||
|
||
def family_siblings
|
||
# cannot substract, as the ruby object signature may be different
|
||
LdapObject.find(:all, :base => self.family_parent_dn.to_s, :scope => :one).select{|obj| obj.dn != self.dn }
|
||
end
|
||
|
||
def family_siblings_dn
|
||
self.family_siblings.collect {|obj| obj.dn }
|
||
end
|
||
|
||
protected
|
||
|
||
def fetch_attributes_data(attr_list, options = {})
|
||
... | ... | |
puts "aspects: " + item.aspects.sort.join(", ")
|
||
|
||
puts "--- Family ---"
|
||
puts "children: " + item.children.join(", ")
|
||
puts "parent: " + item.family_parent_dn.to_s
|
||
puts "siblings: " + item.family_siblings_dn.join(", ")
|
||
puts "children: " + item.family_children_dn.join(", ")
|
||
|
||
puts "--- Relations ---"
|
||
item.relations.each do |rel|
|
Also available in: Unified diff
[evol] preliminary family management: display nearby family members'DN in debug mode