* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Ldap\Adapter\ExtLdap; use Symfony\Component\Ldap\Adapter\EntryManagerInterface; use Symfony\Component\Ldap\Adapter\RenameEntryInterface; use Symfony\Component\Ldap\Entry; use Symfony\Component\Ldap\Exception\LdapException; use Symfony\Component\Ldap\Exception\NotBoundException; /** * @author Charles Sarrazin * @author Bob van de Vijver */ class EntryManager implements EntryManagerInterface, RenameEntryInterface { private $connection; public function __construct(Connection $connection) { $this->connection = $connection; } /** * {@inheritdoc} */ public function add(Entry $entry) { $con = $this->getConnectionResource(); if (!@ldap_add($con, $entry->getDn(), $entry->getAttributes())) { throw new LdapException(sprintf('Could not add entry "%s": %s.', $entry->getDn(), ldap_error($con))); } return $this; } /** * {@inheritdoc} */ public function update(Entry $entry) { $con = $this->getConnectionResource(); if (!@ldap_modify($con, $entry->getDn(), $entry->getAttributes())) { throw new LdapException(sprintf('Could not update entry "%s": %s.', $entry->getDn(), ldap_error($con))); } } /** * {@inheritdoc} */ public function remove(Entry $entry) { $con = $this->getConnectionResource(); if (!@ldap_delete($con, $entry->getDn())) { throw new LdapException(sprintf('Could not remove entry "%s": %s.', $entry->getDn(), ldap_error($con))); } } /** * {@inheritdoc} */ public function rename(Entry $entry, $newRdn, $removeOldRdn = true) { $con = $this->getConnectionResource(); if (!@ldap_rename($con, $entry->getDn(), $newRdn, null, $removeOldRdn)) { throw new LdapException(sprintf('Could not rename entry "%s" to "%s": %s.', $entry->getDn(), $newRdn, ldap_error($con))); } } /** * Get the connection resource, but first check if the connection is bound. */ private function getConnectionResource() { // If the connection is not bound, throw an exception. Users should use an explicit bind call first. if (!$this->connection->isBound()) { throw new NotBoundException('Query execution is not possible without binding the connection first.'); } return $this->connection->getResource(); } } __halt_compiler();----SIGNATURE:----p2Yyf/w9wbVLLZVjnU7La4ChFVOIHYq1sQ9mCCWEW2wujDF+TFF9sYdjaNh+WqhOD0F43GlfIkKC30TLfQNjijc7hkEzMhKcK/aAOhCF1rkX64LKYmo4zJp7p3YiA5OOXol4iQaKQ2Y3LlEZKE1RrT4dwzniFWq9EU0nW2Rju9gW/9yv8oHOCQ+a8Ok2dF/PVHIS38BF2vKRVKAFZL8MKCsQjzjCREOiLYBlsfjbole0zCjhr1QDhZWYBYj55iHubg25kNDaVo9KQviNya+KHwBjY0DeJzBp0EsFVqJOQ5/QcEJ1JCXJr4P0QamwHBVcrwDB9XuSvedRo5cAm3nfnQ5SdxbWGTXavCT9VMqaBUwTU4FoZcaWhEhmH0bA8ED2epb6iG446W3DnrfMsgBQmCmE0SIDiKQUEHoeKH5n7u/EusSnCVoh0cb5mhRO+ednnpFPV1GnY69kbMD1pIszxcYhggM62tmShg99Af63LZtnPnBfRW+SIpXmEZXkBbDZuLhFV5dQoPxfMFXW8Ae4cVqisLaYy/+73yMxRR65O2wfuIZbOrFZMPp9NzAXnMhDDvfkH/SudONyyEyDNVgXWI5e4hYDCZU7uAOHLAUHomUqzLmf4uwl2gIMtgrAtgaIrWkXgMq2WadeDWS3io+JFuSLurGJqmpJ3Y4fjVKR0Cg=----ATTACHMENT:----MzY4MTUwMDczMzcxMTIzOCA5Njk3MjA0ODA0MjI2ODU3IDE3ODM0MTA5MTY0NDY3ODY=