[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
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\Adapter\ExtLdap; 13 14 use Symfony\Component\Ldap\Adapter\AdapterInterface; 15 use Symfony\Component\Ldap\Exception\LdapException; 16 17 /** 18 * @author Charles Sarrazin <[email protected]> 19 */ 20 class Adapter implements AdapterInterface 21 { 22 private $config; 23 private $connection; 24 private $entryManager; 25 26 public function __construct(array $config = []) 27 { 28 if (!\extension_loaded('ldap')) { 29 throw new LdapException('The LDAP PHP extension is not enabled.'); 30 } 31 32 $this->config = $config; 33 } 34 35 /** 36 * {@inheritdoc} 37 */ 38 public function getConnection() 39 { 40 if (null === $this->connection) { 41 $this->connection = new Connection($this->config); 42 } 43 44 return $this->connection; 45 } 46 47 /** 48 * {@inheritdoc} 49 */ 50 public function getEntryManager() 51 { 52 if (null === $this->entryManager) { 53 $this->entryManager = new EntryManager($this->getConnection()); 54 } 55 56 return $this->entryManager; 57 } 58 59 /** 60 * {@inheritdoc} 61 */ 62 public function createQuery(string $dn, string $query, array $options = []) 63 { 64 return new Query($this->getConnection(), $dn, $query, $options); 65 } 66 67 /** 68 * {@inheritdoc} 69 */ 70 public function escape(string $subject, string $ignore = '', int $flags = 0) 71 { 72 $value = ldap_escape($subject, $ignore, $flags); 73 74 // Per RFC 4514, leading/trailing spaces should be encoded in DNs, as well as carriage returns. 75 if ($flags & \LDAP_ESCAPE_DN) { 76 if (!empty($value) && ' ' === $value[0]) { 77 $value = '\\20'.substr($value, 1); 78 } 79 if (!empty($value) && ' ' === $value[\strlen($value) - 1]) { 80 $value = substr($value, 0, -1).'\\20'; 81 } 82 $value = str_replace("\r", '\0d', $value); 83 } 84 85 return $value; 86 } 87 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |