Revision 2cb97830
Added by Marc Dequènes over 14 years ago
- ID 2cb9783056d36e1b4862e5af7fb4cbd019cf2485
conf/ldap_shadows/shadows/MilkyPond/plugins/aspects/primary_account.rb | ||
---|---|---|
|
||
require 'shared_attributes'
|
||
|
||
def self.hook_before_create(item)
|
||
hook_common(item)
|
||
end
|
||
... | ... | |
end
|
||
|
||
def self.hook_common(item)
|
||
if item.attribute_present?('allowedServices')
|
||
user_services = ActiveLdap::Base.find(:all, :scope => :sub, :filter => "(objectClass=userService)", :attributes => ['cn'])
|
||
srv_names = user_services.collect {|srv| srv.cn }
|
||
|
||
invalid_srv_names = item.allowedServices(true) - (item.allowedServices(true) & srv_names)
|
||
unless invalid_srv_names.empty?
|
||
raise PreProcessingError, "Invalid User Service(s) name(s): " + invalid_srv_names.join(", ")
|
||
end
|
||
end
|
||
SharedAttr.check_common_attributes(item)
|
||
end
|
||
|
conf/ldap_shadows/shadows/MilkyPond/plugins/includes/shared_attributes.rb | ||
---|---|---|
module SharedAttr
|
||
module_function
|
||
|
||
def check_common_attributes(item)
|
||
if item.attribute_present?('allowedServices')
|
||
user_services = ActiveLdap::Base.find(:all, :scope => :sub, :filter => "(objectClass=userService)", :attributes => ['cn'])
|
||
srv_names = user_services.collect {|srv| srv.cn }
|
||
|
||
invalid_srv_names = item.allowedServices(true) - (item.allowedServices(true) & srv_names)
|
||
unless invalid_srv_names.empty?
|
||
raise PreProcessingError, "Invalid User Service(s) name(s): " + invalid_srv_names.join(", ")
|
||
end
|
||
end
|
||
end
|
||
end
|
conf/ldap_shadows/shadows/MilkyPond/plugins/objects/secondary_account.rb | ||
---|---|---|
|
||
require 'shared_attributes'
|
||
|
||
def self.hook_before_create(item)
|
||
hook_common(item)
|
||
end
|
||
... | ... | |
end
|
||
|
||
def self.hook_common(item)
|
||
if item.attribute_present?('allowedServices')
|
||
user_services = ActiveLdap::Base.find(:all, :scope => :sub, :filter => "(objectClass=userService)", :attributes => ['cn'])
|
||
srv_names = user_services.collect {|srv| srv.cn }
|
||
|
||
invalid_srv_names = item.allowedServices(true) - (item.allowedServices(true) & srv_names)
|
||
unless invalid_srv_names.empty?
|
||
raise PreProcessingError, "Invalid User Service(s) name(s): " + invalid_srv_names.join(", ")
|
||
end
|
||
end
|
||
SharedAttr.check_common_attributes(item)
|
||
end
|
||
|
conf/ldap_shadows/shadows/MilkyPond/plugins/objects/system_account.rb | ||
---|---|---|
|
||
require 'shared_attributes'
|
||
|
||
def self.hook_before_create(item)
|
||
hook_common(item)
|
||
end
|
||
... | ... | |
end
|
||
|
||
def self.hook_common(item)
|
||
if item.attribute_present?('allowedServices')
|
||
user_services = ActiveLdap::Base.find(:all, :scope => :sub, :filter => "(objectClass=userService)", :attributes => ['cn'])
|
||
srv_names = user_services.collect {|srv| srv.cn }
|
||
|
||
invalid_srv_names = item.allowedServices(true) - (item.allowedServices(true) & srv_names)
|
||
unless invalid_srv_names.empty?
|
||
raise PreProcessingError, "Invalid User Service(s) name(s): " + invalid_srv_names.join(", ")
|
||
end
|
||
end
|
||
SharedAttr.check_common_attributes(item)
|
||
end
|
||
|
lib/ldap_shadows/config.rb | ||
---|---|---|
}
|
||
shadow.set_config(config)
|
||
|
||
include_path = File.join(shadow_config_path, "plugins", "includes")
|
||
$:.unshift(include_path) if File.directory?(include_path)
|
||
|
||
load_element_config(shadow_config_path, 'aspects') do |c_name, c_config|
|
||
shadow.add_aspect(c_name, c_config)
|
||
end
|
Also available in: Unified diff
[evol] use a plugins-pecific include dir to share functions among plugins easily (closes #36)