Project

General

Profile

« Previous | Next » 

Revision 1744c478

Added by Marc Dequènes almost 15 years ago

  • ID 1744c4788df2f00a4ae490d0cba9feaade7bc806

[evol] added private config load in home, and global hidden attributes (until something really proper is done for config)

View differences:

bin/shadowwalker
require 'yaml'
require 'cmdparse2'
config_str_prv = IO.read(File.join(LdapShadows::Config::CFG_DIR, "private.conf"))
config_str = IO.read(File.join(LdapShadows::Config::CFG_DIR, "test.conf"))
config = YAML.load(config_str_prv).merge(YAML.load(config_str)).recursive_symbolize_keys!
config = YAML.load(config_str)
config_str_prv_filelist = [
File.join(ENV['HOME'], ".shadowwalker"),
File.join(LdapShadows::Config::CFG_DIR, "private.conf")
]
config_str_prv_filelist.each do |file|
if File.exists?(file)
config_str_prv = IO.read(file)
config.merge!(YAML.load(config_str_prv))
break
end
end
config.recursive_symbolize_keys!
ActiveLdap::Base.setup_connection(config[:ldap])
cmdparser = CmdParse::CommandParser.new(true)
......
I18n.default_locale = :en
ldapctl = LdapShadows::Controller.new
ldapctl.set_global_config(config[:presentation])
config[:aspects].each_pair do |aspect_name, aspect_data|
ldapctl.set_aspect(aspect_name, aspect_data)
end
conf/ldap_shadows/test.conf
---
presentation:
hidden_attributes: ['objectClass', 'userPassword']
objects:
bot:
mapping:
......
presentation:
optional_classes: []
allowed_aspects: ['primary', 'mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
hidden_attributes: ['objectClass', 'uid']
hidden_attributes: ['uid']
expert_attributes: ['uidNumber', 'gidNumber', 'gecos']
individual:
mapping:
......
presentation:
optional_classes: []
allowed_aspects: ['primary', 'mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
hidden_attributes: ['objectClass', 'uid']
hidden_attributes: ['uid']
expert_attributes: ['uidNumber', 'gidNumber', 'gecos']
group:
mapping:
......
presentation:
optional_classes: []
allowed_aspects: []
hidden_attributes: ['objectClass', 'uniqueMember']
hidden_attributes: ['uniqueMember']
expert_attributes: ['gidNumber']
associated_relations: ['individualsPrimaryMembers', 'botsPrimaryMembers', 'individualsSecondaryMembers', 'botsSecondaryMembers']
relations:
......
sort_by: o
presentation:
name_attribute: o
hidden_attributes: ['objectClass', 'founder']
hidden_attributes: ['founder']
associated_relations: ['foundersIndividuals', 'foundersEntities']
relations:
foundersIndividuals:
data/ldap_shadows/en.yml
uidNumber: "Identifier (numeric)"
uniqueAbbreviation: "Unique Abbreviation"
uniqueMember: "Group member"
userPassword: "Password"
webVirtualHost: "Hosted Web Sites"
relations:
primaryGroup: "Primary Group"
lib/ldap_shadows/controller.rb
@aspects = {}
end
def set_global_config(global_config)
@global_config = global_config
end
def get_global_config
@global_config
end
def set_aspect(aspect_name, aspect_def)
@aspects[aspect_name] = aspect_def
end
lib/ldap_shadows/object.rb
options[:expert] ||= false;
options[:skip_binary] ||= false;
ignored_attrs = self.class.presentation[:hidden_attributes] || []
ignored_attrs = self.mapper.get_global_config[:hidden_attributes] || []
ignored_attrs += self.class.presentation[:hidden_attributes] || []
ignored_attrs += (self.class.presentation[:expert_attributes] || []) unless options[:expert]
attr_list = self.attributes.keys - ignored_attrs

Also available in: Unified diff