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

Always trying the last entry on ldap #252

Open
Tshegofatso100 opened this issue Jul 27, 2018 · 0 comments
Open

Always trying the last entry on ldap #252

Tshegofatso100 opened this issue Jul 27, 2018 · 0 comments

Comments

@Tshegofatso100
Copy link

     def search_for_login
        @login_ldap_entry ||= begin
          DeviseLdapAuthenticatable::Logger.send("LDAP search for login: #{@attribute}=#{@login}")
          filter = Net::LDAP::Filter.eq(@attribute.to_s, @login.to_s)
          ldap_entry = nil
          match_count = 0
          @ldap.search(:filter => filter) {|entry| ldap_entry = entry; match_count+=1} ## <<-- this returns the last entry if the are two entries of the same email
          op_result= @ldap.get_operation_result
          if op_result.code!=0 then
            DeviseLdapAuthenticatable::Logger.send("LDAP Error #{op_result.code}: #{op_result.message}")
          end
          DeviseLdapAuthenticatable::Logger.send("LDAP search yielded #{match_count} matches")
          ldap_entry
        end
      end

The problem that i am getting is that somethings we have more than 1 entry with the same email. This method always returns the last one. How can we choose to return the first one or try to authenticate on both entries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant