/** * Write an entry * * @param peer.ldap.LDAPEntry entry * @throws lang.IllegalArgumentException in case the parameter is not an LDAPEntry object */ public function write(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"); }
/** * 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; }