Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add LdapClient #696

Merged
merged 1 commit into from
Mar 17, 2023
Merged

Add LdapClient #696

merged 1 commit into from
Mar 17, 2023

Conversation

jzheaux
Copy link
Contributor

@jzheaux jzheaux commented Aug 16, 2022

This PR introduces a new LDAP client that uses a fluent design similar to Spring WebClient.

For example, to perform a search, with LdapOperations, you do:

LdapQuery query = ...;
ContextMapper<T> mapper = ...;
List<T> results = ldap.search(query, mapper);

And with LdapClient, you do:

LdapQuery query = ...;
ContextMapper<T> mapper = ...;
List<T> results = ldap.search().query(query).toList(mapper);

All search functions -- list, listBindings, and search -- ship with both list and stream support.

The DirContext cognates are obvious for most functions. rename, modifyAttributes, and rebind, however, do not have an LdapClient method that matches their name. The reason for this is to keep the API as minimal as possible.

To perform a rename, use modify, like so:

ldap.modify(oldDn).name(newDn).execute()

To perform a modifyAttributes, use modify, like so:

ldap.modify(dn).attributes(modified).execute()

To perform a rebind, use bind and replaceExisting, like so:

ldap.bind(dn).object(context).replaceExisting(true).execute();

Also note that to keep the API concise, ODM support is not added at this point, specifically while #697 is under consideration.

Closes gh-675

@jzheaux jzheaux self-assigned this Aug 16, 2022
Copy link
Member

@sjohnr sjohnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Due to my unfamiliarity (other than occasional skirmishes) with LdapOperations, I can only say that this looks like a pretty dramatic improvement! Great job!

@jzheaux jzheaux force-pushed the ldap-client branch 2 times, most recently from 8f48118 to eadb157 Compare March 17, 2023 16:38
@jzheaux jzheaux added this to the 3.1.0-M1 milestone Mar 17, 2023
@jzheaux jzheaux merged commit de86a00 into spring-projects:main Mar 17, 2023
@jzheaux jzheaux deleted the ldap-client branch March 17, 2023 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add LdapClient
3 participants