Mapping a Resource — Service Connector API Example (Java)
Example code is provided that illustrates mapping an existing resource using method calls available in the Service Connector API.
The step numbers in the comments correspond to the steps in the illustration, Mapping a User.
public XmlResourceDetail mappingUsers(int aModelVersion) throws DirectoryEngineFault, SecurityFault { // Step 1: get details of all model entities in given major version GetOrgModelResponse model = getOrgModelService().getOrgModel(aModelVersion, false); // Step 2: get details of all configured LDAP Containers XmlContainer[] ldapContainers = getDirectoryService().listContainers(); // select an LDAP Container XmlContainer ldapContainer = ldapContainers[0]; // Step 3: get list of candidates from selected LDAP Container ListCandidateResourcesResponse candidates = getDirectoryService().listCandidateResources(ldapContainer.getId(), XmlCandidateChoice.NON_EXISTING); // select a candidate XmlResourceCandidate candidate = candidates.getCandidateArray(0); // Step 4: create new resource for selected candidate Candidate[] newResources = { Candidate.Factory.newInstance() }; newResources[0].setName(candidate.getName()); newResources[0].setContainerId(ldapContainer.getId()); newResources[0].setLdapAlias(candidate.getLdapAlias()); newResources[0].setLdapDn(candidate.getLdapDn()); newResources[0].setSecondaryRefArray(candidate.getSecondaryRefArray()); CreateResourceResponse resourceDetail = getOrgResourceService().createResource(newResources); // select a position, group, etc. from model XmlPosition position = model.getOrganizationArray(0).getOrgUnitArray(0).getPositionArray(0); // Step 5: map resource to selected position XmlUpdateResourceType[] update = { XmlUpdateResourceType.Factory.newInstance() }; update[0].setGuid(resourceDetail.getEntityArray(0).getGuid()); update[0].addNewAddPosition().setGuid(position.getGuid()); XmlResourceDetail[] response = getOrgResourceService().updateResource(update); return(response[0]); }
Copyright © Cloud Software Group, Inc. All rights reserved.