Local AD Integration with ServiceNow using Rest Api Integration (without plugin)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 02:54 AM
Hello All,
I am trying to integrate a Local AD with ServiceNow via REST Integration without using the plugin.
Can anyone please provide me with an Integration guide or step wise configurations for the same?
Any quick help is much appreciated
Thanks,
Pranita Bahuguni

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 04:23 AM - edited 01-09-2023 06:08 AM
To integrate a local AD with ServiceNow via REST integration without using a plugin, you can follow these steps:
Set up a REST integration in ServiceNow to connect to the local AD.
In the REST Integration form, provide a name and description for the integration, and select "Active Directory" as the type.
In the "Endpoint" field, enter the URL for the local AD server. This will typically be in the form "http://<server_name>:<port>".
In the "Authentication" section, select "Basic" as the authentication type and provide the username and password for a user with access to the local AD.
In the "HTTP Headers" section, add a header with the name "Authorization" and the value "Basic <base64_encoded_credentials>", where "base64_encoded_credentials" is the base64-encoded version of the username and password separated by a colon (e.g. "username:password").
Click "Submit" to save the REST integration.
Next, create a script include to handle the authentication and querying of the local AD.
// Function to authenticate with the local AD and retrieve user information
function getUserInfo(username) {
// Get the REST integration record
var restInt = new GlideRecord('x_<your_company_name>_ad_integration');
restInt.get('<your_rest_integration_sys_id>'); // Replace with the sys_id of the REST integration you created
// Set up the HTTP request to the local AD
var request = new sn_ws.RESTMessageV2();
request.setEndpoint(restInt.endpoint.getValue());
request.setBasicAuth(restInt.username
Kindly mark the response as Correct or Helpful.
Cheers,
Anish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 05:33 AM
Hi @Anish Reghu
Thankyou for your quick response.
Below are my few queries:
But I could not find "System Web Services > Outbound > REST Integrations"
If you are referring to System Web Services > Outbound> REST Message i also couldn't find "Active Directory" as the type field.
Can you please also let me know in this URL http://<server_name>:<port>" what would be the port we should be requesting the client to provide.
Also if we have added Authentication credentials as Basic Auth credentials and have selected the added credentials then do we need to add the "HTTP Headers" section details?
And cant we use directly GET method instead of creating the Script Include?
Thanks,
Pranita Bahuguni

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 06:12 AM
//Using the GET method
var restMessage = new sn_ws.RESTMessageV2('Get Incidents', 'get');
restMessage.setEndpoint('/api/now/table/incident');
// Set any desired query parameters
restMessage.setQueryParameter('sysparm_limit', '10');
restMessage.setQueryParameter('active', 'true');
// Send the request and get the response
var response = restMessage.execute();
// Get the response body and status code
var responseBody = response.getBody();
var statusCode = response.getStatusCode();
// Log the response
gs.log(responseBody);
You can then use the JSON.parse() method to parse the response body and access the data as needed.
var incidents = JSON.parse(responseBody).result;
incidents.forEach(function(incident) {
gs.log(incident.number + ': ' + incident.short_description);
});
Kindly mark the response as Correct or Helpful.
Cheers,
Anish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 06:15 AM
And yes,
You are correct, there is no "Active Directory" type in the REST message. The type that you select in the REST message depends on the service or API that you are trying to invoke.
If you are trying to invoke an Active Directory service or API using the REST message, then you would need to select the appropriate type based on the protocol and data format used by the service or API. For example, if the Active Directory service or API uses the HTTP protocol and the JSON data format, then you would select the "JSON" type in the REST message.
Kindly mark the response as Correct or Helpful.
Cheers,
Anish