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.
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. |
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.
Parse a DN into key value pairs using ASN from tools.ietf.org/html/rfc2253 section 3.
Proxy all other requests to the string object, because a DN is mainly used within the library as a string