{"id":282,"date":"2018-04-27T05:30:20","date_gmt":"2018-04-27T05:30:20","guid":{"rendered":"https:\/\/ldap.com\/ldapv3-wire-protocol-reference-the-ldap-add-operation\/"},"modified":"2018-05-06T17:34:42","modified_gmt":"2018-05-06T22:34:42","slug":"ldapv3-wire-protocol-reference-add","status":"publish","type":"page","link":"https:\/\/ldap.com\/ldapv3-wire-protocol-reference-add\/","title":{"rendered":"LDAPv3 Wire Protocol Reference: The LDAP Add Operation"},"content":{"rendered":"<p>\n  The LDAP add operation may be used to create a new entry in the directory. Each add operation consists of one request message and one response message.\n<\/p>\n<p><a name=\"add-request\"><\/a><\/p>\n<h3>The Add Request<\/h3>\n<p>\n  <a href=\"https:\/\/docs.ldap.com\/specs\/rfc4511.txt\" target=\"_blank\">RFC 4511<\/a> section 4.7 defines the add request protocol operation as:\n<\/p>\n<pre>AddRequest ::= [APPLICATION 8] SEQUENCE {\n     entry           LDAPDN,\n     attributes      AttributeList }\n\nAttributeList ::= SEQUENCE OF attribute Attribute<\/pre>\n<p>\n  And its dependencies are also defined elsewhere in <a href=\"https:\/\/docs.ldap.com\/specs\/rfc4511.txt\" target=\"_blank\">RFC 4511<\/a> as follows:\n<\/p>\n<pre>LDAPDN ::= LDAPString\n           -- Constrained to &lt;distinguishedName&gt; [RFC4514]\n\nLDAPString ::= OCTET STRING -- UTF-8 encoded,\n              -- [ISO10646] characters\n\nAttribute ::= PartialAttribute(WITH COMPONENTS {\n     ...,\n     vals (SIZE(1..MAX))})\n\nPartialAttribute ::= SEQUENCE {\n     type       AttributeDescription,\n     vals       SET OF value AttributeValue }\n\nAttributeDescription ::= LDAPString\n          -- Constrained to &lt;attributedescription&gt;\n          -- [RFC4512]\n\nAttributeValue ::= OCTET STRING<\/pre>\n<p>\n  This is a lot of dependencies, but basically it means that the add request protocol op is a sequence with BER type <tt>0x68<\/tt> that consists of two elements: one for the entry\u2019s distinguished name and another for the set of attributes.\n<\/p>\n<p>\n  The entry\u2019s DN is encoded as a simple octet string containing the string representation as described in <a href=\"https:\/\/docs.ldap.com\/specs\/rfc4514.txt\" target=\"_blank\">RFC 4514<\/a>. And the set of attributes is encoded as a sequence, in which each element represents a different attribute. Each of those attributes is itself a sequence of two elements: an octet string with the attribute description (the attribute type name or OID, plus zero or more attribute options, each of which is preceded by a semicolon), and a set of octet strings in which each octet string represents a value for the attribute.\n<\/p>\n<p>\n  For example, let\u2019s say that we want to create an add request for the following entry:\n<\/p>\n<pre>dn: dc=example,dc=com\nobjectClass: top\nobjectClass: domain\ndc: example<\/pre>\n<p>\n  The DN would be encoded as a simple octet string, so its encoded representation is:\n<\/p>\n<pre>04 11 64 63 3d 65 78 61 6d 70\n      6c 65 2c 64 63 3d 63 6f\n      6d<\/pre>\n<p>\n  And the sequence of attributes would be encoded as:\n<\/p>\n<pre>30 2f -- Begin the sequence of attributes\n   30 1c -- Begin the sequence for the objectClass attribute\n      04 0b 6f 62 6a 65 63 74 43 6c -- The attribute description\n            61 73 73                -- (octet string \"objectClass\")\n      31 0d -- Begin the set of objectClass values\n         04 03 74 6f 70 -- The first value (octet string \"top\")\n         04 06 64 6f 6d 61 69 6e -- The second value (octet string \"domain\")\n   30 0f -- Begin the sequence for the dc attribute\n      04 02 64 63 -- The attribute description (octet string \"dc\")\n      31 09 -- Begin the set of dc values\n         04 07 65 78 61 6d 70 6c 65 -- The first value (octet string \"example\")<\/pre>\n<p>\n  So a complete add request message for the above entry with message ID two and no controls would look like:\n<\/p>\n<pre>30 49 -- Begin the LDAPMessage sequence\n   02 01 02 -- The message ID (integer value 2)\n   68 44 -- Begin the add request protocol op\n      04 11 64 63 3d 65 78 61 6d 70 -- The DN of the entry to add\n            6c 65 2c 64 63 3d 63 6f -- (octet string \"dc=example,dc=com\")\n            6d\n      30 2f -- Begin the sequence of attributes\n         30 1c -- Begin the first attribute sequence\n            04 0b 6f 62 6a 65 63 74 43 6c -- The attribute description\n    61 73 73                -- (octet string \"objectClass\")\n            31 0d -- Begin the set of values\n 04 03 74 6f 70 -- The first value (octet string \"top\")\n 04 06 64 6f 6d 61 69 6e -- The second value (octet string \"domain\")\n         30 0f -- Begin the second attribute sequence\n            04 02 64 63 -- The attribute description (octet string \"dc\")\n            31 09 -- Begin the set of values\n 04 07 65 78 61 6d 70 6c 65 -- The value (octet string \"example\")<\/pre>\n<p><a name=\"add-response\"><\/a><\/p>\n<h3>The Add Response<\/h3>\n<p>\n  When the server completes processing for an add operation, it will send a single response message. The add response protocol operation is defined in <a href=\"https:\/\/docs.ldap.com\/specs\/rfc4511.txt\" target=\"_blank\">RFC 4511<\/a> section 4.7 as follows:\n<\/p>\n<pre>AddResponse ::= [APPLICATION 9] LDAPResult<\/pre>\n<p>\n  We\u2019ve already discussed the <tt>LDAPResult<\/tt> element in depth in an <a href=\"https:\/\/ldap.com\/ldapv3-wire-protocol-reference-ldap-result\">earlier section<\/a>, so the only operation-specific thing we need to know is the BER type, and for an add response, it\u2019s <tt>0x69<\/tt> (application class, constructed, tag number nine). So the complete LDAP message for an add response with a result code of success, empty matched DN, empty diagnostic message, no referral URLs, and no controls is:\n<\/p>\n<pre>30 0c -- Begin the LDAPMessage sequence\n   02 01 02 -- The message ID (integer value 2)\n   69 07 -- Begin the add response protocol op\n      0a 01 00 -- success result code (enumerated value 0)\n      04 00 -- No matched DN (0-byte octet string)\n      04 00 -- No diagnostic message (0-byte octet string)<\/pre>\n<\/p>\n<table border=\"0\" width=\"100%\">\n<tr>\n<td align=\"left\">Previous: <a href=\"https:\/\/ldap.com\/ldapv3-wire-protocol-reference-abandon\">The LDAP Abandon Operation<\/a><\/td>\n<td align=\"right\">Next: <a href=\"https:\/\/ldap.com\/ldapv3-wire-protocol-reference-bind\">The LDAP Bind Operation<\/a><\/td>\n<\/tr>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>The LDAP add operation may be used to create a new entry in the directory. Each add operation consists of one request message and one response message. The Add Request RFC 4511 section 4.7 defines the add request protocol operation as: AddRequest ::= [APPLICATION 8] SEQUENCE { entry LDAPDN, attributes AttributeList } AttributeList ::= SEQUENCE&hellip; <span class=\"excerpt-more\"><a href=\"https:\/\/ldap.com\/ldapv3-wire-protocol-reference-add\/\">Read More<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"footnotes":""},"tags":[],"class_list":["post-282","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/P9RddA-4y","jetpack_likes_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ldap.com\/wp-json\/wp\/v2\/pages\/282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ldap.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ldap.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ldap.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ldap.com\/wp-json\/wp\/v2\/comments?post=282"}],"version-history":[{"count":3,"href":"https:\/\/ldap.com\/wp-json\/wp\/v2\/pages\/282\/revisions"}],"predecessor-version":[{"id":545,"href":"https:\/\/ldap.com\/wp-json\/wp\/v2\/pages\/282\/revisions\/545"}],"wp:attachment":[{"href":"https:\/\/ldap.com\/wp-json\/wp\/v2\/media?parent=282"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ldap.com\/wp-json\/wp\/v2\/tags?post=282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}