Exemplo n.º 1
0
function ldap_internal_dn_from_username($username)
{
    global $config, $ds, $cache;
    if (!isset($cache['ldap']['dn'][$username])) {
        ldap_init();
        $filter = "(" . $config['auth_ldap_attr']['uid'] . '=' . $username . ")";
        print_debug("LDAP[Filter][{$filter}][" . trim($config['auth_ldap_suffix'], ', ') . "]");
        $search = ldap_search($ds, trim($config['auth_ldap_suffix'], ', '), $filter);
        $entries = ldap_get_entries($ds, $search);
        if ($entries['count']) {
            list($cache['ldap']['dn'][$username], ) = ldap_escape_filter_value($entries[0]['dn']);
        }
    }
    return $cache['ldap']['dn'][$username];
}
Exemplo n.º 2
0
function ldap_dn_from_username($username)
{
    global $config, $debug, $ds, $cache;
    if (!isset($cache['ldap']['dn'][$username])) {
        ldap_init();
        $filter = "(" . $config['auth_ldap_attr']['uid'] . '=' . $username . ")";
        if ($debug) {
            echo "LDAP[Filter][{$filter}][" . trim($config['auth_ldap_suffix'], ', ') . "]\n";
        }
        $search = ldap_search($ds, trim($config['auth_ldap_suffix'], ', '), $filter);
        $entries = ldap_get_entries($ds, $search);
        if ($entries['count']) {
            $cache['ldap']['dn'][$username] = $entries[0]['dn'];
        }
    }
    return $cache['ldap']['dn'][$username];
}