Skip to content
Snippets Groups Projects
Commit feb73bc6 authored by Aleksander Machniak's avatar Aleksander Machniak
Browse files

Unify some error, warning and debug messages

parent 85c8e887
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -159,7 +159,7 @@ class Net_LDAP3
if (array_keys($entries) == range(0, count($entries) - 1)) {
// $entries is sequential
if (count($entries) !== count($attributes)) {
$this->_error("Wrong entry/attribute count in " . __FUNCTION__);
$this->_error("LDAP: Wrong entry/attribute count in " . __FUNCTION__);
return false;
}
 
Loading
Loading
@@ -204,14 +204,14 @@ class Net_LDAP3
 
$this->_debug("C: Add $entry_dn: " . json_encode($attributes));
 
if (($add_result = ldap_add($this->conn, $entry_dn, $attributes)) == false) {
if (($add_result = @ldap_add($this->conn, $entry_dn, $attributes)) == false) {
$this->_debug("S: " . ldap_error($this->conn));
$this->_debug("S: Adding entry $entry_dn failed. " . ldap_error($this->conn));
$this->_warning("LDAP: Adding entry $entry_dn failed. " . ldap_error($this->conn));
 
return false;
}
 
$this->_debug("LDAP: S: OK");
$this->_debug("S: OK");
 
return true;
}
Loading
Loading
@@ -294,14 +294,14 @@ class Net_LDAP3
$result = $ldap->add_entry($new_replica_dn, $replica_attrs);
 
if (!$result) {
$this->_error("Could not add replication configuration to database for $domain_root_dn on $replica_host");
$this->_error("LDAP: Could not add replication configuration to database for $domain_root_dn on $replica_host");
continue;
}
 
$result = $ldap->search($replica_dn, "(objectclass=nsDS5ReplicationAgreement)", "sub");
 
if (!$result) {
$this->_error("Host $replica_host does not have any replication agreements");
$this->_error("LDAP: Host $replica_host does not have any replication agreements");
continue;
}
 
Loading
Loading
@@ -338,7 +338,7 @@ class Net_LDAP3
$result = $ldap->add_entry($replica_agreement_dn, $replica_agreement_attrs);
 
if (!$result) {
$this->_error("Failed adding $replica_agreement_dn");
$this->_error("LDAP: Failed adding $replica_agreement_dn");
}
}
}
Loading
Loading
@@ -503,7 +503,7 @@ class Net_LDAP3
}
 
$this->_debug("S: ".ldap_error($this->conn));
$this->_error("Bind failed for dn=$bind_dn: ".ldap_error($this->conn));
$this->_error("LDAP: Bind failed for dn=$bind_dn. ".ldap_error($this->conn));
 
return false;
}
Loading
Loading
@@ -647,14 +647,15 @@ class Net_LDAP3
*/
public function delete_entry($entry_dn)
{
$this->_debug("LDAP: C: Delete $entry_dn");
$this->_debug("C: Delete $entry_dn");
 
if (ldap_delete($this->conn, $entry_dn) === false) {
$this->_debug("LDAP: S: " . ldap_error($this->conn));
$this->_debug("S: " . ldap_error($this->conn));
$this->_warning("LDAP: Removing entry $entry_dn failed. " . ldap_error($this->conn));
return false;
}
 
$this->_debug("LDAP: S: OK");
$this->_debug("S: OK");
 
return true;
}
Loading
Loading
@@ -1004,6 +1005,7 @@ class Net_LDAP3
}
else {
$this->_debug("S: ".ldap_error($this->conn));
$this->_warning("LDAP: Failed to read $dn. " . ldap_error($this->conn));
}
 
if (!empty($rec)) {
Loading
Loading
@@ -1109,7 +1111,7 @@ class Net_LDAP3
$bound = $this->bind($entry_dn, $password);
 
if (!$bound) {
$this->_error("Could not bind with " . $entry_dn);
$this->_error("LDAP: Could not bind with " . $entry_dn);
return null;
}
 
Loading
Loading
@@ -1516,7 +1518,7 @@ class Net_LDAP3
}
 
if (!function_exists('ldap_sasl_bind')) {
$this->_error("Unable to bind: ldap_sasl_bind() not exists");
$this->_error("LDAP: Unable to bind. ldap_sasl_bind() not exists");
return false;
}
 
Loading
Loading
@@ -1537,7 +1539,7 @@ class Net_LDAP3
}
 
$this->_debug("S: ".ldap_error($this->conn));
$this->_error("Bind failed for authcid=$authc ".ldap_error($this->conn));
$this->_error("LDAP: Bind failed for authcid=$authc. ".ldap_error($this->conn));
 
return false;
}
Loading
Loading
@@ -1634,7 +1636,7 @@ class Net_LDAP3
$ldap_result = @$function($this->conn, $base_dn, $filter, $attrs, 0, $sizelimit, $timelimit);
 
if (!$ldap_result) {
$this->_warning("$function failed for dn=$base_dn: ".ldap_error($this->conn));
$this->_warning("LDAP: $function failed for dn=$base_dn. " . ldap_error($this->conn));
return false;
}
 
Loading
Loading
@@ -2294,7 +2296,7 @@ class Net_LDAP3
$newrdn = $attributes['rename']['new_rdn'];
$new_parent = $attributes['rename']['new_parent'];
 
$this->_debug("LDAP: C: Rename $olddn to $newrdn,$new_parent");
$this->_debug("C: Rename $olddn to $newrdn,$new_parent");
 
// Note: for some reason the operation fails if RDN contains special characters
// and last argument of ldap_rename() is set to TRUE. That's why we use FALSE.
Loading
Loading
@@ -2308,7 +2310,7 @@ class Net_LDAP3
}
 
if ($result) {
$this->_debug("LDAP: S: OK");
$this->_debug("S: OK");
 
if ($new_parent) {
$subject_dn = $newrdn . ',' . $new_parent;
Loading
Loading
@@ -2328,52 +2330,52 @@ class Net_LDAP3
}
}
else {
$this->_debug("LDAP: S: " . ldap_error($this->conn));
$this->_warning("LDAP: Failed to rename $olddn to $newrdn,$new_parent");
$this->_debug("S: " . ldap_error($this->conn));
$this->_warning("LDAP: Failed to rename $olddn to $newrdn,$new_parent. " . ldap_error($this->conn));
return false;
}
}
 
if (is_array($attributes['replace']) && !empty($attributes['replace'])) {
$this->_debug("LDAP: C: Mod-Replace $subject_dn: " . json_encode($attributes['replace']));
$this->_debug("C: Mod-Replace $subject_dn: " . json_encode($attributes['replace']));
 
$result = ldap_mod_replace($this->conn, $subject_dn, $attributes['replace']);
 
if ($result) {
$this->_debug("LDAP: S: OK");
$this->_debug("S: OK");
}
else {
$this->_debug("LDAP: S: " . ldap_error($this->conn));
$this->_debug("S: " . ldap_error($this->conn));
$this->_warning("LDAP: Failed to replace attributes on $subject_dn: " . json_encode($attributes['replace']));
return false;
}
}
 
if (is_array($attributes['del']) && !empty($attributes['del'])) {
$this->_debug("LDAP: C: Mod-Delete $subject_dn: " . json_encode($attributes['del']));
$this->_debug("C: Mod-Delete $subject_dn: " . json_encode($attributes['del']));
 
$result = ldap_mod_del($this->conn, $subject_dn, $attributes['del']);
 
if ($result) {
$this->_debug("LDAP: S: OK");
$this->_debug("S: OK");
}
else {
$this->_debug("LDAP: S: " . ldap_error($this->conn));
$this->_debug("S: " . ldap_error($this->conn));
$this->_warning("LDAP: Failed to delete attributes on $subject_dn: " . json_encode($attributes['del']));
return false;
}
}
 
if (is_array($attributes['add']) && !empty($attributes['add'])) {
$this->_debug("LDAP: C: Mod-Add $subject_dn: " . json_encode($attributes['add']));
$this->_debug("C: Mod-Add $subject_dn: " . json_encode($attributes['add']));
 
$result = ldap_mod_add($this->conn, $subject_dn, $attributes['add']);
 
if ($result) {
$this->_debug("LDAP: S: OK");
$this->_debug("S: OK");
}
else {
$this->_debug("LDAP: S: " . ldap_error($this->conn));
$this->_debug("S: " . ldap_error($this->conn));
$this->_warning("LDAP: Failed to add attributes on $subject_dn: " . json_encode($attributes['add']));
return false;
}
Loading
Loading
@@ -2933,7 +2935,7 @@ class Net_LDAP3
// only report once
if (!$seen["$host:$port"]++) {
$this->mc_available--;
$this->_error("Memcache failure on host $host:$port");
$this->_error("LDAP: Memcache failure on host $host:$port");
}
}
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment