Beispiel #1
0
function cacti_ldap_auth($username, $password = "", $dn = "", $host = "", $port = "", $port_ssl = "", $version = "", $encryption = "", $referrals = "", $group_require = "", $group_dn = "", $group_attrib = "", $group_member_type = "")
{
    $ldap = new Ldap();
    if (!empty($username)) {
        $ldap->username = $username;
    }
    if (!empty($password)) {
        $ldap->password = $password;
    }
    if (!empty($dn)) {
        $ldap->dn = $dn;
    }
    if (!empty($host)) {
        $ldap->host = $host;
    }
    if (!empty($port)) {
        $ldap->port = $port;
    }
    if (!empty($port_ssl)) {
        $ldap->port_ssl = $port_ssl;
    }
    if (!empty($version)) {
        $ldap->version = $version;
    }
    if (!empty($encryption)) {
        $ldap->encryption = $encryption;
    }
    if (!empty($referrals)) {
        $ldap->referrals = $referrals;
    }
    if (!empty($group_require)) {
        $ldap->group_require = $group_require;
    }
    if (!empty($group_dn)) {
        $ldap->group_dn = $group_dn;
    }
    if (!empty($group_attrib)) {
        $ldap->group_attrib = $group_attrib;
    }
    if (!empty($group_member_type)) {
        $ldap->group_member_type = $group_member_type;
    }
    return $ldap->Authenticate();
}
Beispiel #2
0
function domains_ldap_auth($username, $password = '', $dn = '', $realm)
{
    $ldap = new Ldap();
    if (!empty($username)) {
        $ldap->username = $username;
    }
    if (!empty($password)) {
        $ldap->password = $password;
    }
    if (!empty($dn)) {
        $ldap->dn = $dn;
    }
    $ld = db_fetch_row_prepared('SELECT * FROM user_domains_ldap WHERE domain_id = ?', array($realm - 1000));
    if (sizeof($ld)) {
        if (!empty($ld['dn'])) {
            $ldap->dn = $ld['dn'];
        }
        if (!empty($ld['server'])) {
            $ldap->host = $ld['server'];
        }
        if (!empty($ld['port'])) {
            $ldap->port = $ld['port'];
        }
        if (!empty($ld['port_ssl'])) {
            $ldap->port_ssl = $ld['port_ssl'];
        }
        if (!empty($ld['proto_version'])) {
            $ldap->version = $ld['proto_version'];
        }
        if (!empty($ld['encryption'])) {
            $ldap->encryption = $ld['encryption'];
        }
        if (!empty($ld['referrals'])) {
            $ldap->referrals = $ld['referrals'];
        }
        if (!empty($ld['group_require'])) {
            $ldap->group_require = $ld['group_require'];
        }
        if (!empty($ld['group_dn'])) {
            $ldap->group_dn = $ld['group_dn'];
        }
        if (!empty($ld['group_attrib'])) {
            $ldap->group_attrib = $ld['group_attrib'];
        }
        if (!empty($ld['group_member_type'])) {
            $ldap->group_member_type = $ld['group_member_type'];
        }
        return $ldap->Authenticate();
    } else {
        return false;
    }
}