Delete directory object
Deletes a directory object.
DELETE ~/api/directoryObjects?<parameters>
Query parameters
-
Name
-
Required
-
Type
-
Description
-
directoryobject
-
True
-
string
-
The identifier of the directory object to delete. An object can be identified by:
Distinguished name (DN) {.black}
# Example CN=John Smith,CN=Users,DC=example,DC=com
Globally unique identifier (GUID) {.black}
# Example 7a4267ce-d354-44e7-8bd6-c681f1284a41
Security identifier (SID) {.black}
# Example S-1-5-21-3635565734-1729062999-1822655016-1627
Request headers
-
Name
-
Required
-
Description
-
Adm-Authorization
-
True
-
Specify the security token obtained during authentication.
Request body
Do not send a body with this request.
Responses
If successful, returns 200 OK
status code and an operation result in the response body. Otherwise, returns one of the common HTTP error codes and an error description in the response body.
Examples
Delete a user
The following code sample deletes a user account.
Request
- PowerShell
-
Add-Type -AssemblyName System.Web $userIdentifier = [System.Web.HttpUtility]::UrlEncode("CN=John Smith,CN=Users,DC=example,DC=com") $baseUrl = "https://host.example.com/restApi" $endpoint = "/api/directoryObjects" $requestParams = "?directoryobject=$userIdentifier" $requestUrl = $baseUrl + $endpoint + $requestParams $requestHeaders = @{"Adm-Authorization"="HxtdAPz73OFfae7....w7lQvxjJHIbVqgkCtPtLD"} # Make request Invoke-RestMethod -Method DELETE -Headers $requestHeaders -Uri $requestUrl
- C#
-
using System; using System.Net.Http; using System.Threading.Tasks; class Program { static async Task Main() { const string userIdentifier = "CN=John Smith,CN=Users,DC=example,DC=com"; const string token = "HxtdAPz73OFfae7....w7lQvxjJHIbVqgkCtPtLD"; UriBuilder requestUrl = new UriBuilder( "https://host.example.com/restApi/api/directoryObjects"); requestUrl.Query += $"?directoryObject={userIdentifier}"; // Initialize HTTP client using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Add("Adm-Authorization", token); // Make request HttpResponseMessage response = await client.DeleteAsync(requestUrl.ToString()); string responseBody = response.Content.ReadAsStringAsync().Result; Console.WriteLine(responseBody); } } }
- cURL
-
curl --header 'Adm-Authorization: HxtdAPz73OFfae7....w7lQvxjJHIbVqgkCtPtLD' \ --get -X DELETE 'https://host.example.com/restApi/api/directoryObjects' \ --data-urlencode 'directoryobject=CN=John Smith,CN=Users,DC=example,DC=com'
- node.js
-
var userIdentifier = "CN=John Smith,CN=Users,DC=example,DC=com"; var https = require('https'); // Request parameters and headers var requestPath = "/restApi/api/directoryObjects" + `?directoryobject=${userIdentifier}`; var options = { 'method': 'DELETE', 'hostname': 'host.example.com', 'path': encodeURI(requestPath), 'headers': { 'Adm-Authorization': 'HxtdAPz73OFfae7....w7lQvxjJHIbVqgkCtPtLD' } }; // Make request var req = https.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function (chunk) { var body = Buffer.concat(chunks); console.log(body.toString()); }); res.on("error", function (error) { console.error(error); }); }); req.end();
Response
HTTP Status code: 200 OK
Response body:
{
"resultType": 0,
"innerMessages": [],
"exception": null,
"actualObjectDN": "CN=John Smith,CN=Users,DC=example,DC=com",
"extraInfo": {}
}