Need help on using userManager.findAuthorizables("jcr:primaryType", "rep:User") in AEM 6.0
Hi All,
We are trying to get the list of users in cq instance to be displayed in a dropdown.
In the servlet code written, we have the below :
final List<String> users = new ArrayList<String>();
Iterator<Authorizable> iter = userManager.findAuthorizables("jcr:primaryType", "rep:User");
while (iter.hasNext()) {
Authorizable auth = iter.next();
users.add(auth.getID());
}
and we are passing this list to the below method, to create a json response.
public JSONArray createJson(List<String> users) {
JSONObject eachOption = null;
JSONArray optionsArray = new JSONArray();
try {
if (users != null && users.size() > 0) {
for (int i = 0; i < users.size(); i++) {
eachOption = new JSONObject();
eachOption.put("text", users.get(i));
eachOption.put("value", users.get(i));
optionsArray.put(eachOption);
}
}
} catch (Exception e) {
LOG.error("createJson() " + e.getMessage());
}
return optionsArray;
}
1] In the response returned for "text" and "value" above we are getting only the email values of users, not the user name.
2] What should be done to get the user names, instead of email values.