Project

General

Profile

« Previous | Next » 

Revision b0304d30

Added by Marc Dequènes about 15 years ago

  • ID b0304d3003b2a568db3af0e21fa958a3ebdb509e

[evol] first experimental attempt for field modifications (with activeldap workaround for #26720)

View differences:

lib/ldap_shadows/object.rb
ActiveLdap::DistinguishedName.parse(self.dn)
end
def self.find(*args)
obj = super(*args)
obj.load_initial_attribute_list
return obj
end
def load_initial_attribute_list
@initial_attribute_list ||= self.attributes.keys
end
def name
name = self[dn_attribute].is_a?(Array) ? self[dn_attribute][0] : self[dn_attribute]
name.strip
end
def validate_required_ldap_values
_schema = nil
# Make sure all MUST attributes have a value
entry_attribute.object_classes.each do |object_class|
object_class.must.each do |required_attribute|
# Normalize to ensure we catch schema problems
# needed?
real_name = to_real_attribute_name(required_attribute.name, true)
raise UnknownAttribute.new(required_attribute) if real_name.nil?
next if required_attribute.read_only?
value = @data[real_name] || []
next unless self.class.blank_value?(value)
# Duck: hack
next unless @initial_attribute_list.include?(real_name)
_schema ||= schema
aliases = required_attribute.aliases.collect do |name|
self.class.human_attribute_name(name)
end
args = [self.class.human_object_class_name(object_class)]
if aliases.empty?
format = _("%{fn} is required attribute by objectClass '%s'")
else
format = _("%{fn} is required attribute by objectClass " \
"'%s': aliases: %s")
args << aliases.join(', ')
end
unless ActiveLdap.get_text_supported?
format = format.sub(/^%\{fn\} /, '')
end
errors.add(real_name, format % args)
end
end
end
def human_name
[self.class.presentation[:name_attribute], 'displayName', 'cn'].each do |attr|
if attr == 'dn' or (self.has_attribute?(attr) and self.attribute_present?(attr))

Also available in: Unified diff