Getting All users from LDAP

I am trying to get a list of all LDAP users.

I have the following code, but it only give me users who are members in plone groups

            groups_tool = getToolByName(context, 'portal_groups')  #gives users only in plone groups
            groups = acl_users.source_groups.getGroupIds()
            for group_id in groups:
                print  str("group="+group_id)
                group = groups_tool.getGroupById(group_id)
                if group is None:
                members = group.getGroupMembers()
                for m in members:
                    member_email = m.getProperty('email')
                    #print member_email +"\n"
                #print str(len(member_emails))

I know I can get an LDAP user with the following code even if they don't exist in Plone
member = context.acl_users.getUserById(someid)

I still can figure out how to get a list of all LDAP users. Can someone point me in the right direction? Thanks

The LDAP plugin must be registered as user enumeration plugin which is usually a bad idea for large LDAP trees.
Your LDAP administrator unlikely wants this.


Our LDAP is not huge. So Lets say the ldap plugin is registered, How do I get a list of all the users?

You need to check the interface definition for user enumeration plugins in PlonePAS or CMFCore.

Likely something like acl_user.getUserNames() or getUsers()

That only gives Plone users, not ldap users

We're having the same issue with ldap, and plone also doesn't help by breaking rather than failing gracefully. Sadly getUsers breaks too for us using pas.plugins.ldap. I don't know if any better libraries exist.