The Check_LDAP_Object method is used to check whether an LDAP object with a specified Distinguished Name (DN) exists in the LDAP directory.

Required Parameters:

dn (String): The Distinguished Name (DN) of the object you want to check for existence in the LDAP directory.

Returns a Boolean: true if the object exists, and false if the object does not exist or if there is an error.


import requests
import json

# Define the method and parameters
method = 'Check_LDAP_Object'
params = {
    'dn': 'cn=jane doe,cn=users,dc=rcdevsdocs,dc=com'
}

# Create the request payload
request_payload = {
    'jsonrpc': "2.0",
    'method': method,
    'params': params,
    'id': 0
}

# Convert payload to JSON
json_payload = json.dumps(request_payload)

# Define the URL and credentials
url = "https://webadm1.rcdevsdocs.com/manag/"
auth = ("RCDEVSDOCS\\administrator", "password")

# Define the headers
headers = {
    "Content-Type": "application/json",
    "Connection": "close"
}

# Make the POST request
response = requests.post(url, data=json_payload, headers=headers, auth=auth, verify=False)

# Print the HTTP response code and response content
print(f"HTTP response code: {response.status_code}")
print(response.json())
    

<?php
#!/bin/php
$method = 'Check_LDAP_Object';
$params = array(
    'dn' => 'cn=jane doe,cn=users,dc=rcdevsdocs,dc=com'
);

$request = array(
    'jsonrpc' => "2.0",
    'method' => $method,
    'params' => $params,
    'id' => 0
);
$json = json_encode($request);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://webadm1.rcdevsdocs.com/manag/");
curl_setopt($ch, CURLOPT_USERPWD, "RCDEVSDOCS\\administrator:password");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("connection: close"));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$out = curl_exec($ch);
curl_close($ch);

print_r(json_decode($out));
?>
    

$method = 'Check_LDAP_Object'
$params = @{
    dn = 'cn=jane doe,cn=users,dc=rcdevsdocs,dc=com'
}

$request = @{
    jsonrpc = "2.0"
    method = $method
    params = $params
    id = 0
}

$json = $request | ConvertTo-Json

$headers = @{
    "Content-Type" = "application/json"
    "Connection" = "close"
}

# Define credentials
$credentials = New-Object System.Management.Automation.PSCredential ("RCDEVSDOCS\administrator", (ConvertTo-SecureString "password" -AsPlainText -Force))

# Send the POST request
$response = Invoke-RestMethod -Uri "https://webadm1.rcdevsdocs.com/manag/" -Method Post -Body $json -Headers $headers -Credential $credentials -SkipCertificateCheck

# Print the response
Write-Host "HTTP response: $($response | ConvertTo-Json)"