support ou=addressbook (RFE 117)

This commit is contained in:
Roland Gruber 2015-06-17 19:41:48 +00:00
parent 5aa5b7b4b0
commit 0edcb1401a
1 changed files with 5 additions and 4 deletions

View File

@ -992,8 +992,9 @@ class inetOrgPerson extends baseModule implements passwordService {
public function postModifyActions($newAccount, $attributes) {
$messages = array();
// add address book
if ($this->isBooleanConfigOptionSet('inetOrgPerson_addAddressbook')) {
$dn = 'ou=addressbook,' . $this->getAccountContainer()->finalDN;
$accountContainer = $this->getAccountContainer();
if ($this->isBooleanConfigOptionSet('inetOrgPerson_addAddressbook') && !empty($accountContainer)) {
$dn = 'ou=addressbook,' . $accountContainer->finalDN;
$result = ldapGetDN($dn);
if (empty($result)) {
$ldapUser = $_SESSION['ldap']->decrypt_login();
@ -1004,11 +1005,11 @@ class inetOrgPerson extends baseModule implements passwordService {
);
$success = @ldap_add($_SESSION['ldap']->server(), $dn, $attrs);
if (!$success) {
logNewMessage(LOG_ERR, '[' . $ldapUser .'] Unable to add addressbook for user ' . $this->getAccountContainer()->finalDN . ' (' . ldap_error($_SESSION['ldap']->server()) . ').');
logNewMessage(LOG_ERR, '[' . $ldapUser .'] Unable to add addressbook for user ' . $accountContainer->finalDN . ' (' . ldap_error($_SESSION['ldap']->server()) . ').');
$messages[] = array('ERROR', sprintf(_("Was unable to create DN: %s."), htmlspecialchars($dn)), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
}
else {
logNewMessage(LOG_NOTICE, '[' . $ldapUser .'] Added addressbook for user ' . $this->getAccountContainer()->finalDN);
logNewMessage(LOG_NOTICE, '[' . $ldapUser .'] Added addressbook for user ' . $accountContainer->finalDN);
}
}
}