use of org.opends.server.protocols.internal.InternalSearchOperation in project OpenAM by OpenRock.
the class SMSEmbeddedLdapObject method getSubEntries.
private Set<String> getSubEntries(SSOToken token, String dn, String filter, int numOfEntries, boolean sortResults, boolean ascendingOrder) throws SMSException, SSOException {
// Get the sub entries
try {
SearchRequest request = Requests.newSearchRequest(dn, SearchScope.SINGLE_LEVEL, filter, orgUnitAttr.toArray(new String[orgUnitAttr.size()]));
InternalSearchOperation iso = icConn.processSearch(request);
ResultCode resultCode = iso.getResultCode();
if (resultCode == ResultCode.NO_SUCH_OBJECT) {
if (debug.messageEnabled()) {
debug.message("SMSEmbeddedLdapObject.getSubEntries(): " + "entry not present:" + dn);
}
} else if (resultCode == ResultCode.SIZE_LIMIT_EXCEEDED) {
if (debug.messageEnabled()) {
debug.message("SMSEmbeddedLdapObject.getSubEntries: " + "size limit " + numOfEntries + " exceeded for " + "sub-entries: " + dn);
}
} else if (resultCode != ResultCode.SUCCESS) {
if (debug.warningEnabled()) {
debug.warning("SMSEmbeddedLdapObject.getSubEntries: " + "Unable to search for " + "sub-entries: " + dn);
}
throw new SMSException("", "sms-entry-cannot-search");
}
// Construct the results and return
Set<String> answer = new LinkedHashSet<>();
LinkedList searchResult = iso.getSearchEntries();
for (Iterator iter = searchResult.iterator(); iter.hasNext(); ) {
SearchResultEntry entry = (SearchResultEntry) iter.next();
String edn = entry.getName().toString();
if (!edn.toLowerCase().startsWith("ou=")) {
continue;
}
String rdn = entry.getName().getRDN(0).getAttributeValue(0).toString();
answer.add(rdn);
}
if (debug.messageEnabled()) {
debug.message("SMSEmbeddedLdapObject.getSubEntries: " + "Successfully obtained sub-entries for : " + dn);
}
return answer;
} catch (DirectoryException dex) {
if (debug.warningEnabled()) {
debug.warning("SMSEmbeddedLdapObject.getSubEntries: " + "Unable to search for " + "sub-entries: " + dn, dex);
}
throw new SMSException(dex, "sms-entry-cannot-search");
}
}
use of org.opends.server.protocols.internal.InternalSearchOperation in project OpenAM by OpenRock.
the class SMSEmbeddedLdapObject method searchSubOrganizationNames.
private Set<String> searchSubOrganizationNames(String dn, String filter, int numOfEntries, boolean sortResults, boolean ascendingOrder, boolean recursive) throws SMSException, SSOException {
SearchScope scope = (recursive) ? SearchScope.WHOLE_SUBTREE : SearchScope.SINGLE_LEVEL;
InternalSearchOperation iso = searchObjects(dn, filter, scope, numOfEntries, sortResults, ascendingOrder);
ResultCode resultCode = iso.getResultCode();
if (resultCode == ResultCode.NO_SUCH_OBJECT) {
if (debug.messageEnabled()) {
debug.message("SMSEmbeddedLdapObject." + "searchSubOrganizationNames: suborg not present:" + dn);
}
} else if (resultCode == ResultCode.SIZE_LIMIT_EXCEEDED) {
if (debug.messageEnabled()) {
debug.message("SMSEmbeddedLdapObject." + "searchSubOrganizationNames: size limit exceeded. " + "numOfEntries = " + numOfEntries + ", dn = " + dn);
}
} else if (resultCode != ResultCode.SUCCESS) {
if (debug.warningEnabled()) {
debug.warning("SMSEmbeddedLdapObject." + "searchSubOrganizationNames: Unable to search. dn = " + dn + ", filter = " + filter + ", resultCode = " + resultCode);
}
throw new SMSException("", "sms-suborg-cannot-search");
}
Set<String> answer = new LinkedHashSet<>();
for (SearchResultEntry entry : iso.getSearchEntries()) {
String edn = entry.getName().toString();
answer.add(edn);
}
if (debug.messageEnabled()) {
debug.message("SMSEmbeddedLdapObject.searchSubOrganizationName: " + "Successfully obtained suborganization names for : " + dn);
debug.message("SMSEmbeddedLdapObject.searchSubOrganizationName: " + "Successfully obtained suborganization names : " + answer.toString());
}
return answer;
}
use of org.opends.server.protocols.internal.InternalSearchOperation in project OpenAM by OpenRock.
the class SMSEmbeddedLdapObject method searchObjects.
private InternalSearchOperation searchObjects(String startDN, String filter, SearchScope scope, int numOfEntries, boolean sortResults, boolean ascendingOrder) throws SSOException, SMSException {
// sorting is not implemented
try {
// Get the sub entries
SearchRequest request = Requests.newSearchRequest(startDN, scope, filter);
request.setSizeLimit(numOfEntries);
InternalSearchOperation iso = icConn.processSearch(request);
return iso;
} catch (DirectoryException dex) {
if (debug.warningEnabled()) {
debug.warning("SMSEmbeddedLdapObject.searchObjects: " + "Unable to " + "search. startDN = " + startDN + ", filter = " + filter, dex);
}
throw new SMSException(dex, "sms-error-in-searching");
}
}
use of org.opends.server.protocols.internal.InternalSearchOperation in project midpoint by Evolveum.
the class TestSanity method test049DeleteUser.
/**
* The user should have an account now. Let's try to delete the user. The
* account should be gone as well.
*
* @throws JAXBException
*/
@Test
public void test049DeleteUser() throws SchemaException, FaultMessage, DirectoryException, JAXBException {
TestUtil.displayTestTile("test049DeleteUser");
// GIVEN
assertNoRepoCache();
// WHEN
OperationResultType result = deleteObjectViaModelWS(ObjectTypes.USER.getTypeQName(), USER_JACK_OID);
// THEN
assertNoRepoCache();
displayJaxb("deleteObject result", result, SchemaConstants.C_RESULT);
TestUtil.assertSuccess("deleteObject has failed", result);
// User should be gone from the repository
OperationResult repoResult = new OperationResult("getObject");
try {
repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult);
AssertJUnit.fail("User still exists in repo after delete");
} catch (ObjectNotFoundException e) {
// This is expected
}
// Account shadow should be gone from the repository
repoResult = new OperationResult("getObject");
try {
repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult);
AssertJUnit.fail("Shadow still exists in repo after delete");
} catch (ObjectNotFoundException e) {
// This is expected, but check also the result
AssertJUnit.assertFalse("getObject failed as expected, but the result indicates success", repoResult.isSuccess());
}
// Account should be deleted from LDAP
InternalSearchOperation op = openDJController.getInternalConnection().processSearch("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, DereferencePolicy.NEVER_DEREF_ALIASES, 100, 100, false, "(uid=" + USER_JACK_LDAP_UID + ")", null);
AssertJUnit.assertEquals(0, op.getEntriesSent());
}
use of org.opends.server.protocols.internal.InternalSearchOperation in project midpoint by Evolveum.
the class TestSanityLegacy method test049DeleteUser.
/**
* The user should have an account now. Let's try to delete the user. The
* account should be gone as well.
*
* @throws JAXBException
*/
@Test
public void test049DeleteUser() throws SchemaException, FaultMessage, DirectoryException, JAXBException {
TestUtil.displayTestTile("test049DeleteUser");
// GIVEN
assertNoRepoCache();
// WHEN
OperationResultType result = deleteObjectViaModelWS(ObjectTypes.USER.getTypeQName(), USER_JACK_OID);
// THEN
assertNoRepoCache();
displayJaxb("deleteObject result", result, SchemaConstants.C_RESULT);
TestUtil.assertSuccess("deleteObject has failed", result);
// User should be gone from the repository
OperationResult repoResult = new OperationResult("getObject");
try {
repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult);
AssertJUnit.fail("User still exists in repo after delete");
} catch (ObjectNotFoundException e) {
// This is expected
}
// Account shadow should be gone from the repository
repoResult = new OperationResult("getObject");
try {
repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult);
AssertJUnit.fail("Shadow still exists in repo after delete");
} catch (ObjectNotFoundException e) {
// This is expected, but check also the result
AssertJUnit.assertFalse("getObject failed as expected, but the result indicates success", repoResult.isSuccess());
}
// Account should be deleted from LDAP
InternalSearchOperation op = openDJController.getInternalConnection().processSearch("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, DereferencePolicy.NEVER_DEREF_ALIASES, 100, 100, false, "(uid=" + USER_JACK_LDAP_UID + ")", null);
AssertJUnit.assertEquals(0, op.getEntriesSent());
}
Aggregations