# About UserManager sources

**URL:** <https://community.sonatype.com/t/about-usermanager-sources/4688>\
**Category:** Sonatype Nexus Repository\
**Tags:** groovy\
**Created:** [July 24, 2020, 11:30am UTC](https://community.sonatype.com/t/about-usermanager-sources/4688 "2020-07-24T11:30:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tristan107](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/tristan107/32/1211_2.png) [@tristan107](https://community.sonatype.com/u/tristan107)\
**Post date:** [July 24, 2020, 11:30am UTC](https://community.sonatype.com/t/about-usermanager-sources/4688/1 "2020-07-24T11:30:40Z")

</div>

Hi,

I’m trying to list users who have a specific role. I’d like to set the source as well, in case it would make the process shorter.

If I don’t specify any source, it works (but 5s quite long for such a simple query) :

```
import org.sonatype.nexus.security.SecuritySystem
import org.sonatype.nexus.security.user.UserManager
import org.sonatype.nexus.security.user.UserSearchCriteria

SecuritySystem ss = security.getSecuritySystem()

UserSearchCriteria criteria = new UserSearchCriteria()
//criteria.setSource('LDAP')
criteria.setOneOfRoleIds(["my-role-admin"].toSet())
users = ss.searchUsers(criteria)

size = users.size()

log.info("User count: $size")

for (user in users)
{
    log.info("User: $user")
}

```

In the result, I can see all the user source is set to “LDAP”.

So now I launch the task again with `criteria.setSource('LDAP')` and, surprise, there is no exception about not finding the userManager corresponding to “LDAP” source, but the user count is at “0”, what is happening here ? am I using the wrong string for source ? How can I get the “userManagers” map to iterate on keys and see what they are exactly ?

---

<div class="post-metadata">

**Author:** ![mpiggott](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mpiggott](https://community.sonatype.com/u/mpiggott)\
**Post date:** [July 24, 2020, 9:17pm UTC](https://community.sonatype.com/t/about-usermanager-sources/4688/2 "2020-07-24T21:17:24Z")

</div>

The LDAP manager does not page through users, it will retrieve the first X users that match the username search (in this case \*) and check if any have matching roles. If the role is assigned via LDAP group, you should use the LDAP server for determining this information.
