check if bindDN is not empty, more documentation

This commit is contained in:
Uwe Steinmann 2023-08-24 13:13:11 +02:00
parent b8c59fd264
commit 87f3406bbf

View File

@ -135,13 +135,20 @@ class SeedDMS_LdapAuthentication extends SeedDMS_Authentication {
// If it succeeds, get the DN for the user and use it for an authentication
// with the users password.
$bind = false;
if (isset($settings->_ldapBindDN)) {
if (!empty($settings->_ldapBindDN)) {
$bind = @ldap_bind($ds, $settings->_ldapBindDN, $settings->_ldapBindPw);
} else {
$bind = @ldap_bind($ds);
}
$dn = false;
/* If bind succeed, then get the dn of the user */
/* If bind succeed, then get the dn of the user. If a filter
* is set, it will be used to allow only those users to log in
* matching the filter criteria. Depending on the type of server,
* (AD or regular LDAP), the search attribute is already set to
* 'sAMAccountName=' or 'uid='. All other filters are ANDed.
* A common filter is '(mail=*)' to ensure a user has an email
* address.
*/
if ($bind) {
if (isset($settings->_ldapFilter) && strlen($settings->_ldapFilter) > 0) {
$search = ldap_search($ds, $settings->_ldapBaseDN, "(&(".$ldapSearchAttribut.$username.")".$settings->_ldapFilter.")");