Revision 3e7f80c0
Added by Marc Dequènes about 15 years ago
- ID 3e7f80c01ca7c5a2baf5b3ddbf8148e02ea026dc
lib/ldap_shadows/activeldap_fixes.rb | ||
---|---|---|
end
|
||
end
|
||
|
||
# patch for activeldap#26745
|
||
class Base
|
||
# temporary method until active_ldap is fixed: return a DN object (see activeldap#23932)
|
||
def dn_obj
|
||
ActiveLdap::DistinguishedName.parse(self.dn)
|
||
end
|
||
|
||
# temporary method until active_ldap is fixed: return a DN object (see activeldap#23932)
|
||
def self.base_obj
|
||
ActiveLdap::DistinguishedName.parse(self.base)
|
||
end
|
||
|
||
# patch for activeldap#26745
|
||
def collect_modified_attributes(ldap_data, data)
|
||
attributes = []
|
||
# Now that all the options will be treated as unique attributes
|
lib/ldap_shadows/elements/object.rb | ||
---|---|---|
instance_variable_set(:@relations_info, object_relations_info)
|
||
end
|
||
|
||
# temporary method until active_ldap is fixed: return a DN object (see activeldap#23932)
|
||
def dn_obj
|
||
ActiveLdap::DistinguishedName.parse(self.dn)
|
||
end
|
||
|
||
# temporary method until active_ldap is fixed: return a DN object (see activeldap#23932)
|
||
def self.base_obj
|
||
ActiveLdap::DistinguishedName.parse(self.base)
|
||
end
|
||
|
||
def name
|
||
name = self[dn_attribute] || self.attributes[dn_attribute] || self.dn
|
||
name = name[0] if name.is_a? Array
|
||
... | ... | |
present_aspects
|
||
end
|
||
|
||
def self.objectclasses_attr_list(objectclass_list)
|
||
objectclass_list = [objectclass_list] unless objectclass_list.is_a? Array
|
||
list = []
|
||
objectclass_list.each do |objectclass|
|
||
objectclass_obj = ActiveLdap::Base.schema.object_class(objectclass)
|
||
attr_list = objectclass_obj.must + objectclass_obj.may
|
||
list += attr_list.collect{|attr| attr.human_attribute_name }
|
||
end
|
||
list
|
||
end
|
||
|
||
def self.possible_attributes
|
||
self.objectclasses_attr_list(self.required_classes)
|
||
end
|
||
|
||
def self.possible_attributes_for_aspect(aspect)
|
||
self.objectclasses_attr_list(self.shadow.get_aspect(aspect).parameters[:mapping][:classes])
|
||
end
|
||
... | ... | |
end
|
||
end
|
||
|
||
def family_parent_dn
|
||
pdn = self.dn_obj.dup
|
||
pdn.shift
|
||
pdn
|
||
end
|
||
|
||
def family_parent
|
||
# nothing found when using LdapObject, that's weird, so using ActiveLdap::Base
|
||
# until further investigation
|
||
#LdapObject.find(:first, :base => self.family_parent_dn.to_s, :scope => :base)
|
||
ActiveLdap::Base.find(:first, :base => self.family_parent_dn.to_s, :scope => :base)
|
||
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
|
||
|
||
def modified_attributes(op_types = nil, att_only = false)
|
||
list = []
|
||
prepare_data_for_saving do |data, ldap_data|
|
||
list = collect_modified_attributes(ldap_data, data)
|
||
false
|
||
end
|
||
|
||
unless op_types.nil?
|
||
list.reject! do |mod_info|
|
||
op_type, att, new_val = mod_info
|
||
not op_types.include? op_type
|
||
end
|
||
end
|
||
|
||
if att_only
|
||
list.collect! do |mod_info|
|
||
op_type, att, new_val = mod_info
|
||
att
|
||
end
|
||
end
|
||
|
||
list
|
||
end
|
||
|
||
def add_aspect(aspect)
|
||
return unless self.class.possible_aspects.include?(aspect)
|
||
|
lib/ldap_shadows/lang_additions.rb | ||
---|---|---|
@rdns.shift
|
||
end
|
||
end
|
||
|
||
class Base
|
||
def family_parent_dn
|
||
pdn = self.dn_obj.dup
|
||
pdn.shift
|
||
pdn
|
||
end
|
||
|
||
def family_parent
|
||
ActiveLdap::Base.find(:first, :base => self.family_parent_dn.to_s, :scope => :base)
|
||
end
|
||
|
||
def family_children
|
||
ActiveLdap::Base.find(:all, :base => self.dn, :scope => :one)
|
||
end
|
||
|
||
def family_children_dn
|
||
self.family_children.collect {|obj| obj.dn }
|
||
end
|
||
|
||
def family_siblings
|
||
ActiveLdap::Base.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
|
||
|
||
def modified_attributes(op_types = nil, att_only = false)
|
||
list = []
|
||
prepare_data_for_saving do |data, ldap_data|
|
||
list = collect_modified_attributes(ldap_data, data)
|
||
false
|
||
end
|
||
|
||
unless op_types.nil?
|
||
list.reject! do |mod_info|
|
||
op_type, att, new_val = mod_info
|
||
not op_types.include? op_type
|
||
end
|
||
end
|
||
|
||
if att_only
|
||
list.collect! do |mod_info|
|
||
op_type, att, new_val = mod_info
|
||
att
|
||
end
|
||
end
|
||
|
||
list
|
||
end
|
||
|
||
def self.objectclasses_attr_list(objectclass_list)
|
||
objectclass_list = [objectclass_list] unless objectclass_list.is_a? Array
|
||
list = []
|
||
objectclass_list.each do |objectclass|
|
||
objectclass_obj = ActiveLdap::Base.schema.object_class(objectclass)
|
||
attr_list = objectclass_obj.must + objectclass_obj.may
|
||
list += attr_list.collect{|attr| attr.human_attribute_name }
|
||
end
|
||
list
|
||
end
|
||
|
||
def self.possible_attributes
|
||
self.objectclasses_attr_list(self.required_classes)
|
||
end
|
||
end
|
||
end
|
||
|
Also available in: Unified diff
[cleanup] code reorganization