Private GIT

Skip to content
Snippets Groups Projects
Commit b71a3e88 authored by loiclau's avatar loiclau
Browse files

* Fix ldap connection, typo in function name #5216

* Remove special chars filter for POST data
parent fd359770
Branches
Tags
No related merge requests found
......@@ -192,6 +192,7 @@ class CentreonLDAP {
*/
public function connect()
{
foreach ($this->_ldapHosts as $ldap) {
$port = "";
$testingPort = 389;
......@@ -204,8 +205,9 @@ class CentreonLDAP {
} else {
$url = 'ldap://' . $ldap['host'] . $port . '/';
}
$this->debug("LDAP Connect : trying url : " . $url);
$this->setErrorHandler();
$this->_debug("LDAP Connect : trying url : " . $url);
$this->_setErrorHandler();
if ($this->isLdapServerAvailable($ldap['host'], $testingPort, $ldap['search_timeout'])) {
$this->_ds = ldap_connect($url);
......@@ -216,7 +218,7 @@ class CentreonLDAP {
}
ldap_set_option($this->_ds, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
if (isset($ldap['info']['use_tls']) && $ldap['info']['use_tls'] == 1) {
$this->debug("LDAP Connect : use tls");
$this->_debug("LDAP Connect : use tls");
@ldap_start_tls($this->_ds);
}
restore_error_handler();
......@@ -226,7 +228,7 @@ class CentreonLDAP {
return true;
}
}
$this->debug("LDAP Connect : connection error");
$this->_debug("LDAP Connect : connection error");
}
return false;
}
......@@ -321,8 +323,10 @@ class CentreonLDAP {
if (trim($this->_userSearchInfo['filter']) == '') {
return false;
}
$this->_setErrorHandler();
// $this->_setErrorHandler();
$filter = preg_replace('/%s/', $this->replaceFilter($username), $this->_userSearchInfo['filter']);
$result = ldap_search($this->_ds, $this->_userSearchInfo['base_search'], $filter);
$entries = ldap_get_entries($this->_ds, $result);
restore_error_handler();
......@@ -342,6 +346,9 @@ class CentreonLDAP {
if (trim($this->_groupSearchInfo['filter']) == '') {
return false;
}
var_dump($this->_groupSearchInfo['filter']);
$this->_setErrorHandler();
$filter = preg_replace('/%s/', $this->replaceFilter($group), $this->_groupSearchInfo['filter']);
$result = ldap_search($this->_ds, $this->_groupSearchInfo['base_search'], $filter);
......
......@@ -89,6 +89,7 @@ $queryGetLdap = 'SELECT contact_alias
WHERE contact_register = 1';
$res = $pearDB->query($queryGetLdap);
$listLdapUsers = array();
if (!PEAR::isError($res)) {
while ($row = $res->fetchRow()) {
$listLdapUsers[] = $row['contact_alias'];
......@@ -101,7 +102,10 @@ $buffer->startElement("reponse");
$ids = explode(",", $confList);
foreach ($ids as $arId) {
$ldap = new CentreonLDAP($pearDB, null, $arId);
$connect = false;
if ($ldap->connect()) {
$connect = true;
......@@ -116,7 +120,7 @@ foreach ($ids as $arId) {
FROM auth_ressource_info
WHERE ar_id = ?";
$stmt = $pearDB->prepare($query);
$res = $pearDB->execute($stmt, array($arId));
$res = $pearDB->execute($stmt, array((int)$arId));
while ($row = $res->fetchRow()) {
switch ($row['ari_name']) {
......@@ -143,6 +147,7 @@ foreach ($ids as $arId) {
$searchResult = $ldap->search($ldap_search_filter, $ldap_base_dn, $ldap_search_limit, $ldap_search_timeout);
$number_returned = count($searchResult);
if ($number_returned) {
$buffer->writeElement("entries", $number_returned);
for ($i = 0; $i < $number_returned; $i++) {
......@@ -217,6 +222,7 @@ foreach ($ids as $arId) {
}
}
}
if (isset($error)) {
$buffer->writeElement("error", $error);
}
......
......@@ -44,11 +44,6 @@
* Purge Values
*/
if (function_exists('filter_var')){
foreach ($_POST as $key => $value){
if (!is_array($value)){
$_POST[$key] = filter_var($value, FILTER_SANITIZE_SPECIAL_CHARS);
}
}
foreach ($_GET as $key => $value){
if (!is_array($value)){
$_GET[$key] = filter_var($value, FILTER_SANITIZE_SPECIAL_CHARS);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment