Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Provide a way to search in multiple base DNs #636

Open
goto1134 opened this issue Apr 10, 2022 · 2 comments
Open

Provide a way to search in multiple base DNs #636

goto1134 opened this issue Apr 10, 2022 · 2 comments

Comments

@goto1134
Copy link

In my ldap the users are located in DN=(ou=users,dc=example,dc=com), and service accounts in DN=(ou=sa,dc=example,dc=com). The size of LDAP is huge and it is crucial to limit the search scope to these org. units.
But I have the same entity to be retrieved from these ous:

@Entry(objectClasses = ["top", "person", "user"])
class LdapUser {
    @Id
    lateinit var id: Name

    @Attribute(name = "objectGUID", type = Attribute.Type.BINARY)
    lateinit var objectGUID: ByteArray
}

Therefore I have to perform the following code to search for the only record by objectGUID:

val ldapUser = ldapTemplate.find(
    query().base("ou=users").filter(guidFilter),
    LdapUser::class.java
).firstOrNull() ?: ldapTemplate.find(
    query().base("ou=sa").filter(guidFilter),
    LdapUser::class.java
).firstOrNull()

Please, provide a way to search multiple organizational units in one query.

@jzheaux
Copy link
Contributor

jzheaux commented May 30, 2023

@goto1134, thanks for the suggestion. It looks like in your case you are wanting to search for one and then if no results, then search for the other. Others want a union, while others may want duplicates to be resolved in another way.

I think the framework can perform a union of the results. That allows you in your use case to take the first result and others to perform their own de-duping logic.

Are you interested in providing a PR that adds LdapQueryBuilder#base(String...) and changes DefaultLdapClient#search to perform the same search per-base and union the results?

@goto1134
Copy link
Author

@jzheaux , sure, it seems fun for me to contribute to spring.

Yet there are problems I am already facing: I can't build the project due to 401 while trying to retrieve a project dependency.

A problem occurred configuring root project 'spring-ldap'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve io.spring.gradle:spring-io-plugin:0.0.8.RELEASE.
     Required by:
         project :
      > Could not resolve io.spring.gradle:spring-io-plugin:0.0.8.RELEASE.
         > Could not get resource 'https://repo.spring.io/plugins-release/io/spring/gradle/spring-io-plugin/0.0.8.RELEASE/spring-io-plugin-0.0.8.RELEASE.pom'.
            > Could not GET 'https://repo.spring.io/plugins-release/io/spring/gradle/spring-io-plugin/0.0.8.RELEASE/spring-io-plugin-0.0.8.RELEASE.pom'. Received status code 401 from server: 

Could you provide a fix for this issue?

@jzheaux jzheaux added this to the 3.3.x milestone Sep 30, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants