Skip to content

DefaultLdapAuthoritiesPopulator does not provide all authorities if pagination is enforced on LDAP Server #14741

Open
@mayur9991

Description

@mayur9991

Describe the bug
DefaultLdapAuthoritiesPopulator does not provide a way to fetch all authorities belonging to the user if pagination is enforced on the LDAP Server.

We have a use-case where, on the LDAP server, users are mapped to 1000+ groups. Size limit is enforced, which can fetch 500 records at a time. Refer to OpenLDAP limits.

DefaultLdapAuthoritiesPopulator uses SpringSecurityLdapTemplate, and a search with the default NullDirContextProcessor is triggered. See the code sample below from DefaultLdapAuthoritiesPopulator.

Set<Map<String, List<String>>> userRoles = getLdapTemplate().searchForMultipleAttributeValues(

The search call on LdapTemplate should be made with DirContextProcessor.

The default value could be NullDirContextProcessor for DirContextProcessor, but whoever wants to use a paginated one can customize it and use PagedResultsDirContextProcessor.

To Reproduce
Add 1000+ groups in LDAP and assign any user to all these groups. Make sure to set the limit as 500 on the LDAP. Now, when DefaultLdapAuthoritiesPopulator is used along with LdapAuthenticationProvider, only the first 500 groups are fetched.

Expected behavior
DefaultLdapAuthoritiesPopulator should provide a way to customize DirContextProcessor, and that should be used with SpringSecurityLdapTemplate.

Metadata

Metadata

Assignees

Labels

in: ldapAn issue in spring-security-ldaptype: enhancementA general enhancement

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions