mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-21 12:54:26 +02:00
Let Icinga\Protocol\Ldap\Exception inherit from IcingaException
This commit is contained in:
parent
bdc05ec5f1
commit
c49f723f05
@ -171,11 +171,9 @@ class Connection
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
throw new LdapException(
|
throw new LdapException(
|
||||||
sprintf(
|
'LDAP list for "%s" failed: %s',
|
||||||
'LDAP list for "%s" failed: %s',
|
$dn,
|
||||||
$dn,
|
ldap_error($this->ds)
|
||||||
ldap_error($this->ds)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$children = ldap_get_entries($this->ds, $result);
|
$children = ldap_get_entries($this->ds, $result);
|
||||||
@ -183,7 +181,7 @@ class Connection
|
|||||||
$result = $this->deleteRecursively($children[$i]['dn']);
|
$result = $this->deleteRecursively($children[$i]['dn']);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
//return result code, if delete fails
|
//return result code, if delete fails
|
||||||
throw new LdapException(sprintf('Recursively deleting "%s" failed', $dn));
|
throw new LdapException('Recursively deleting "%s" failed', $dn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->deleteDN($dn);
|
return $this->deleteDN($dn);
|
||||||
@ -200,11 +198,9 @@ class Connection
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
throw new LdapException(
|
throw new LdapException(
|
||||||
sprintf(
|
'LDAP delete for "%s" failed: %s',
|
||||||
'LDAP delete for "%s" failed: %s',
|
$dn,
|
||||||
$dn,
|
ldap_error($this->ds)
|
||||||
ldap_error($this->ds)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,10 +221,8 @@ class Connection
|
|||||||
$rows = $this->fetchAll($query, $fields);
|
$rows = $this->fetchAll($query, $fields);
|
||||||
if (count($rows) !== 1) {
|
if (count($rows) !== 1) {
|
||||||
throw new LdapException(
|
throw new LdapException(
|
||||||
sprintf(
|
'Cannot fetch single DN for %s',
|
||||||
'Cannot fetch single DN for %s',
|
$query->create()
|
||||||
$query->create()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return key($rows);
|
return key($rows);
|
||||||
@ -471,18 +465,14 @@ class Connection
|
|||||||
} else {
|
} else {
|
||||||
Logger::debug('LDAP STARTTLS failed: %s', ldap_error($ds));
|
Logger::debug('LDAP STARTTLS failed: %s', ldap_error($ds));
|
||||||
throw new LdapException(
|
throw new LdapException(
|
||||||
sprintf(
|
'LDAP STARTTLS failed: %s',
|
||||||
'LDAP STARTTLS failed: %s',
|
ldap_error($ds)
|
||||||
ldap_error($ds)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} elseif ($force_tls) {
|
} elseif ($force_tls) {
|
||||||
throw new LdapException(
|
throw new LdapException(
|
||||||
sprintf(
|
'TLS is required but not announced by %s',
|
||||||
'TLS is required but not announced by %s',
|
$this->hostname
|
||||||
$this->hostname
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Log noticy -> TLS enabled but not announced
|
// TODO: Log noticy -> TLS enabled but not announced
|
||||||
@ -708,24 +698,20 @@ class Connection
|
|||||||
|
|
||||||
if (! $result) {
|
if (! $result) {
|
||||||
throw new LdapException(
|
throw new LdapException(
|
||||||
sprintf(
|
'Capability query failed (%s:%d): %s. Check if hostname and port of the'
|
||||||
'Capability query failed (%s:%d): %s. Check if hostname and port of the ldap resource are correct '
|
. ' ldap resource are correct and if anonymous access is permitted.',
|
||||||
. ' and if anonymous access is permitted.',
|
$this->hostname,
|
||||||
$this->hostname,
|
$this->port,
|
||||||
$this->port,
|
ldap_error($ds)
|
||||||
ldap_error($ds)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$entry = ldap_first_entry($ds, $result);
|
$entry = ldap_first_entry($ds, $result);
|
||||||
if ($entry === false) {
|
if ($entry === false) {
|
||||||
throw new LdapException(
|
throw new LdapException(
|
||||||
sprintf(
|
'Capabilities not available (%s:%d): %s. Discovery of root DSE probably not permitted.',
|
||||||
'Capabilities not available (%s:%d): %s. Discovery of root DSE probably not permitted.',
|
$this->hostname,
|
||||||
$this->hostname,
|
$this->port,
|
||||||
$this->port,
|
ldap_error($ds)
|
||||||
ldap_error($ds)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,14 +757,12 @@ class Connection
|
|||||||
$r = @ldap_bind($this->ds, $this->bind_dn, $this->bind_pw);
|
$r = @ldap_bind($this->ds, $this->bind_dn, $this->bind_pw);
|
||||||
if (! $r) {
|
if (! $r) {
|
||||||
throw new LdapException(
|
throw new LdapException(
|
||||||
sprintf(
|
'LDAP connection to %s:%s (%s / %s) failed: %s',
|
||||||
'LDAP connection to %s:%s (%s / %s) failed: %s',
|
$this->hostname,
|
||||||
$this->hostname,
|
$this->port,
|
||||||
$this->port,
|
$this->bind_dn,
|
||||||
$this->bind_dn,
|
'***' /* $this->bind_pw */,
|
||||||
'***' /* $this->bind_pw */,
|
ldap_error($this->ds)
|
||||||
ldap_error($this->ds)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->bound = true;
|
$this->bound = true;
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
|
|
||||||
namespace Icinga\Protocol\Ldap;
|
namespace Icinga\Protocol\Ldap;
|
||||||
|
|
||||||
|
use Icinga\Exception\IcingaException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Exception
|
* Class Exception
|
||||||
* @package Icinga\Protocol\Ldap
|
* @package Icinga\Protocol\Ldap
|
||||||
*/
|
*/
|
||||||
class Exception extends \Exception
|
class Exception extends IcingaException
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user