Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,7 @@ private DirContextOperations searchForUser(DirContext context, String username)
String bindPrincipal = createBindPrincipal(username);
String searchRoot = (this.rootDn != null) ? this.rootDn : searchRootFromPrincipal(bindPrincipal);
SingleContextSource contextSource = new SingleContextSource(context);
LdapClient ldapClient = LdapClient.builder()
.contextSource(contextSource)
LdapClient ldapClient = LdapClient.withContextSource(contextSource)
.defaultSearchControls(() -> searchControls)
.ignorePartialResultException(true)
.build();
Expand All @@ -315,11 +314,10 @@ private DirContextOperations searchForUser(DirContext context, String username)
.base(searchRoot)
.searchScope(SearchScope.SUBTREE)
.filter(this.searchFilter, bindPrincipal, username);
DirContextOperations result = ldapClient.search().query(query).toEntry();
if (result == null) {
throw new IncorrectResultSizeDataAccessException(1, 0);
}
return result;
return ldapClient.search()
.query(query)
.<DirContextOperations>optional()
.orElseThrow(() -> new IncorrectResultSizeDataAccessException(1, 0));
}
Comment on lines -318 to 321

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A good case of this is the API update in Spring LDAP.

catch (CommunicationException ex) {
throw badLdapConnection(ex);
Expand Down
Loading