lib/LDAP: Add fetchByDn for a base scope retrieval on an entry

refs #11485
This commit is contained in:
Markus Frosch 2016-04-05 15:05:58 +02:00
parent 202d61dd4e
commit 955a9482ad
1 changed files with 18 additions and 0 deletions

View File

@ -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
*