$msgOk .= $dc['target'] . ','; } $msgOk = substr($msgOk, 0, -1); } if (!$dcs) { $msgErr = tr('No Domain Controller found.'); } } else { $msgErr = tr("PHP LDAP extension is not available."); } break; case 'AdConnection': if (IF_AbstractLdapConnector::isLdapExtensionEnabled()) { try { $test = new adLDAP(array('domain_controllers' => explode(',', $pAdDomainController), 'admin_username' => $pAdBindUser, 'admin_password' => $pAdBindPassword, 'base_dn' => null, 'account_suffix' => '')); $msgOk = "OK, BaseDN is " . $test->findBaseDn(); } catch (Exception $e) { $msgErr = $e->getMessage(); } } else { $msgErr = tr("PHP LDAP extension is not available."); } break; default: $msgErr = "Invalid request."; } // Prepare data for JSON response. header("Content-Type: application/json"); $json = new stdClass(); $json->type = empty($msgOk) ? "error" : "success"; $json->message = empty($msgOk) ? $msgErr : $msgOk;