How to Sync VMware Identity Manager via API in Automation Orchestrator

There is a challenge when you connect your Identity Manager to the Active Directory as Directory Service, and that is the delay of syncing by Identity Manager.

The minimum frequency to sync is 15 minutes and in some case is too late

Because of that I decided to prepare a workflow to sync the Directory Service after my deployment.

So via Add Rest Host workflow I added the rest host

Then Via Workflow Add Rest Operation, I added an operation to the rest host, the url to get a token is : /SAAS/API/1.0/REST/auth/system/login

So I need first to find out what is the Id of Directory Service, this can be done easily with developer tools when you go to the related section in identity manager administration console:

URL: /SAAS/jersey/manager/api/connectormanagement/directoryconfigs/[DirectoryServiceID]/syncprofile/sync’

contentType: application/vnd.vmware.horizon.manager.connector.management.directory.sync.profile.sync+json

Then I created the workflow to sync first I run prepare the body for the Invoke a Rest Operation workflow which contains username and password.

after providing the inputs for theinvoke a Rest Operation which is rest operation (IDM-Get-Token), I will export the token

The last step is to execute the API call to syncronize the Directory Service, so I add a scriptable task, I just managed to pass the sessionToken from the previous scriptable task to this one:

var requestTemplateUrl = “/SAAS/jersey/manager/api/connectormanagement/directoryconfigs/{directory service id}/syncprofile/sync”
var requestHostUrl = “https://{idmurl}”
var requestMethod = “POST”
var requestBody = { “ignoreSafeguards”:”false” }
var requestContentType = “application/vnd.vmware.horizon.manager.connector.management.directory.sync.profile.sync+json”;
var acceptHeader = “application/vnd.vmware.horizon.v1.0+json”
var logResponseOutput = true
var closeConnection = true

var restHost = RESTHostManager.createHost(“dynamicRequest”);
httpRestHost = RESTHostManager.createTransientHostFrom(restHost);
httpRestHost.operationTimeout = 60;
httpRestHost.connectionTimeout = 30;
httpRestHost.hostVerification = false;
httpRestHost.url = requestHostUrl;

var request = httpRestHost.createRequest(requestMethod, requestTemplateUrl, JSON.stringify(requestBody));
request.setHeader(“Accept”, acceptHeader)
request.setHeader(“Content-Type”, requestContentType)
request.setHeader(“Authorization”, sessionToken)
var response = request.execute();

System.log(“REST Request: ” + requestMethod + ” ” + request.fullUrl );
responseAsString = response.contentAsString;
System.log(“REST Response Content: ” + responseAsString);

Leave a Reply

Your email address will not be published. Required fields are marked *

+ 27 = 35