ruby-activeldap 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/activeldap.rb +1 -1
- data/lib/activeldap/base.rb +48 -42
- metadata +2 -2
data/lib/activeldap.rb
CHANGED
data/lib/activeldap/base.rb
CHANGED
@@ -689,54 +689,56 @@ module ActiveLDAP
|
|
689
689
|
# Put all changes into one change entry to ensure
|
690
690
|
# automatic rollback upon failure.
|
691
691
|
entry = []
|
692
|
-
if @exists
|
693
|
-
# Cycle through all attrs to determine action
|
694
|
-
action = {}
|
695
692
|
|
696
|
-
replaceable = []
|
697
693
|
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
end
|
714
|
-
ldap_data[key].delete(value)
|
694
|
+
# Expand subtypes to real ldap_data entries
|
695
|
+
# We can't reuse @ldap_data because an exception would leave
|
696
|
+
# an object in an unknown state
|
697
|
+
@@logger.debug("#write: dup'ing @ldap_data")
|
698
|
+
ldap_data = @ldap_data.dup
|
699
|
+
@@logger.debug("#write: dup finished @ldap_data")
|
700
|
+
@@logger.debug("#write: expanding subtypes in @ldap_data")
|
701
|
+
ldap_data.keys.each do |key|
|
702
|
+
ldap_data[key].each do |value|
|
703
|
+
if value.class == Hash
|
704
|
+
suffix, real_value = extract_subtypes(value)
|
705
|
+
if ldap_data.has_key? key + suffix
|
706
|
+
ldap_data[key + suffix].push(real_value)
|
707
|
+
else
|
708
|
+
ldap_data[key + suffix] = real_value
|
715
709
|
end
|
710
|
+
ldap_data[key].delete(value)
|
716
711
|
end
|
717
712
|
end
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
data[key].delete(value)
|
713
|
+
end
|
714
|
+
@@logger.debug("#write: subtypes expanded for @ldap_data")
|
715
|
+
|
716
|
+
# Expand subtypes to real data entries, but leave @data alone
|
717
|
+
@@logger.debug("#write: dup'ing @data")
|
718
|
+
data = @data.dup
|
719
|
+
@@logger.debug("#write: finished dup'ing @data")
|
720
|
+
@@logger.debug("#write: expanding subtypes for @data")
|
721
|
+
data.keys.each do |key|
|
722
|
+
data[key].each do |value|
|
723
|
+
if value.class == Hash
|
724
|
+
suffix, real_value = extract_subtypes(value)
|
725
|
+
if data.has_key? key + suffix
|
726
|
+
data[key + suffix].push(real_value)
|
727
|
+
else
|
728
|
+
data[key + suffix] = real_value
|
735
729
|
end
|
730
|
+
data[key].delete(value)
|
736
731
|
end
|
737
732
|
end
|
738
|
-
|
733
|
+
end
|
734
|
+
@@logger.debug("#write: subtypes expanded for @data")
|
735
|
+
|
739
736
|
|
737
|
+
if @exists
|
738
|
+
# Cycle through all attrs to determine action
|
739
|
+
action = {}
|
740
|
+
|
741
|
+
replaceable = []
|
740
742
|
# Now that all the subtypes will be treated as unique attributes
|
741
743
|
# we can see what's changed and add anything that is brand-spankin'
|
742
744
|
# new.
|
@@ -805,11 +807,15 @@ module ActiveLDAP
|
|
805
807
|
@@logger.debug("#write: adding objectClass = #{data[@attr_methods['objectClass']].inspect}")
|
806
808
|
entry.push(LDAP.mod(LDAP::LDAP_MOD_ADD, 'objectClass',
|
807
809
|
data[@attr_methods['objectClass']]))
|
808
|
-
|
810
|
+
data.each do |pair|
|
809
811
|
if pair[1].size > 0 and pair[0] != 'objectClass' and pair[0] != @attr_methods[dnattr()]
|
810
812
|
# Detect subtypes and account for them
|
811
|
-
|
812
|
-
|
813
|
+
if pair[0].match(/;binary(;|$)/)
|
814
|
+
binary = LDAP::LDAP_MOD_BVALUES
|
815
|
+
else
|
816
|
+
binary = 0
|
817
|
+
end
|
818
|
+
@@logger.debug("adding attribute to new entry: #{pair[0].inspect}: #{pair[1].inspect}")
|
813
819
|
entry.push(LDAP.mod(LDAP::LDAP_MOD_ADD|binary, pair[0], pair[1]))
|
814
820
|
end
|
815
821
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.1
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ruby-activeldap
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.4.
|
7
|
-
date: 2004-10-
|
6
|
+
version: 0.4.3
|
7
|
+
date: 2004-10-08
|
8
8
|
summary: Ruby/ActiveLDAP is a object-oriented API to LDAP
|
9
9
|
require_paths:
|
10
10
|
- lib
|