Example #1
0
 $ldap_email = $ra['username'];
 $ldap_disabled = $ra['disabled'];
 $ldap_admin = $ra['admin'];
 //get ldap servers
 $r1 = mysql_query("SELECT host, port, ssl_enc, ldaptype, bindaccount, aes_decrypt(password, '{$spt_encrypt_key}') as password, basedn FROM settings_ldap WHERE id = '{$ldap_server}'");
 while ($ra1 = mysql_fetch_assoc($r1)) {
     $ldap_host = $ra1['host'];
     $ldap_port = $ra1['port'];
     $ldap_ssl_enc = $ra1['ssl_enc'];
     $ldap_ldaptype = $ra1['ldaptype'];
     $ldap_bindaccount = $ra1['bindaccount'];
     $ldap_password = $ra1['password'];
     $ldap_basedn = $ra1['basedn'];
 }
 //lookup first and last name based on email address
 $ldap_user_lookup = ldap_user_email_query($ldap_host, $ldap_port, $ldap_bindaccount, $ldap_password, $ldap_basedn, $ldap_ssl_enc, $ldap_ldaptype, $ldap_email);
 if ($ldap_user_lookup) {
     $fname = $ldap_user_lookup[0]['givenname'][0];
     $lname = $ldap_user_lookup[0]['sn'][0];
 } else {
     $fname = "n/a";
     $lname = "n/a";
 }
 echo "<tr>\n<td>";
 echo $fname . " " . $lname;
 echo "</td>\n<td>";
 echo $ldap_email;
 echo "</td>\n<td>";
 echo $ldap_host;
 echo "</td>\n<td>";
 //determine if the specific user is an admin
Example #2
0
     $current_ldap_server_bindaccount = $ra[5];
     $current_ldap_server_password = $ra[6];
     $current_ldap_server_basedn = $ra[7];
 }
 //get connected
 $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;
 }