diff --git a/library/Icinga/Protocol/Ldap/LdapConnection.php b/library/Icinga/Protocol/Ldap/LdapConnection.php index 2d9ee358a..ffb8c3ed5 100644 --- a/library/Icinga/Protocol/Ldap/LdapConnection.php +++ b/library/Icinga/Protocol/Ldap/LdapConnection.php @@ -6,6 +6,7 @@ namespace Icinga\Protocol\Ldap; use Exception; use LogicException; use ArrayIterator; +use stdClass; use Icinga\Application\Config; use Icinga\Application\Logger; use Icinga\Data\ConfigObject; @@ -549,6 +550,23 @@ class LdapConnection implements Selectable, Inspectable return $pairs; } + /** + * Fetch an LDAP entry by its DN + * + * @param string $dn + * @param array|null $fields + * + * @return StdClass|bool + */ + public function fetchByDn($dn, array $fields = null) + { + return $this->select() + ->from('*', $fields) + ->setBase($dn) + ->setScope('base') + ->fetchRow(); + } + /** * Test the given LDAP credentials by establishing a connection and attempting a LDAP bind *