Class ActiveLdap::DistinguishedName
In: lib/active_ldap/distinguished_name.rb
Parent: Object
Error DeleteError LdapError AdapterNotSpecified OperationNotPermitted RequiredAttributeMissed LdifInvalid AttributeAssignmentError RequiredObjectClassMissed DistinguishedNameNotSetError StrongAuthenticationRequired ConnectionError SaveError EntryNotFound AuthenticationError EntryNotSaved UnknownAttribute ConnectionNotEstablished TimeoutError ConfigurationError AdapterNotFound DistinguishedNameInvalid ObjectClassError EntryInvalid EntryAlreadyExist Base DistinguishedName Ldif Reloadable::Deprecated Reloadable::Subclasses Enumerable Collection StandardError Children HasMany HasManyWrap BelongsToMany Proxy BelongsTo Common Find LDIF Delete Update GetText Parser GetTextSupport Base\n[lib/active_ldap/adapter/base.rb\nlib/active_ldap/adapter/ldap.rb\nlib/active_ldap/adapter/net_ldap.rb] Ldap NetLdap Normalize ActiveRecord::Callbacks ActiveRecord::Validations Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] lib/active_ldap/base.rb lib/active_ldap/schema.rb lib/active_ldap/ldif.rb lib/active_ldap/distinguished_name.rb lib/active_ldap/ldap_error.rb ClassMethods Associations ClassMethods HumanReadable 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/children.rb lib/active_ldap/association/collection.rb lib/active_ldap/association/belongs_to_many.rb lib/active_ldap/association/belongs_to.rb HasManyUtils Association ClassMethods Tree Acts Common LDIF Delete Find Update Operations lib/active_ldap/get_text/parser.rb GetText ClassMethods Configuration Command lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb Adapter GetTextSupport Normalize ClassMethods Attributes Escape Callbacks ClassMethods ObjectClass Helper Validations ClassMethods Connection GetTextFallback Populate Salt UserPassword ActiveLdap dot/m_40_0.png

Methods

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

Included Modules

GetTextSupport

Classes and Modules

Class ActiveLdap::DistinguishedName::Parser

Attributes

rdns  [R] 

Public Class methods

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 159
159:     def initialize(*rdns)
160:       @rdns = rdns.collect do |rdn|
161:         rdn = {rdn[0] => rdn[1]} if rdn.is_a?(Array) and rdn.size == 2
162:         rdn
163:       end
164:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 153
153:       def parse(source)
154:         Parser.new(source).parse
155:       end

Public Instance methods

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 166
166:     def -(other)
167:       rdns = @rdns.dup
168:       normalized_rdns = normalize(@rdns)
169:       normalize(other.rdns).reverse_each do |rdn|
170:         if rdn == normalized_rdns.pop
171:           rdns.pop
172:         else
173:           raise ArgumentError, _("%s isn't sub DN of %s") % [other, self]
174:         end
175:       end
176:       self.class.new(*rdns)
177:     end

[Source]

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

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 187
187:     def <=>(other)
188:       normalize_for_comparing(@rdns) <=>
189:         normalize_for_comparing(other.rdns)
190:     end

[Source]

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

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 197
197:     def eql?(other)
198:       other.is_a?(self.class) and
199:         normalize(@rdns).to_s.eql?(normalize(other.rdns).to_s)
200:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 202
202:     def hash
203:       normalize(@rdns).to_s.hash
204:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 206
206:     def inspect
207:       super
208:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 210
210:     def to_s
211:       @rdns.collect do |rdn|
212:         rdn.sort_by do |type, value|
213:           type.upcase
214:         end.collect do |type, value|
215:           "#{type}=#{escape(value)}"
216:         end.join("+")
217:       end.join(",")
218:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 183
183:     def unshift(rdn)
184:       @rdns.unshift(rdn)
185:     end

Private Instance methods

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 241
241:     def escape(value)
242:       if /(\A | \z)/.match(value)
243:         '"' + value.gsub(/([\\\"])/, '\\\\\1') + '"'
244:       else
245:         value.gsub(/([,=\+<>#;\\\"])/, '\\\\\1')
246:       end
247:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 221
221:     def normalize(rdns)
222:       rdns.collect do |rdn|
223:         normalized_rdn = {}
224:         rdn.each do |key, value|
225:           normalized_rdn[key.upcase] = value.upcase
226:         end
227:         normalized_rdn
228:       end
229:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 231
231:     def normalize_for_comparing(rdns)
232:       normalize(rdns).collect do |rdn|
233:         rdn.sort_by do |key, value|
234:           key
235:         end
236:       end.collect do |key, value|
237:         [key, value]
238:       end
239:     end

[Validate]