コード例 #1
0
ファイル: ldap_test.php プロジェクト: cinno/sptoolkit
        $ldap_conn = ldap_connection($current_ldap_server_host, $current_ldap_server_port, $current_ldap_server_ssl);
        if (!$ldap_conn) {
            $_SESSION['alert_message'] = "could not connect to server";
            header('location:./?test_ldap_server=' . $host . '#tabs-3');
            exit;
        }
        //get username and password from submission
        $username = $_POST['username'];
        $password = $_POST['password'];
        //get username
        $ldap_user_lookup = ldap_user_email_query($current_ldap_server_host, $current_ldap_server_port, $current_ldap_server_bindaccount, $current_ldap_server_password, $current_ldap_server_basedn, $current_ldap_server_ssl, $current_ldap_server_ldaptype, $username);
        if ($ldap_user_lookup) {
            $ldap_test_user_dn = $ldap_user_lookup['0']['dn'];
        }
        unset($ldap_bind);
        //attempt bind with provided username and password
        $ldap_bind = ldap_bind_connection($ldap_conn, $ldap_test_user_dn, $password);
        if ($ldap_bind) {
            $_SESSION['alert_message'] = "authentication successful :)";
            header('location:./?test_ldap_server=' . $host . '#tabs-3');
            exit;
        } else {
            $_SESSION['alert_message'] = "authentication unsuccessful :(";
            header('location:./?test_ldap_server=' . $host . '#tabs-3');
            exit;
        }
    }
}
$_SESSION['alert_message'] = "gotta send me something";
header('location:./#tabs-3');
exit;
コード例 #2
0
ファイル: ldap.php プロジェクト: cinno/sptoolkit
function ldap_user_group_check($ldap_server, $ldap_port, $ldap_ssl, $ldap_type, $ldap_user, $ldap_pass, $ldap_basedn, $ldap_user, $ldap_group_dn)
{
    //call connect function
    $ldap_conn = ldap_connection($ldap_server, $ldap_port, $ldap_user, $ldap_pass);
    //call bind function
    $ldap_bind = ldap_bind_connection($ldap_conn, $ldap_user, $ldap_pass);
    //setup search filter for the data you want
    $search = "(&(uid=" . $ldap_user . ")(memberof=" . $ldap_group_dn . ")";
    //setup filter for what you want from your data
    $filter = array("dn", "uid");
    //search
    $ldap_user_of_group = ldap_search($ldap_conn, $ldap_basedn, $search, $filter);
    //get data
    $ldap_user_of_group = ldap_get_entries($ldap_conn, $ldap_user_of_group);
    //return dump
    return $ldap_user_of_group;
}
コード例 #3
0
ファイル: validator.php プロジェクト: cinno/sptoolkit
 if (strtolower($ldap_user) == strtolower($u)) {
     //attempt bind with provided username and password
     //get connected
     $ldap_conn = ldap_connection($ldap_host, $ldap_port, $ldap_ssl_enc);
     if (!$ldap_conn) {
         $_SESSION['alert_message'] = "problems attempting authentication";
         header('location:../');
         exit;
     }
     //get username
     $ldap_user_lookup = ldap_user_email_query($ldap_host, $ldap_port, $ldap_bindaccount, $ldap_password, $ldap_basedn, $ldap_ssl_enc, $ldap_ldaptype, $ldap_user);
     if ($ldap_user_lookup) {
         $ldap_dn = $ldap_user_lookup['0']['dn'];
     }
     //attempt bind with provided username and password
     $ldap_bind = ldap_bind_connection($ldap_conn, $ldap_dn, $temp_p);
     if ($ldap_bind) {
         //create an authenticated session
         $_SESSION['authenticated'] = 1;
         //create a username session
         $_SESSION['username'] = $u;
         //check to see if they are an admin
         if ($ra['admin'] == 1) {
             //create an admin session
             $_SESSION['admin'] = 1;
         }
         //send authenticated user to the dashboard
         header('location:../dashboard/#phish_pie');
         exit;
     }
 }