connect() public method

Connect and bind to LDAP.
public connect ( string | null $username = null, string | null $password = null, boolean $anonymous = false, string | null $server = null )
$username string | null The username to connect with. If not specified, the one in the config is used.
$password string | null The password for the username.
$anonymous boolean Whether this is an attempt to bind anonymously, ignoring the username and password.
$server string | null The server to connect to. If not specified, the server(s) in the config are used.
コード例 #1
0
ファイル: RootDse.php プロジェクト: ldaptools/ldaptools
 /**
  * Do the LDAP query to get the LDAP object.
  *
  * @param bool $anonymous
  * @return \LdapTools\Object\LdapObject
  */
 protected function doLdapQuery($anonymous)
 {
     if ($anonymous) {
         $this->connection->connect('', '', true);
     }
     $schema = $this->schemaFactory->get(self::SCHEMA_ROOTDSE_NAME, $this->connection->getConfig()->getLdapType());
     return (new LdapQueryBuilder($this->connection))->from($schema)->select('*')->getLdapQuery()->getSingleResult();
 }
コード例 #2
0
ファイル: RootDseSpec.php プロジェクト: ldaptools/ldaptools
 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);
 }