我正在尝试为属性添加值。但它失败了,没有显示错误。这是我的代码:
function set_attribute($attribute, $uid, $service)
{
$entries = $this->get_account($uid);
if ($entries != false && count($entries) == 1) {
$entry = $entries[0];
$result = $entry->add(array($attribute => $service));
$changedEntry = Net_LDAP_Entry::createFresh($entry->dn(), $entry->getValues());
if (PEAR::isError($result))
return false;
else {
$ldap = $this->conn;
$ldap->delete($entry);
$ldap->add($changedEntry);
var_dump($entry->getValue($attribute)); // this result have new service
$entry = $ldap->getEntry($changedEntry->dn());
var_dump($entry->getValue($attribute)); // this result doesn't have new service
$result = $entry->update();
var_dump($result->getMessage()); // this results nothing
if (PEAR::isError($result))
return false;
}
return true;
} else
return false;
}
此函数返回true,不显示错误消息。