Class ActiveLdap::DistinguishedName
In: lib/active_ldap/distinguished_name.rb
Parent: Object
Error DeleteError AdapterNotSpecified OperationNotPermitted LdapError RequiredAttributeMissed AttributeAssignmentError RequiredObjectClassMissed DistinguishedNameNotSetError StrongAuthenticationRequired ConnectionError SaveError EntryNotFound AuthenticationError EntryNotSaved UnknownAttribute ConnectionNotEstablished TimeoutError ConfigurationError AdapterNotFound DistinguishedNameInvalid ObjectClassError EntryInvalid EntryAlreadyExist Reloadable::Deprecated Base Reloadable::Subclasses Enumerable Collection StandardError HasMany HasManyWrap BelongsToMany Proxy BelongsTo Base\n[lib/active_ldap/adapter/base.rb\nlib/active_ldap/adapter/ldap.rb\nlib/active_ldap/adapter/net_ldap.rb] Ldap NetLdap ActiveRecord::Callbacks ActiveRecord::Validations Schema DistinguishedName lib/active_ldap/base.rb lib/active_ldap/schema.rb lib/active_ldap/distinguished_name.rb lib/active_ldap/ldap_error.rb ClassMethods Associations lib/active_ldap/association/has_many_wrap.rb lib/active_ldap/association/has_many.rb lib/active_ldap/association/proxy.rb lib/active_ldap/association/collection.rb lib/active_ldap/association/belongs_to_many.rb lib/active_ldap/association/belongs_to.rb Association ClassMethods Configuration Command lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb lib/active_ldap/adapter/base.rb Adapter ClassMethods Attributes ClassMethods ObjectClass Callbacks ClassMethods Connection Validations Salt UserPassword ActiveLdap dot/m_26_0.png

Methods

-   <<   <=>   ==   eql?   escape   hash   inspect   new   normalize   normalize_for_comparing   parse   to_s   unshift  

Classes and Modules

Class ActiveLdap::DistinguishedName::Parser

Attributes

rdns  [R] 

Public Class methods

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 154
154:     def initialize(*rdns)
155:       @rdns = rdns.collect do |rdn|
156:         rdn = {rdn[0] => rdn[1]} if rdn.is_a?(Array) and rdn.size == 2
157:         rdn
158:       end
159:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 148
148:       def parse(source)
149:         Parser.new(source).parse
150:       end

Public Instance methods

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 161
161:     def -(other)
162:       rdns = @rdns.dup
163:       normalized_rdns = normalize(@rdns)
164:       normalize(other.rdns).reverse_each do |rdn|
165:         if rdn == normalized_rdns.pop
166:           rdns.pop
167:         else
168:           raise ArgumentError, "#{other} isn't sub DN of #{self}"
169:         end
170:       end
171:       self.class.new(*rdns)
172:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 174
174:     def <<(rdn)
175:       @rdns << rdn
176:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 182
182:     def <=>(other)
183:       normalize_for_comparing(@rdns) <=>
184:         normalize_for_comparing(other.rdns)
185:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 187
187:     def ==(other)
188:       other.is_a?(self.class) and
189:         normalize(@rdns) == normalize(other.rdns)
190:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 192
192:     def eql?(other)
193:       other.is_a?(self.class) and
194:         normalize(@rdns).to_s.eql?(normalize(other.rdns).to_s)
195:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 197
197:     def hash
198:       normalize(@rdns).to_s.hash
199:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 201
201:     def inspect
202:       super
203:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 205
205:     def to_s
206:       @rdns.collect do |rdn|
207:         rdn.sort_by do |type, value|
208:           type.upcase
209:         end.collect do |type, value|
210:           "#{type}=#{escape(value)}"
211:         end.join("+")
212:       end.join(",")
213:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 178
178:     def unshift(rdn)
179:       @rdns.unshift(rdn)
180:     end

Private Instance methods

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 236
236:     def escape(value)
237:       if /(\A | \z)/.match(value)
238:         '"' + value.gsub(/([\\\"])/, '\\\\\1') + '"'
239:       else
240:         value.gsub(/([,=\+<>#;\\\"])/, '\\\\\1')
241:       end
242:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 216
216:     def normalize(rdns)
217:       rdns.collect do |rdn|
218:         normalized_rdn = {}
219:         rdn.each do |key, value|
220:           normalized_rdn[key.upcase] = value.upcase
221:         end
222:         normalized_rdn
223:       end
224:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 226
226:     def normalize_for_comparing(rdns)
227:       normalize(rdns).collect do |rdn|
228:         rdn.sort_by do |key, value|
229:           key
230:         end
231:       end.collect do |key, value|
232:         [key, value]
233:       end
234:     end

[Validate]