public function testUnescapeValues() { $dnval = '\\20\\20\\16\\20t\\,e\\+s \\"t\\,\\\\v\\<a\\>l\\;u\\#e\\=!\\20\\20\\20\\20'; $expected = ' ' . chr(22) . ' t,e+s "t,\\v<a>l;u#e=! '; $this->assertEquals($expected, Zend_Ldap_Dn::unescapeValue($dnval)); $this->assertEquals($expected, Zend_Ldap_Dn::unescapeValue(array($dnval))); $this->assertEquals(array($expected, $expected, $expected), Zend_Ldap_Dn::unescapeValue(array($dnval, $dnval, $dnval))); }
/** * Update LDAP registry * * @param string|Zend_Ldap_Dn $dn * @param array $entry * @return Zend_Ldap Provides a fluid interface * @throws Zend_Ldap_Exception */ public function update($dn, array $entry) { if (!$dn instanceof Zend_Ldap_Dn) { $dn = Zend_Ldap_Dn::factory($dn, null); } self::prepareLdapEntryArray($entry); $rdnParts = $dn->getRdn(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER); foreach ($rdnParts as $key => $value) { $value = Zend_Ldap_Dn::unescapeValue($value); if (array_key_exists($key, $entry) && !in_array($value, $entry[$key])) { $entry[$key] = array_merge(array($value), $entry[$key]); } } $adAttributes = array('distinguishedname', 'instancetype', 'name', 'objectcategory', 'objectguid', 'usnchanged', 'usncreated', 'whenchanged', 'whencreated'); foreach ($adAttributes as $attr) { if (array_key_exists($attr, $entry)) { unset($entry[$attr]); } } if (count($entry) > 0) { $isModified = @ldap_modify($this->getResource(), $dn->toString(), $entry); if ($isModified === false) { /** * @see Zend_Ldap_Exception */ #require_once 'Zend/Ldap/Exception.php'; throw new Zend_Ldap_Exception($this, 'updating: ' . $dn->toString()); } } return $this; }