Ejemplo n.º 1
0
 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, Ldap\Dn::unescapeValue($dnval));
     $this->assertEquals($expected, Ldap\Dn::unescapeValue(array($dnval)));
     $this->assertEquals(array($expected, $expected, $expected), Ldap\Dn::unescapeValue(array($dnval, $dnval, $dnval)));
 }
Ejemplo n.º 2
0
Archivo: Ldap.php Proyecto: Rovak/zf2
 /**
  * Update LDAP registry
  *
  * @param  string|Dn $dn
  * @param  array     $entry
  * @return Ldap Provides a fluid interface
  * @throws Exception\LdapException
  */
 public function update($dn, array $entry)
 {
     if (!$dn instanceof Dn) {
         $dn = Dn::factory($dn, null);
     }
     self::prepareLdapEntryArray($entry);
     $rdnParts = $dn->getRdn(Dn::ATTR_CASEFOLD_LOWER);
     foreach ($rdnParts as $key => $value) {
         $value = 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) {
         ErrorHandler::start(E_WARNING);
         $isModified = ldap_modify($this->getResource(), $dn->toString(), $entry);
         ErrorHandler::stop();
         if ($isModified === false) {
             throw new Exception\LdapException($this, 'updating: ' . $dn->toString());
         }
     }
     return $this;
 }