Advertisement
Guest User

Untitled

a guest
Sep 26th, 2014
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.57 KB | None | 0 0
  1. --- LdapLoginManagement_o.java  2014-09-02 00:19:18.000000000 +0600
  2. +++ LdapLoginManagement.java    2014-09-25 17:27:07.036366000 +0600
  3. @@ -29,6 +29,7 @@
  4.  import java.util.Properties;
  5.  import java.util.Set;
  6.  
  7. +import org.apache.directory.api.ldap.model.cursor.CursorLdapReferralException;
  8.  import org.apache.directory.api.ldap.model.cursor.EntryCursor;
  9.  import org.apache.directory.api.ldap.model.entry.Attribute;
  10.  import org.apache.directory.api.ldap.model.entry.Entry;
  11. @@ -250,17 +251,21 @@
  12.                     String searchQ = String.format(config.getProperty(CONFIGKEY_LDAP_SEARCH_QUERY, "%s"), user);
  13.                     SearchScope scope = SearchScope.valueOf(config.getProperty(CONFIGKEY_LDAP_SEARCH_SCOPE, SearchScope.ONELEVEL.name()));
  14.                     EntryCursor cursor = conn.search(baseDn, searchQ, scope, "*");
  15. -                   while (cursor.next()) {
  16. -                       if (userDn != null) {
  17. -                           log.error("more than 1 user found in LDAP");
  18. -                           throw new OmException(-1L);
  19. +                   try {
  20. +                       while (cursor.next()) {
  21. +                           Entry e = cursor.get();
  22. +                           if (userDn != null) {
  23. +                               log.error("more than 1 user found in LDAP");
  24. +                               throw new OmException(-1L);
  25. +                           }
  26. +                           userDn = e.getDn();                        
  27. +                           log.debug(userDn.toString());
  28. +                           if (useAdminForAttrs) {
  29. +                               entry = e;
  30. +                           }
  31.                         }
  32. -                       Entry e = cursor.get();
  33. -                       userDn = e.getDn();
  34. -                       if (useAdminForAttrs) {
  35. -                           entry = e;
  36. -                       }
  37. -                   }
  38. +                   } catch(CursorLdapReferralException e) {
  39. +                       }
  40.                     cursor.close();
  41.                     if (userDn == null) {
  42.                         log.error("NONE users found in LDAP");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement