Revision 6089b33a
Added by Marc Dequènes over 15 years ago
- ID 6089b33a753e7b3d548686ab36e99843cfea0283
bin/shadowwalker | ||
---|---|---|
cmd = CmdParse::Command.new('list', false)
|
||
cmd.short_desc = "list objects"
|
||
cmd.set_execution_block do |args|
|
||
if args.size != 1
|
||
if args.size < 1
|
||
STDERR.puts "syntax error: no object name given"
|
||
exit 1
|
||
end
|
||
|
||
obj_hdl = args.shift.singularize
|
||
obj_klass = ldapctl.find_klass(obj_hdl)
|
||
if obj_klass.nil?
|
||
STDERR.puts "No such object '#{obj_hdl}'."
|
||
exit 2
|
||
end
|
||
case obj_hdl
|
||
when ':object'
|
||
puts "=== List of LDAP objects ==="
|
||
ldapctl.objects.each do |obj_name|
|
||
puts " - #{obj_name}"
|
||
end
|
||
when ':aspect'
|
||
if args.empty?
|
||
STDERR.puts "syntax error: no sub-object name given"
|
||
exit 1
|
||
end
|
||
|
||
subobj_hdl = args.shift.singularize
|
||
obj_klass = ldapctl.find_klass(subobj_hdl)
|
||
if obj_klass.nil?
|
||
STDERR.puts "No such object '#{obj_hdl}'."
|
||
exit 2
|
||
end
|
||
|
||
subobj_human_name = Translator.translate_object_name(subobj_hdl)
|
||
puts "=== List of LDAP aspects of #{subobj_human_name.pluralize} ==="
|
||
obj_klass.possible_aspects.each do |subobj_name|
|
||
puts " - #{subobj_name}"
|
||
end
|
||
else
|
||
obj_klass = ldapctl.find_klass(obj_hdl)
|
||
if obj_klass.nil?
|
||
STDERR.puts "No such object '#{obj_hdl}'."
|
||
exit 2
|
||
end
|
||
|
||
obj_human_name = Translator.translate_object_name(obj_hdl)
|
||
Display.display_item_list("List of " + obj_human_name.pluralize, obj_klass.find(:all))
|
||
obj_human_name = Translator.translate_object_name(obj_hdl)
|
||
Display.display_item_list("List of #{obj_human_name.pluralize}", obj_klass.find(:all))
|
||
end
|
||
end
|
||
cmdparser.add_command(cmd)
|
||
|
conf/ldap_shadows/test.conf | ||
---|---|---|
---
|
||
presentation:
|
||
hidden_attributes: ['objectClass', 'userPassword']
|
||
tree_objects: ['ou', 'entity']
|
||
tree_objects: ['unit', 'entity']
|
||
objects:
|
||
bot:
|
||
mapping:
|
||
... | ... | |
object: entity
|
||
foreign_key: founder
|
||
primary_key: dn
|
||
ou:
|
||
unit:
|
||
mapping:
|
||
dn_attribute: ou
|
||
prefix: ''
|
data/ldap_shadows/en.yml | ||
---|---|---|
---
|
||
en:
|
||
objects:
|
||
individual: "Individual"
|
||
bot: "Bot"
|
||
group: "Group"
|
||
domain: "Domain"
|
||
entity: "Entity"
|
||
group: "Group"
|
||
individual: "Individual"
|
||
secondary_account: "Secondary Account"
|
||
systemAccount: "System Account"
|
||
domain: "Domain"
|
||
unit: "Unit"
|
||
attribute_types:
|
||
allowGlobalDirectory: "Disclose Own Contact Information in GLobal Directory"
|
||
cn: "Full Name"
|
||
... | ... | |
foundersIndividuals: "Founder(s) Individual(s)"
|
||
foundersEntities: "Founder(s) Entity(ies)"
|
||
aspects:
|
||
primary: "Primary Account"
|
||
ftp: "FTP Account"
|
||
web: "Web Account"
|
||
shell: "Shell Account"
|
||
fs: "FileSystem Account"
|
||
mail: "eMail Account"
|
||
ftp: "FTP Account"
|
||
jabber: "Jabber Account"
|
||
mail: "eMail Account"
|
||
primary: "Primary Account"
|
||
shell: "Shell Account"
|
||
web: "Web Account"
|
lib/ldap_shadows/controller.rb | ||
---|---|---|
klass.relations_info = obj_relations_info
|
||
end
|
||
end
|
||
|
||
def objects
|
||
@object_definitions.keys.collect{|key| key.to_s }.sort
|
||
end
|
||
end
|
||
|
||
# default location for mapped objects
|
lib/ldap_shadows/object.rb | ||
---|---|---|
rel_list & possible_relations
|
||
end
|
||
|
||
def self.possible_aspects
|
||
return [] unless self.presentation[:allowed_aspects]
|
||
self.presentation[:allowed_aspects].collect{|key| key.to_s }.sort
|
||
end
|
||
|
||
def aspects
|
||
present_aspects = []
|
||
(self.class.presentation[:allowed_aspects] || []).each do |aspect|
|
Also available in: Unified diff
[evol] added list of available objects and aspects of objects, and s/ou/unit/ object