RFC 2253
Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names
Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names πβ¨
Okay bestie, here's the tea on this RFC ππ«Ά
- RFC number: 2253 π
- Title: Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names
- Authors: M. Wahl (Critical Angle Inc.), S. Kille (Isode Ltd.) and T. Howes (Netscape Communications Corp.) π―
- Category: Standards Track π¦
- Date: December 1997 πΈ
- Obsoletes: RFC 1779 π
- Updates: the header doesn't list any RFCs being updated
Status of This Memo π
This document is an Internet standards track protocol for the Internet community, and it's asking for discussion and suggestions for improvements π£οΈ For the standardization state and status of this protocol, check the current edition of the "Internet Official Protocol Standards" (STD 1). Distribution of this memo is unlimited π
Copyright Notice Β©οΈ
Copyright (C) The Internet Society (1997). All Rights Reserved. π
IESG Note β οΈ
Okay, this one's important π¨ This document describes a directory access protocol that gives both read and update access. Update access needs secure authentication, but this document doesn't require anyone to implement any satisfactory authentication mechanisms. π
Following RFC 2026, section 4.4.1, the IESG approved this specification as a Proposed Standard anyway, for these reasons:
- to encourage implementation and interoperability testing of these protocols (with or without update access) before they are deployed, and
- to encourage deployment and use of these protocols in read-only applications (e.g. applications where LDAPv3 is used as a query language for directories which are updated by some secure mechanism other than LDAP), and
- to avoid delaying the advancement and deployment of other Internet standards-track protocols which require the ability to query, but not update, LDAPv3 directory servers.
Readers, consider yourselves warned π© Until mandatory authentication mechanisms are standardized, clients and servers written to this specification that use the update functionality are unlikely to interoperate, or may interoperate only if authentication is reduced to an unacceptably weak level. π
Implementors are also strongly discouraged from deploying LDAPv3 clients or servers that implement the update functionality, until a Proposed Standard for mandatory authentication in LDAPv3 has been approved and published as an RFC π ββοΈ
Abstract π
The X.500 Directory uses distinguished names as the primary keys to entries in the directory. Distinguished Names are encoded in ASN.1 in the X.500 Directory protocols. In the Lightweight Directory Access Protocol, a string representation of distinguished names gets transferred. This specification defines the string format for representing names. It's designed to give a clean representation of commonly used distinguished names, while still being able to represent any distinguished name π§
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [6]. π
1. Background πΈ
This spec assumes you're familiar with X.500 [1] and the concept of a Distinguished Name. It's important to have a common format so you can unambiguously represent a distinguished name π The main goal is ease of encoding and decoding. A secondary goal is for names to be human readable. LDAP clients with a human user interface aren't expected to display these strings directly to the user. They'd most likely do translations instead, like expressing attribute type names in one of the local national languages π
2. Converting DistinguishedName from ASN.1 to a String π§©
In X.501 [2], the ASN.1 structure of a distinguished name is defined as:
DistinguishedName ::= RDNSequence
RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
RelativeDistinguishedName ::= SET SIZE (1..MAX) OF
AttributeTypeAndValue
AttributeTypeAndValue ::= SEQUENCE {
type AttributeType,
value AttributeValue }
The following sections define the algorithm for turning an ASN.1 structured representation into a UTF-8 string representation β¨
2.1. Converting the RDNSequence π
If the RDNSequence is an empty sequence, the result is the empty or zero length string. π«₯
Otherwise, the output is made up of the string encodings of each RelativeDistinguishedName in the RDNSequence (according to 2.2). You start with the last element of the sequence and move backwards toward the first one π
The encodings of adjoining RelativeDistinguishedNames are separated by a comma character (',' ASCII 44) π
2.2. Converting RelativeDistinguishedName π¦
When you convert an ASN.1 RelativeDistinguishedName to a string, the output consists of the string encodings of each AttributeTypeAndValue (according to 2.3), in any order. Any order! π
If there's a multi-valued RDN, the outputs from adjoining AttributeTypeAndValues are separated by a plus ('+' ASCII 43) character β
2.3. Converting AttributeTypeAndValue π―
The AttributeTypeAndValue is encoded as the string representation of the AttributeType, followed by an equals character ('=' ASCII 61), followed by the string representation of the AttributeValue. The encoding of the AttributeValue is given in section 2.4 π
If the AttributeType is in a published table of attribute types associated with LDAP [4], then the type name string from that table is used. Otherwise, it's encoded as the dotted-decimal encoding of the AttributeType's OBJECT IDENTIFIER. The dotted-decimal notation is described in [3] π’ Here are some examples of strings for attribute types you'll frequently see in RDNs:
String X.500 AttributeType
------------------------------
CN commonName
L localityName
ST stateOrProvinceName
O organizationName
OU organizationalUnitName
C countryName
STREET streetAddress
DC domainComponent
UID userid
2.4. Converting an AttributeValue from ASN.1 to a String π«§
If the AttributeValue is of a type that doesn't have a string representation defined for it, then it's simply encoded as an octothorpe character ('#' ASCII 35), followed by the hexadecimal representation of each of the bytes of the BER encoding of the X.500 AttributeValue. This form SHOULD be used if the AttributeType is of the dotted-decimal form. π§
Otherwise, if the AttributeValue is of a type that does have a string representation, the value is first converted to a UTF-8 string according to its syntax specification (see for example section 6 of [4]) π
If the UTF-8 string doesn't have any of the following characters that need escaping, then that string can be used as the string representation of the value:
- a space or "#" character occurring at the beginning of the string
- a space character occurring at the end of the string
- one of the characters ",", "+", """, "", "<", ">" or ";"
Implementations MAY escape other characters. π
If a character to be escaped is one of the list shown above, then it's prefixed by a backslash ('' ASCII 92) πͺ
Otherwise, the character to be escaped is replaced by a backslash and two hex digits, which form a single byte in the code of the character π¨
Examples of the escaping mechanism are shown in section 5 π
3. Parsing a String back to a Distinguished Name π
The structure of the string is specified in a BNF grammar, based on the grammar defined in RFC 822 [5]. Server implementations parsing a DN string generated by an LDAPv2 client MUST also accept (and ignore) the variants given in section 4 of this document. This one's a must-do, bestie π«Ά
distinguishedName = [name] ; may be empty string
name = name-component *("," name-component)
name-component = attributeTypeAndValue *("+" attributeTypeAndValue)
attributeTypeAndValue = attributeType "=" attributeValue
attributeType = (ALPHA 1*keychar) / oid
keychar = ALPHA / DIGIT / "-"
oid = 1*DIGIT *("." 1*DIGIT)
attributeValue = string
string = *( stringchar / pair )
/ "#" hexstring
/ QUOTATION *( quotechar / pair ) QUOTATION ; only from v2
quotechar = <any character except "\" or QUOTATION >
special = "," / "=" / "+" / "<" / ">" / "#" / ";"
pair = "\" ( special / "\" / QUOTATION / hexpair )
stringchar = <any character except one of special, "\" or QUOTATION >
hexstring = 1*hexpair
hexpair = hexchar hexchar
hexchar = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
/ "a" / "b" / "c" / "d" / "e" / "f"
ALPHA = <any ASCII alphabetic character>
; (decimal 65-90 and 97-122)
DIGIT = <any ASCII decimal digit> ; (decimal 48-57)
QUOTATION = <the ASCII double quotation mark character '"' decimal 34>
4. Relationship with RFC 1779 and LDAPv2 π€
The syntax in this document is more restrictive than the syntax in RFC 1779. Implementations parsing a string generated by an LDAPv2 client MUST accept the syntax of RFC 1779. Implementations MUST NOT, however, generate any of the RFC 1779 encodings that aren't described above in section 2. Don't be that implementation π ββοΈ
Implementations MUST allow a semicolon character to be used instead of a comma to separate RDNs in a distinguished name. They MUST also allow whitespace characters to be present on either side of the comma or semicolon. The whitespace characters are ignored, and the semicolon gets replaced with a comma πͺ
Implementations MUST allow an oid in the attribute type to be prefixed by one of the character strings "oid." or "OID." π’
Implementations MUST allow for space (' ' ASCII 32) characters to be present between name-component and ',', between attributeTypeAndValue and '+', between attributeType and '=', and between '=' and attributeValue. These space characters are ignored when parsing π«§
Implementations MUST allow a value to be surrounded by quote ('"' ASCII 34) characters, which aren't part of the value. Inside the quoted value, the following characters can occur without any escaping:
",", "=", "+", "<", ">", "#" and ";"
5. Examples π
Okay so this notation is literally designed to be super convenient for the most common forms of name, and this section gives a few distinguished names written with it. First up is a name with three relative distinguished names (RDNs) π :
CN=Steve Kille,O=Isode Limited,C=GB
Here's another one with three RDNs, but the first RDN is multi-valued π«Ά:
OU=Sales+CN=J. Smith,O=Widget Inc.,C=US
This example shows how to quote a comma inside an organization name π:
CN=L. Eagle,O=Sue\, Grabbit and Runn,C=GB
An example name where a value contains a carriage return character π:
CN=Before\0DAfter,O=Test,C=GB
Next is a name with an RDN of a type that isn't recognized π. The value is the BER encoding of an OCTET STRING containing two bytes, 0x48 and 0x69 β¨:
1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB
And finally, an example with a surname value made of 5 letters π:
Unicode Letter Description 10646 code UTF-8 Quoted
=============================== ========== ====== =======
LATIN CAPITAL LETTER L U0000004C 0x4C L
LATIN SMALL LETTER U U00000075 0x75 u
LATIN SMALL LETTER C WITH CARON U0000010D 0xC48D \C4\8D
LATIN SMALL LETTER I U00000069 0x69 i
LATIN SMALL LETTER C WITH ACUTE U00000107 0xC487 \C4\87
That same surname can also be written in printable ASCII, which is super useful for debugging π:
SN=Lu\C4\8Di\C4\87
6. References π
- [1] The Directory -- overview of concepts, models and services. ITU-T Rec. X.500(1993).
- [2] The Directory -- Models. ITU-T Rec. X.501(1993).
- [3] Wahl, M., Howes, T., and S. Kille, "Lightweight Directory Access Protocol (v3)", RFC 2251, December 1997.
- [4] Wahl, M., Coulbeck, A., Howes, T. and S. Kille, "Lightweight Directory Access Protocol (v3): Attribute Syntax Definitions", RFC 2252, December 1997.
- [5] Crocker, D., "Standard of the Format of ARPA-Internet Text Messages", STD 11, RFC 822, August 1982.
- [6] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", RFC 2119.
7. Security Considerations π₯
7.1. Disclosure
Okay, security time, and this one is serious bestie π. Distinguished Names usually hold descriptive info about the entries they name, and those entries can be people, organizations, devices, or other real-world objects. This often includes some of the following kinds of information π΅οΈ:
- the common name of the object (i.e. a person's full name)
- an email or TCP/IP address
- its physical location (country, locality, city, street address)
- organizational attributes (such as department name or affiliation)
Most countries have privacy laws about publishing information about people, so be careful what you put out there π.
7.2. Use of Distinguished Names in Security Applications
Here's the tea β. Transformations of an AttributeValue from its X.501 form to an LDAP string representation are not always reversible back to the same BER or DER form. A situation that needs the DER form of a distinguished name is verifying an X.509 certificate, for example π§Ύ.
Let's say a distinguished name has one RDN with one AVA, where the type is commonName and the value is the TeletexString choice with the letters 'Sam'. In LDAP that comes out as the string CN=Sam. Another distinguished name where the value is still 'Sam' but uses the PrintableString choice would have the exact same representation, CN=Sam π. Same string, different encodings, and that's the whole problem.
Applications that need to rebuild the DER form of the value SHOULD NOT use the string representation of attribute syntaxes when converting a distinguished name to the LDAP format. Instead, they SHOULD use the hexadecimal form prefixed by the octothorpe ('#') as described in the first paragraph of section 2.4. π¨
8. Authors' Addresses π
Mark Wahl
Critical Angle Inc.
4815 W. Braker Lane #502-385
Austin, TX 78759
USA
EMail: M.Wahl@critical-angle.com
Steve Kille
Isode Ltd.
The Dome
The Square
Richmond, Surrey
TW9 1DT
England
Phone: +44-181-332-9091
EMail: S.Kille@ISODE.COM
Tim Howes
Netscape Communications Corp.
501 E. Middlefield Rd, MS MV068
Mountain View, CA 94043
USA
Phone: +1 650 937-3419
EMail: howes@netscape.com
9. Full Copyright Statement β
Copyright (C) The Internet Society (1997). All Rights Reserved.
This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organizations, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English.
The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns.
This document and the information contained herein is provided on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. π¦
π¦ where this page comes from
- ietf: rfc2253 1997-12
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms