Just to note, there's already a pull request related to this: https://github.com/opnsense/plugins/pull/2166
can you try this changes to add some debug to Tester and try again?in /usr/local/www/diag_authenticatiopn.php addCode: [Select] foreach ($authenticator->getLastAuthProperties() as $attr_name => $attr_value) { if (is_array($attr_value)) { $attr_value = implode(",", $attr_value); } $input_errors[] = "{$attr_name}: {$attr_value}"; }after Code: [Select] $input_errors[] = gettext("Authentication failed.");string in /usr/local/opnsese/mvc/app/library/opnsense/auth/ldap.php addCode: [Select] $this->lastAuthProperties['error'] = $error_string; $this->lastAuthProperties['ldap_error'] = ldap_error($this->ldapHandle);after Code: [Select] syslog(LOG_ERR, sprintf($message . " [%s,%s]", $error_string, ldap_error($this->ldapHandle)));string in logLDAPError functionand add Code: [Select] else { $this->lastAuthProperties['error'] = "User DN not found"; }after brace inCode: [Select] if ($result !== false && count($result) > 0) { $user_dn = $result[0]['dn']; $ldap_is_connected = $this->connect($this->ldapBindURL, $result[0]['dn'], $password); }in authenticate function
foreach ($authenticator->getLastAuthProperties() as $attr_name => $attr_value) { if (is_array($attr_value)) { $attr_value = implode(",", $attr_value); } $input_errors[] = "{$attr_name}: {$attr_value}"; }
$input_errors[] = gettext("Authentication failed.");
$this->lastAuthProperties['error'] = $error_string; $this->lastAuthProperties['ldap_error'] = ldap_error($this->ldapHandle);
syslog(LOG_ERR, sprintf($message . " [%s,%s]", $error_string, ldap_error($this->ldapHandle)));
else { $this->lastAuthProperties['error'] = "User DN not found"; }
if ($result !== false && count($result) > 0) { $user_dn = $result[0]['dn']; $ldap_is_connected = $this->connect($this->ldapBindURL, $result[0]['dn'], $password); }
The following input errors were detected:Authentication failed.error: User DN not found
so I'll go back and double-check to see if I haven't made any obvious mistakes
Quoteso I'll go back and double-check to see if I haven't made any obvious mistakesas you can see in the proposed code, the "User DN not found" error occurs when the user's search does not return any results. that is, the binding itself is successful. so it's not about the SSL params.search uses username from tester input, "User naming attribute" from server config and "Extended Query" from server config (if any). plus underlying search function uses "Base DN" and "Authentication containers" (if any) from server config.so I would pay attention to these parameters of server config
What got authentication working was to append the base DN to this value to fully qualify it.
I can press the "Select a container" button alongside the "Authentication containers"
QuoteI can press the "Select a container" button alongside the "Authentication containers" tried without specifying a "Authentication containers"? with "base dn" only(button uses the same search function, which does not attach the basedn to the container)
setting if you dismiss the pop-up window via the "Close" button (given there's nothing to select in the pop-up)
This is even when pressing "Select a container" with the fully-specified DN entered in the setting field
I have a feeling that when calling the lists of containers with this button, the value of this field is not involved in the search. only baseDN. "Authentication containers" values are used to check for matches and mark the matched containers as selected in the result table. so can you try with empty "Authentication containers" and Base DN only?
if ($searchResults !== false) { for ($i = 0; $i < $searchResults["count"]; $i++) { $result[] = $searchResults[$i]['dn']; }
if ($searchResults !== false) { $this->logLdapError("LDAP containers search result count: " . $searchResults["count"]); for ($i = 0; $i < $searchResults["count"]; $i++) { $result[] = $searchResults[$i]['dn']; }
can you try to modify listOUs function in /usr/local/opnsese/mvc/app/library/opnsense/auth/ldap.php:before:Code: [Select] if ($searchResults !== false) { for ($i = 0; $i < $searchResults["count"]; $i++) { $result[] = $searchResults[$i]['dn']; }after:Code: [Select] if ($searchResults !== false) { $this->logLdapError("LDAP containers search result count: " . $searchResults["count"]); for ($i = 0; $i < $searchResults["count"]; $i++) { $result[] = $searchResults[$i]['dn']; }try to "Select" again and look General log for some ldap errors?
public function listOUs() { $result = array(); if ($this->ldapHandle !== false) { $searchResults = $this->search("(|(ou=*)(cn=Users))"); if ($searchResults !== false) { $this->logLdapError("LDAP containers search result count: " . $searchResults["count"]); for ($i = 0; $i < $searchResults["count"]; $i++) { $result[] = $searchResults[$i]['dn']; } return $result; } else { $this->logLdapError("LDAP containers search returned no results"); } } return false; }
LDAP containers search returned no results [,Time limit exceeded]
Time limit exceeded
if ($this->ldapScope == 'one') { $sr = @ldap_list($this->ldapHandle, $baseDN, $filter, $this->ldapSearchAttr, 0, 0, 60); } else { $sr = @ldap_search($this->ldapHandle, $baseDN, $filter, $this->ldapSearchAttr, 0, 0, 60); }
hm. have you tried with "One level" in "Search scope" parameter?and imho (not tested) you can try to play with timelimit in ldap_list and ldap_search functions in search function.can try to make it like (for 60 sec limit. if LDAP server allows it) in search function:Code: [Select] if ($this->ldapScope == 'one') { $sr = @ldap_list($this->ldapHandle, $baseDN, $filter, $this->ldapSearchAttr, 0, 0, 60); } else { $sr = @ldap_search($this->ldapHandle, $baseDN, $filter, $this->ldapSearchAttr, 0, 0, 60); }