/** * Get the RootDSE LdapObject while accounting for the state of the connection. * * @return \LdapTools\Object\LdapObject * @throws LdapConnectionException */ public function get() { $anonymous = !$this->connection->isBound(); try { $rootDse = self::doLdapQuery($anonymous); } catch (\Exception $e) { throw new LdapConnectionException(sprintf('Unable to query the RootDSE. %s', $e->getMessage())); } finally { // Make sure to set things back to how they were... if ($anonymous && $this->connection->isBound()) { $this->connection->close(); } } return $rootDse; }
function let(LdapConnectionInterface $connection, EventDispatcherInterface $dispatcher) { $connection->execute(Argument::that(function ($operation) { return $operation->getFilter() == "(&(objectClass=*))" && $operation->getBaseDn() == ""; }))->willReturn($this->entry); $connection->getConfig()->willReturn(new DomainConfiguration('example.local')); $connection->isBound()->willReturn(false); $connection->connect('', '', true)->willReturn(null); $this->beConstructedWith($connection, $dispatcher); }
function let(LdapConnectionInterface $connection, EventDispatcherInterface $dispatcher, LdapLoggerInterface $logger) { $connection->getConfig()->willReturn(new DomainConfiguration('example.local')); $connection->getConnection()->willReturn(null); $connection->isBound()->willReturn(true); $connection->getServer()->willReturn('foo'); $connection->getIdleTime()->willReturn(1); $this->setConnection($connection); $this->setEventDispatcher($dispatcher); $this->setLogger($logger); }