Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- LdapLoginManagement_o.java 2014-09-02 00:19:18.000000000 +0600
- +++ LdapLoginManagement.java 2014-09-25 17:27:07.036366000 +0600
- @@ -29,6 +29,7 @@
- import java.util.Properties;
- import java.util.Set;
- +import org.apache.directory.api.ldap.model.cursor.CursorLdapReferralException;
- import org.apache.directory.api.ldap.model.cursor.EntryCursor;
- import org.apache.directory.api.ldap.model.entry.Attribute;
- import org.apache.directory.api.ldap.model.entry.Entry;
- @@ -250,17 +251,21 @@
- String searchQ = String.format(config.getProperty(CONFIGKEY_LDAP_SEARCH_QUERY, "%s"), user);
- SearchScope scope = SearchScope.valueOf(config.getProperty(CONFIGKEY_LDAP_SEARCH_SCOPE, SearchScope.ONELEVEL.name()));
- EntryCursor cursor = conn.search(baseDn, searchQ, scope, "*");
- - while (cursor.next()) {
- - if (userDn != null) {
- - log.error("more than 1 user found in LDAP");
- - throw new OmException(-1L);
- + try {
- + while (cursor.next()) {
- + Entry e = cursor.get();
- + if (userDn != null) {
- + log.error("more than 1 user found in LDAP");
- + throw new OmException(-1L);
- + }
- + userDn = e.getDn();
- + log.debug(userDn.toString());
- + if (useAdminForAttrs) {
- + entry = e;
- + }
- }
- - Entry e = cursor.get();
- - userDn = e.getDn();
- - if (useAdminForAttrs) {
- - entry = e;
- - }
- - }
- + } catch(CursorLdapReferralException e) {
- + }
- cursor.close();
- if (userDn == null) {
- log.error("NONE users found in LDAP");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement