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 TimeoutError AuthenticationError AttributeValueInvalid EntryNotSaved DistinguishedNameInputInvalid EntryAlreadyExist ObjectClassError UnknownAttribute EntryInvalid DeleteError ConfigurationError ConnectionNotSetup DistinguishedNameInvalid Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] 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 Xml JndiConnection lib/active_ldap/distinguished_name.rb lib/active_ldap/base.rb lib/active_ldap/xml.rb lib/active_ldap/schema.rb lib/active_ldap/entry_attribute.rb lib/active_ldap/ldif.rb lib/active_ldap/ldap_error.rb Compatible 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_46_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 161
161:       def escape_value(value)
162:         if /(\A | \z)/.match(value)
163:           '"' + value.gsub(/([\\\"])/, '\\\\\1') + '"'
164:         else
165:           value.gsub(/([,=\+<>#;\\\"])/, '\\\\\1')
166:         end
167:       end

[Source]

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

[Source]

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

Public Instance methods

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

Private Instance methods

[Source]

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

[Source]

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

[Validate]