As I understand the purpose of simple_authenticate is authenticating a user against the domain without requiring a query user. This is not happening, as per sequence below:
Adauth::AdObjects::User.simple_authenticate(usr, pwd)
allowed_to_login
usr.cn_goups_nested
Adauth::AdObjects::Group.where('name', group)
filter
Adauth.connection
- _
connect_
Adauth::Connection.new(connection_hash(_@config.query_user, @config.query_password_))
This happens because Adauth.connection doesn't return a connection, despite there's an existing one
created by Adauth::AdObjects::User.authenticate to authenticate the user against the AD; Adauth.connect therefore tries to establish a new connection with the query user credentials, which will be empty, resulting in a <Net::LDAP::LdapError: invalid binding information> error.
The tests themselves simple_authenticate the query user, which kind of defeats the whole purpose of it.
Imho the simplest approach to solve this would be to change Adauth.connection_hash in order to use provided credentials if no query user is configured:
-
accept empty user and password arguments by default (user = "", password = "")
-
use those values as fallback when no query user is configured, in the likes of
:username => @config.query_user.blank? ? user : @config.query_user,
:password => @config.query_user.blank? ? password : @config.password
In this line, would also need to change:
Adauth.connection, in order to accept empty user and password arguments by default (user = "", password = "")
- ditto for
Adauth.connect
As I understand the purpose of simple_authenticate is authenticating a user against the domain without requiring a query user. This is not happening, as per sequence below:
Adauth::AdObjects::User.simple_authenticate(usr, pwd)allowed_to_loginusr.cn_goups_nestedAdauth::AdObjects::Group.where('name', group)filterAdauth.connectionconnect_Adauth::Connection.new(connection_hash(_@config.query_user, @config.query_password_))This happens because
Adauth.connectiondoesn't return a connection, despite there's an existing onecreated by
Adauth::AdObjects::User.authenticateto authenticate the user against the AD;Adauth.connecttherefore tries to establish a new connection with the query user credentials, which will be empty, resulting in a<Net::LDAP::LdapError: invalid binding information>error.The tests themselves simple_authenticate the query user, which kind of defeats the whole purpose of it.
Imho the simplest approach to solve this would be to change
Adauth.connection_hashin order to use provided credentials if no query user is configured:accept empty user and password arguments by default
(user = "", password = "")use those values as fallback when no query user is configured, in the likes of
:username => @config.query_user.blank? ? user : @config.query_user,:password => @config.query_user.blank? ? password : @config.passwordIn this line, would also need to change:
Adauth.connection, in order to accept empty user and password arguments by default (user = "", password = "")Adauth.connect