Creating an LDAP Container Using an LDAP Query Source— Service Connector API Example (Java)
A Java API example is provided of creating an LDAP container using a query source.
The following example code illustrates creating an LDAP container using an LDAP Query Source with method calls available in the Service Connector API. The step numbers in the comments correspond to the steps in the illustration, Creating an LDAP Container Using an LDAP Query Source.
public class ServiceExamples { private DEComponent deComponent; private DirectoryService getDirectoryService() { return(deComponent.getDirectoryService()); } private OrgModelService getOrgModelService() { return(deComponent.getOrgModelService()); } private OrgResourceService getOrgResourceService() { return(deComponent.getOrgResourceService()); } public long createLdapContainer(String aContainerName, String aDescription) throws DirectoryEngineFault, SecurityFault { // Step 1: get list of available LDAP Connections LdapConnection[] connections = getDirectoryService().listLdapConnections(); // Step 2: retrieve names attributes from a select LDAP Connection String alias = connections[0].getLdapAlias(); String baseDn = null; String filter = "(objectClass=person)"; ListAttributeNamesResponse attributes = getDirectoryService().listAttributeNames(alias, baseDn, filter, 0); // Step 3: build an LDAP Container XmlLdapQuerySource primaryLdap = XmlLdapQuerySource.Factory.newInstance(); primaryLdap.setLdapAlias(alias); primaryLdap.setLdapQuery(filter); primaryLdap.setResourceNameAttributes(attributes.getAttributeArray(0).getName()); primaryLdap.setBaseDn(baseDn); long containerId = getDirectoryService().saveContainer(aContainerName, aDescription, primaryLdap, null, null); return(containerId); }
Copyright © Cloud Software Group, Inc. All rights reserved.