application/Espo/Core/Utils/Authentication/LDAP.php
protected function findLdapUserDnByUsername($username)
    {
        $ldapClient = $this->getLdapClient();
        $options = $this->getUtils()->getOptions();

        $loginFilterString = '';
        if (!empty($options['userLoginFilter'])) {
            $loginFilterString = $this->convertToFilterFormat($options['userLoginFilter']);
        }

        $searchString = '(&(objectClass='.$options['userObjectClass'].')('.$options['userNameAttribute'].'='.$username.')'.$loginFilterString.')';
        $result = $ldapClient->search($searchString, null, LDAP\Client::SEARCH_SCOPE_SUB);
        $GLOBALS['log']->debug('LDAP: user search string: "' . $searchString . '"');

        foreach ($result as $item) {
            return $item["dn"];
        }
    }
protected function findLdapUserDnByUsername($username)
    {
        $ldapClient = $this->getLdapClient();
        $options = $this->getUtils()->getOptions();

        $loginFilterString = '';
        if (!empty($options['userLoginFilter'])) {
            $loginFilterString = $this->convertToFilterFormat($options['userLoginFilter']);
        }

        $searchString = '(&(objectClass='.$options['userObjectClass'].')('.$options['userNameAttribute'].'='.$username.')'.$loginFilterString.')';
        $result = $ldapClient->search($searchString, null, LDAP\Client::SEARCH_SCOPE_SUB);
        $GLOBALS['log']->debug('LDAP: user search string: "' . $searchString . '"');

        foreach ($result as $item) {
            return $item["dn"];
        }
    }
protected function findLdapUserDnByUsername ( $ username ) { $ ldapClient = $ this -> getLdapClient ( ) ; $ options = $ this -> getUtils ( ) -> getOptions ( ) ; $ loginFilterString = '' ; if ( ! empty ( $ options [ 'userLoginFilter' ] ) ) { $ loginFilterString = $ this -> convertToFilterFormat ( $ options [ 'userLoginFilter' ] ) ; } $ searchString = '(&(objectClass=' . $ options [ 'userObjectClass' ] . ')(' . $ options [ 'userNameAttribute' ] . '=' . $ username . ')' . $ loginFilterString . ')' ; $ result = $ ldapClient -> search ( $ searchString , null , LDAP \ Client :: SEARCH_SCOPE_SUB ) ; $ GLOBALS [ 'log' ] -> debug ( 'LDAP: user search string: "' . $ searchString . '"' ) ; foreach ( $ result as $ item ) { return $ item [ "dn" ] ; } }
Find LDAP user DN by his username

@param  string $username

@return string | null
Find LDAP user DN by his username