Class ActiveLdap::DistinguishedName
In: lib/active_ldap/distinguished_name.rb
Parent: Object
Error AttributeAssignmentError AdapterNotSpecified OperationNotPermitted RequiredObjectClassMissed ConnectionError RequiredAttributeMissed LdifInvalid LdapError DistinguishedNameNotSetError EntryNotFound SaveError StrongAuthenticationRequired AdapterNotFound ConnectionNotEstablished TimeoutError AuthenticationError AttributeValueInvalid EntryNotSaved DistinguishedNameInputInvalid EntryAlreadyExist ObjectClassError UnknownAttribute EntryInvalid DeleteError ConfigurationError DistinguishedNameInvalid DistinguishedName Base Reloadable::Deprecated Reloadable::Subclasses Enumerable Ldif Collection EntryAttribute StandardError Children HasManyWrap HasMany BelongsToMany Proxy BelongsTo Common Find LDIF Delete Update Normalizable GetText Parser ActiveRecord::Callbacks ActiveRecord::Validations Base\n[lib/active_ldap/adapter/base.rb\nlib/active_ldap/adapter/jndi.rb\nlib/active_ldap/adapter/ldap.rb\nlib/active_ldap/adapter/net_ldap.rb] Jndi Ldap NetLdap GetTextSupport Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] JndiConnection lib/active_ldap/distinguished_name.rb lib/active_ldap/base.rb lib/active_ldap/schema.rb lib/active_ldap/entry_attribute.rb lib/active_ldap/ldif.rb lib/active_ldap/ldap_error.rb ClassMethods Associations LdapBenchmarking ActionController Populate lib/active_ldap/association/has_many_wrap.rb lib/active_ldap/association/children.rb lib/active_ldap/association/collection.rb lib/active_ldap/association/proxy.rb lib/active_ldap/association/belongs_to_many.rb lib/active_ldap/association/belongs_to.rb lib/active_ldap/association/has_many.rb HasManyUtils Association ClassMethods Tree Acts Command Update Common ModifyNameRecordLoadable AddOperationModifiable DeleteOperationModifiable ReplaceOperationModifiable ModifyRecordLoadable DeleteRecordLoadable AddRecordLoadable ContentRecordLoadable LDIF Delete Find Operations GetTextSupport Escape ClassMethods Normalizable Attributes ClassMethods Configuration ClassMethods ObjectClass lib/active_ldap/get_text/parser.rb GetText ClassMethods Callbacks Validations lib/active_ldap/adapter/jndi_connection.rb lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb lib/active_ldap/adapter/jndi.rb Adapter Helper GetTextFallback ClassMethods HumanReadable Salt UserPassword ClassMethods Connection ActiveLdap dot/m_44_0.png

Methods

-   <<   <=>   ==   eql?   escape_value   hash   inspect   new   normalize   normalize_for_comparing   parse   to_human_readable_format   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 160
160:       def escape_value(value)
161:         if /(\A | \z)/.match(value)
162:           '"' + value.gsub(/([\\\"])/, '\\\\\1') + '"'
163:         else
164:           value.gsub(/([,=\+<>#;\\\"])/, '\\\\\1')
165:         end
166:       end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 170
170:     def initialize(*rdns)
171:       @rdns = rdns.collect do |rdn|
172:         if rdn.is_a?(Array) and rdn.size == 2
173:           {rdn[0] => rdn[1]}
174:         else
175:           rdn
176:         end
177:       end
178:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 156
156:       def parse(source)
157:         Parser.new(source).parse
158:       end

Public Instance methods

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 180
180:     def -(other)
181:       rdns = @rdns.dup
182:       normalized_rdns = normalize(@rdns)
183:       normalize(other.rdns).reverse_each do |rdn|
184:         if rdn == normalized_rdns.pop
185:           rdns.pop
186:         else
187:           raise ArgumentError, _("%s isn't sub DN of %s") % [other, self]
188:         end
189:       end
190:       self.class.new(*rdns)
191:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 193
193:     def <<(rdn)
194:       @rdns << rdn
195:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 201
201:     def <=>(other)
202:       normalize_for_comparing(@rdns) <=>
203:         normalize_for_comparing(other.rdns)
204:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 206
206:     def ==(other)
207:       other.is_a?(self.class) and
208:         normalize(@rdns) == normalize(other.rdns)
209:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 211
211:     def eql?(other)
212:       other.is_a?(self.class) and
213:         normalize(@rdns).to_s.eql?(normalize(other.rdns).to_s)
214:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 216
216:     def hash
217:       normalize(@rdns).to_s.hash
218:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 220
220:     def inspect
221:       super
222:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 234
234:     def to_human_readable_format
235:       to_s.inspect
236:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 224
224:     def to_s
225:       @rdns.collect do |rdn|
226:         rdn.sort_by do |type, value|
227:           type.upcase
228:         end.collect do |type, value|
229:           "#{type}=#{self.class.escape_value(value)}"
230:         end.join("+")
231:       end.join(",")
232:     end

[Source]

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

Private Instance methods

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 239
239:     def normalize(rdns)
240:       rdns.collect do |rdn|
241:         normalized_rdn = {}
242:         rdn.each do |key, value|
243:           normalized_rdn[key.upcase] = value.upcase
244:         end
245:         normalized_rdn
246:       end
247:     end

[Source]

     # File lib/active_ldap/distinguished_name.rb, line 249
249:     def normalize_for_comparing(rdns)
250:       normalize(rdns).collect do |rdn|
251:         rdn.sort_by do |key, value|
252:           key
253:         end
254:       end.collect do |key, value|
255:         [key, value]
256:       end
257:     end

[Validate]