Beispiel #1
0
 /**
  * Write an entry
  *
  * @param   peer.ldap.LDAPEntry entry
  * @throws  lang.IllegalArgumentException in case the parameter is not an LDAPEntry object
  */
 public function write(\peer\ldap\LDAPEntry $entry)
 {
     $this->stream->write(sprintf("dn: %s\n", $entry->getDN()));
     foreach (array_keys($entry->attributes) as $key) {
         if ('dn' == $key) {
             continue;
         }
         for ($i = 0, $s = sizeof($entry->attributes[$key]); $i < $s; $i++) {
             $this->stream->write(sprintf("%s: %s\n", $key, $entry->attributes[$key][$i]));
         }
     }
     $this->stream->write("\n");
 }
Beispiel #2
0
 /**
  * Add an attribute to an entry
  *
  * @param   peer.ldap.LDAPEntry entry
  * @param   string name
  * @param   var value
  * @return  bool
  */
 public function replaceAttribute(LDAPEntry $entry, $name, $value)
 {
     if (false == ($res = ldap_mod_replace($this->_hdl, $entry->getDN(), array($name => $value)))) {
         throw new LDAPException('Add attribute for "' . $entry->getDN() . '" failed', ldap_errno($this->_hdl));
     }
     return $res;
 }
 /** @return peer.ldap.LDAPEntry */
 protected function newInstance($dn, $attributes)
 {
     return LDAPEntry::create($dn, $attributes);
 }
 /**
  * Add an attribute to an entry
  *
  * @param   peer.ldap.LDAPEntry entry
  * @param   string name
  * @param   var value
  * @return  bool
  */
 public function replaceAttribute(LDAPEntry $entry, $name, $value)
 {
     if (false == ($res = ldap_mod_replace($this->handle, $entry->getDN(), [$name => $value]))) {
         throw $this->error('Replace attribute for "' . $entry->getDN() . '" failed');
     }
     return $res;
 }