Skip to content

Edit Operation JSON Body Syntax

Mike Garvey edited this page Apr 21, 2022 · 8 revisions

This guide demonstrates the syntax necessary for performing an edit operation on an Active Directory object using the /edit endpoint.

The base JSON body syntax looks like:

{
  "dn": "<DN of object to edit>",
  "edits": {
    // any edit operation keywords
  }
}

The edits JSON object can have any combination of the following edit keywords added.

Add

Indicates to add the specified value(s) to designated attributes. No existing values are overwritten using this.

Add accepts a JSON object of property/value pairs.

EXAMPLE

{
  "dn": "CN=John Doe,DC=contoso,DC=com",
  "edits": {
    "add": {
      "proxyAddresses": [
        "smtp:additionalemail@thisplace.com",
        "smtp:anotheremail@wherever.com"
      ]
    }
}

Clear

Indicates to remove ALL values from a property value collection (e.g. - ProxyAddresses).

Clear can accept a single string value or be a JSON arrays of property names.

EXAMPLE 1

{
  "dn": "CN=John Doe,DC=contoso,DC=com",
  "edits": {
    "clear": "proxyAddresses"
  }
}

EXAMPLE 2

{
  "dn": "CN=John Doe,DC=contoso,DC=com",
  "edits": {
    "clear": [
      "description",
      "proxyAddresses"
    ]
  }
}

Remove

Indicates to remove only the specified values from the designated properties of an Active Directory object.

Remove accepts a JSON object of property JSON objects where each property of said object matches an existing value that is to be removed.

EXAMPLE 1

{
  "dn": "CN=John Doe,DC=contoso,DC=com",
  "edits": {
    "remove": {
      "proxyAddresses": "smtp:badaddress@smtp.com"
    }
  }
}

EXAMPLE 2

{
  "dn": "CN=John Doe,DC=contoso,DC=com",
  "edits": {
    "remove": {
      "proxyAddresses": [
        "smtp:badaddress@smtp.com",
        "smtp:anotherbadaddress@smtp.com"
      ]
    }
  }
}

Replace

Indicates that the specified properties should have their existing values replaced with new ones.

Replace accepts a JSON object of property JSON objects where each property of said object matches an existing value with the JSON value being the replacement.

EXAMPLE

{
  "dn": "CN=John Doe,DC=contoso,DC=com",
  "edits": {
    "replace": {
      "proxyAddresses": {
        "smtp:badaddress@smtp.com": "smtp:goodaddress@smtp.com"
      }
  }
}

Set

Indicates to replace ALL values of the designated properties with a replacement set.

Set accepts an JSON object of additional JSON objects whose key is the LDAP attribute name. The values for each object can be either a single int or string value or an array of values.

EXAMPLE 1

{
  "dn": "CN=John Doe,DC=contoso,DC=com",
  "edits": {
    "set": {
      "proxyAddresses": "smtp:badaddress@smtp.com"
    }
  }
}

EXAMPLE 2

{
  "dn": "CN=John Doe,DC=contoso,DC=com",
  "edits": {
    "set": {
      "proxyAddresses": [
        "smtp:badaddress@smtp.com",
        "smtp:anotherbadaddress@smtp.com"
      ]
    }
  }
}

Order of Operations

When specifying multiple operation keywords together in a single request, each operation will be executed in the following order:

  1. Set
  2. Remove
  3. Add
  4. Replace
  5. Clear

Clone this wiki locally