[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/symfony/ldap/ -> Ldap.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <[email protected]>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\Ldap;
  13  
  14  use Symfony\Component\Ldap\Adapter\AdapterInterface;
  15  use Symfony\Component\Ldap\Adapter\EntryManagerInterface;
  16  use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
  17  use Symfony\Component\Ldap\Adapter\QueryInterface;
  18  use Symfony\Component\Ldap\Exception\DriverNotFoundException;
  19  
  20  /**
  21   * @author Charles Sarrazin <[email protected]>
  22   */
  23  final class Ldap implements LdapInterface
  24  {
  25      private $adapter;
  26  
  27      public function __construct(AdapterInterface $adapter)
  28      {
  29          $this->adapter = $adapter;
  30      }
  31  
  32      /**
  33       * {@inheritdoc}
  34       */
  35      public function bind(string $dn = null, string $password = null)
  36      {
  37          $this->adapter->getConnection()->bind($dn, $password);
  38      }
  39  
  40      /**
  41       * {@inheritdoc}
  42       */
  43      public function query(string $dn, string $query, array $options = []): QueryInterface
  44      {
  45          return $this->adapter->createQuery($dn, $query, $options);
  46      }
  47  
  48      /**
  49       * {@inheritdoc}
  50       */
  51      public function getEntryManager(): EntryManagerInterface
  52      {
  53          return $this->adapter->getEntryManager();
  54      }
  55  
  56      /**
  57       * {@inheritdoc}
  58       */
  59      public function escape(string $subject, string $ignore = '', int $flags = 0): string
  60      {
  61          return $this->adapter->escape($subject, $ignore, $flags);
  62      }
  63  
  64      /**
  65       * Creates a new Ldap instance.
  66       *
  67       * @param string $adapter The adapter name
  68       * @param array  $config  The adapter's configuration
  69       *
  70       * @return static
  71       */
  72      public static function create(string $adapter, array $config = []): self
  73      {
  74          if ('ext_ldap' !== $adapter) {
  75              throw new DriverNotFoundException(sprintf('Adapter "%s" not found. Only "ext_ldap" is supported at the moment.', $adapter));
  76          }
  77  
  78          return new self(new Adapter($config));
  79      }
  80  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer