### Home Classes Methods

### In Files

- lib/active_ldap/distinguished_name.rb

### Parent

Object

### Namespace

- CLASS ActiveLdap::DistinguishedName::Parser

### Methods

- ::escape_value
- ::new
- ::parse
- #+
- #-
- #<<
- #<=>
- #==
- #blank?
- #eql?
- #hash
- #normalize
- #normalize_for_comparing
- #parent
- #to_human_readable_format
- #to_s
- #to_str
- #unshift

### Included Modules

- ActiveLdap::GetTextSupport

### Files

- USAGE

### Class/Module Index

Quicksearch

- ActiveLdap
- ActiveLdap::ActionController
- ActiveLdap::ActionController::LdapBenchmarking
- ActiveLdap::Acts
- ActiveLdap::Acts::Tree
- ActiveLdap::Acts::Tree::ClassMethods
- ActiveLdap::Adapter
- ActiveLdap::Adapter::Base
- ActiveLdap::Adapter::Jndi
- ActiveLdap::Adapter::JndiConnection
- ActiveLdap::Adapter::JndiConnection::ModifyRecord
- ActiveLdap::Adapter::JndiConnection::Scope
- ActiveLdap::Adapter::Ldap
- ActiveLdap::Adapter::Ldap::Method
- ActiveLdap::Adapter::Ldap::Method::Base
- ActiveLdap::Adapter::Ldap::Method::Plain
- ActiveLdap::Adapter::Ldap::Method::SSL
- ActiveLdap::Adapter::Ldap::Method::TLS
- ActiveLdap::Adapter::NetLdap
- ActiveLdap::Association
- ActiveLdap::Association::BelongsTo
- ActiveLdap::Association::BelongsToMany
- ActiveLdap::Association::Children
- ActiveLdap::Association::Collection
- ActiveLdap::Association::HasMany
- ActiveLdap::Association::HasManyUtils
- ActiveLdap::Association::HasManyWrap
- ActiveLdap::Association::Proxy
- ActiveLdap::Associations
- ActiveLdap::Associations::ClassMethods
- ActiveLdap::AttributeMethods
- ActiveLdap::AttributeMethods::BeforeTypeCast
- ActiveLdap::AttributeMethods::Dirty
- ActiveLdap::AttributeMethods::Query
- ActiveLdap::AttributeMethods::Read
- ActiveLdap::AttributeMethods::Write
- ActiveLdap::Attributes
- ActiveLdap::Attributes::ClassMethods
- ActiveLdap::Attributes::Normalizable
- ActiveLdap::Callbacks
- ActiveLdap::Callbacks::ClassMethods
- ActiveLdap::Command
- ActiveLdap::Compatible
- ActiveLdap::Configuration
- ActiveLdap::Configuration::ClassMethods
- ActiveLdap::Connection
- ActiveLdap::Connection::ClassMethods
- ActiveLdap::DN
- ActiveLdap::DistinguishedName
- ActiveLdap::DistinguishedName::Parser
- ActiveLdap::Entry
- ActiveLdap::EntryAttribute
- ActiveLdap::Escape
- ActiveLdap::Generators
- ActiveLdap::Generators::ModelGenerator
- ActiveLdap::Generators::ScaffoldGenerator
- ActiveLdap::GetText
- ActiveLdap::GetText::Parser
- ActiveLdap::GetTextSupport
- ActiveLdap::Helper
- ActiveLdap::HumanReadable
- ActiveLdap::HumanReadable::ClassMethods
- ActiveLdap::LDIF
- ActiveLdap::LdapError
- ActiveLdap::Ldif
- ActiveLdap::Ldif::AddRecord
- ActiveLdap::Ldif::Attribute
- ActiveLdap::Ldif::Attributes
- ActiveLdap::Ldif::ChangeRecord
- ActiveLdap::Ldif::ChangeRecord::Control
- ActiveLdap::Ldif::ContentRecord
- ActiveLdap::Ldif::DeleteRecord
- ActiveLdap::Ldif::ModifyDNRecord
- ActiveLdap::Ldif::ModifyNameRecord
- ActiveLdap::Ldif::ModifyRDNRecord
- ActiveLdap::Ldif::ModifyRecord
- ActiveLdap::Ldif::ModifyRecord::AddOperation
- ActiveLdap::Ldif::ModifyRecord::DeleteOperation
- ActiveLdap::Ldif::ModifyRecord::Operation
- ActiveLdap::Ldif::ModifyRecord::ReplaceOperation
- ActiveLdap::Ldif::Parser
- ActiveLdap::Ldif::Record
- ActiveLdap::Ldif::Scanner
- ActiveLdap::LogSubscriber
- ActiveLdap::ObjectClass
- ActiveLdap::ObjectClass::ClassMethods
- ActiveLdap::Operations
- ActiveLdap::Operations::ClassOnlyDelete
- ActiveLdap::Operations::ClassOnlyUpdate
- ActiveLdap::Operations::Common
- ActiveLdap::Operations::Delete
- ActiveLdap::Operations::Find
- ActiveLdap::Operations::LDIF
- ActiveLdap::Operations::LDIF::AddRecordLoadable
- ActiveLdap::Operations::LDIF::ContentRecordLoadable
- ActiveLdap::Operations::LDIF::DeleteRecordLoadable
- ActiveLdap::Operations::LDIF::ModifyNameRecordLoadable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable::AddOperationModifiable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable::DeleteOperationModifiable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable::ReplaceOperationModifiable
- ActiveLdap::Operations::Update
- ActiveLdap::Persistence
- ActiveLdap::Populate
- ActiveLdap::Railtie
- ActiveLdap::Railties
- ActiveLdap::Railties::ControllerRuntime
- ActiveLdap::Railties::ControllerRuntime::ClassMethods
- ActiveLdap::Schema
- ActiveLdap::Schema::Attribute
- ActiveLdap::Schema::Entry
- ActiveLdap::Schema::ObjectClass
- ActiveLdap::Schema::Syntax
- ActiveLdap::Schema::Syntaxes
- ActiveLdap::Schema::Syntaxes::Base
- ActiveLdap::Schema::Syntaxes::BitString
- ActiveLdap::Schema::Syntaxes::Boolean
- ActiveLdap::Schema::Syntaxes::CountryString
- ActiveLdap::Schema::Syntaxes::DirectoryString
- ActiveLdap::Schema::Syntaxes::DistinguishedName
- ActiveLdap::Schema::Syntaxes::GeneralizedTime
- ActiveLdap::Schema::Syntaxes::Integer
- ActiveLdap::Schema::Syntaxes::JPEG
- ActiveLdap::Schema::Syntaxes::NameAndOptionalUID
- ActiveLdap::Schema::Syntaxes::NumericString
- ActiveLdap::Schema::Syntaxes::OID
- ActiveLdap::Schema::Syntaxes::ObjectSecurityDescriptor
- ActiveLdap::Schema::Syntaxes::OctetString
- ActiveLdap::Schema::Syntaxes::OtherMailbox
- ActiveLdap::Schema::Syntaxes::PostalAddress
- ActiveLdap::Schema::Syntaxes::PrintableString
- ActiveLdap::Schema::Syntaxes::TelephoneNumber
- ActiveLdap::UserPassword
- ActiveLdap::UserPassword::Salt
- ActiveLdap::Validations
- ActiveLdap::XML
- ActiveLdap::Xml
- ActiveLdap::Xml::Serializer
- LDAP
- LDAP::Conn
- LDAP::Mod
- Net
- Net::LDAP
- Net::LDAP::Entry
- ActionView
- ActionView::Base
- URI
- URI::LDAPS
- Object
- Timeout

No matching classes.

# ActiveLdap::DistinguishedName

### Attributes

rdns[R]

### Public Class Methods

escape_value(value) click to toggle source

    # File lib/active_ldap/distinguished_name.rb, line 161
    def escape_value(value)
      if /(\A | \z)/.match(value)
        '"' + value.gsub(/([\\\"])/, '\\\1') + '"'
      else
        value.gsub(/([,=\+<>#;\\\"])/, '\\\1')
      end
    end

new(*rdns) click to toggle source

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

parse(source) click to toggle source

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

### Public Instance Methods

+(other) click to toggle source

    # File lib/active_ldap/distinguished_name.rb, line 185
    def +(other)
      self.class.new(*(@rdns + other.rdns))
    end

-(other) click to toggle source

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

<<(rdn) click to toggle source

    # File lib/active_ldap/distinguished_name.rb, line 202
    def <<(rdn)
      @rdns << rdn
      self
    end

<=>(other) click to toggle source

    # File lib/active_ldap/distinguished_name.rb, line 216
    def <=>(other)
      other = DN.parse(other) if other.is_a?(String)
      return nil unless other.is_a?(self.class)
      normalize_for_comparing(@rdns) <=>
        normalize_for_comparing(other.rdns)
    end

==(other) click to toggle source

    # File lib/active_ldap/distinguished_name.rb, line 223
    def ==(other)
      case other
      when self.class
        normalize(@rdns) == normalize(other.rdns)
      when String
        parsed_other = nil
        begin
          parsed_other = self.class.parse(other)
        rescue DistinguishedNameInvalid
          return false
        end
        self == parsed_other
      else
        false
      end
    end

blank?() click to toggle source

    # File lib/active_ldap/distinguished_name.rb, line 181
    def blank?
      @rdns.blank?
    end

eql?(other) click to toggle source

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

hash() click to toggle source

    # File lib/active_ldap/distinguished_name.rb, line 245
    def hash
      normalize(@rdns).to_s.hash
    end

parent() click to toggle source

    # File lib/active_ldap/distinguished_name.rb, line 211
    def parent
      return nil if @rdns.size <= 1
      self.class.new(*@rdns[1..-1])
    end

to_human_readable_format() click to toggle source

    # File lib/active_ldap/distinguished_name.rb, line 264
    def to_human_readable_format
      to_s.inspect
    end

to_s() click to toggle source

    # File lib/active_ldap/distinguished_name.rb, line 249
    def to_s
      klass = self.class
      @rdns.collect do |rdn|
        rdn.sort_by do |type, value|
          type.upcase
        end.collect do |type, value|
          "#{type}=#{klass.escape_value(value)}"
        end.join("+")
      end.join(",")
    end

to_str() click to toggle source

    # File lib/active_ldap/distinguished_name.rb, line 260
    def to_str # for backward compatibility
      to_s
    end

unshift(rdn) click to toggle source

    # File lib/active_ldap/distinguished_name.rb, line 207
    def unshift(rdn)
      @rdns.unshift(rdn)
    end

### Private Instance Methods

normalize(rdns) click to toggle source

    # File lib/active_ldap/distinguished_name.rb, line 269
    def normalize(rdns)
      rdns.collect do |rdn|
        normalized_rdn = {}
        rdn.each do |key, value|
          normalized_rdn[key.upcase] = value.upcase
        end
        normalized_rdn
      end
    end

normalize_for_comparing(rdns) click to toggle source

    # File lib/active_ldap/distinguished_name.rb, line 279
    def normalize_for_comparing(rdns)
      normalize(rdns).collect do |rdn|
        rdn.sort_by do |key, value|
          key
        end
      end.collect do |key, value|
        [key, value]
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.