Hi,
We have some services that we use to search to which roles a user belongs to.
String searchName = "a";
String directoryServiceName = "system";
//String directoryServiceName = "LDAP";
int maxResults = 100;
IDirectorySession session = DirectorySystemFactory.getDirectorySystem().createSession();
List<IDirectoryService> serviceList = session.listDirectoryServices();
String directoryId ="";
for(int i=0; i<serviceList.size(); i++){
IDirectoryService serv = (IDirectoryService)serviceList.get(i);
if(serv.getName().equals(directoryServiceName)) {
directoryId = serv.getID();
}
}
IDirectoryPagingCookie cookie = session.createPagingCookie(directoryId);
cookie.setPageSize(maxResults+1);
cookie.setStart(1);
DirectorySearchQuery searchQuery = new DirectorySearchQuery("*" + searchName + "*", maxResults + 1, null);
List<IDirectoryPrincipal> principalList = session.searchDirectory(directoryId, IDirectoryPrincipal.TYPE_USER, searchQuery, cookie);
log("principalList.size(): "+principalList.size());
When directoryServiceName is LDAP the search returns the users correcly, but for directoryServiceName=system no user is returned.
Even if we have manually created users in the MWS > Administration > Roles GUI.
Can you please tell us what is wrong in this sample code. I could not find on the SAG documentation clear samples of searches.
br,
Vlad