Class Net::LDAP::DN
In: lib/net/ldap/dn.rb
Parent: Object

Objects of this class represent an LDAP DN ("Distinguished Name"). A DN ("Distinguished Name") is a unique identifier for an entry within an LDAP directory. It is made up of a number of other attributes strung together, to identify the entry in the tree.

Each attribute that makes up a DN needs to have its value escaped so that the DN is valid. This class helps take care of that.

A fully escaped DN needs to be unescaped when analysing its contents. This class also helps take care of that.

Methods

each_pair   escape   method_missing   new   to_a   to_s  

Constants

ESCAPES = { ',' => ',', '+' => '+', '"' => '"', '\\' => '\\', '<' => '<', '>' => '>', ';' => ';', }   tools.ietf.org/html/rfc2253 section 2.4 lists these exceptions for dn values. All of the following must be escaped in any normal string using a single backslash (’\’) as escape.
ESCAPE_RE = Regexp.new("(^ |^#| $|[" + ESCAPES.keys.map { |e| Regexp.escape(e) }.join + "])")   Compiled character class regexp using the keys from the above hash, and checking for a space or # at the start, or space at the end, of the string.

Public Class methods

Escape a string for use in a DN value

Initialize a DN, escaping as required. Pass in attributes in name/value pairs. If there is a left over argument, it will be appended to the dn without escaping (useful for a base string).

Most uses of this class will be to escape a DN, rather than to parse it, so storing the dn as an escaped String and parsing parts as required with a state machine seems sensible.

Public Instance methods

Proxy all other requests to the string object, because a DN is mainly used within the library as a string

Returns the DN as an array in the form expected by the constructor.

Return the DN as an escaped string.

[Validate]