Not yet rated

Problem

By default the Domain Synchronization feature in LiveCycle can only be triggered via explicit UI action or schedule via Cron expression. Not possible to to do it on demand

Solution

The domain synch can be triggered via a remote method invocation using the ServiceClient

Detailed explanation

In a typical LiveCycle (LC) deployment one would create/configure an Enterprise domain which synchronizes the user, group information from an external repository. Using the User Manager (UM) UI you can trigger the synch directly or configure it to be run periodically via a cron exp. This would be sufficient for most requirement.

There may be some case where an Administartor would want to trigger synch in a more controlled way say if the user repository gets updated frequently and such changes are required to be pushed to LC. In that case you can invoke the synch via API exposed in UserManagerUtilService .

 package com.adobe.livecycle.sample;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import com.adobe.idp.um.api.DirectoryManager;
import com.adobe.idp.um.api.UMException;
import com.adobe.idp.um.api.dsc.ManagerBaseDSC;
import com.adobe.idp.um.api.infomodel.DirectorySyncInfo;
import
com.adobe.idp.um.dsc.util.client.UserManagerUtilServiceClient;
import
com.adobe.livecycle.usermanager.client.DirectoryManagerServiceClient;

/**
 * An example demonstrating how to trigger domain synch via API
 */
public class SynchDomainSample{
    
    public static void main(String[] args) throws UMException {
        //Following call are asynchronous and would just schedule a
synch to be triggered in a separate
        //thread
        
        UserManagerUtilServiceClient umutil = new
UserManagerUtilServiceClient(getServiceClientFactory());
        
        //This would schedule a synch for all the domains
configured in LC
        umutil.scheduleSynchronization();
        
        //To schedule a synch for specific domains pass the names
        Set<String> domainNames = new
HashSet<String>();
        domainNames.add("domain1");
        umutil.scheduleSynchronization(domainNames);
        
        DirectoryManager dm = new
DirectoryManagerServiceClient(getServiceClientFactory());
        Map<String, DirectorySyncInfo> synchStatus =
dm.getDirectorySyncStatus(domainNames);
        
        String domainName = "domain1";
        DirectorySyncInfo di = synchStatus.get(domainName);
        if(di.getSyncStatus() ==
DirectorySyncInfo.SYNCSTATUS_COMPLETED){
            System.out.println("Directory synch for domain
"+domainName+" is complete");
        }
    }
    
    private static ServiceClientFactory getServiceClientFactory(){
        //Create -> Configure and return an instance of service
client factory
        //The later call require the user to authenticate
    }
}

Couple of points to note here

  • The API exposed by the UserManagerUtilService are not exposed over WSDL - This was done as some methods use objects which are not suitable to be passed back in web service response
  • The API require authentication to be invoked. The user should have at minimum DSC Invoke permission
  • The method invocation(scheduleSynchronization) are asynchronous and would return immediately. You should use the getDirectorySyncStatus later to check if the domain synch is complete.
  • Refer to the Javadocs for DirectorySynchInfo for details on other synch status.

+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes