support ou=addressbook (RFE 117)

This commit is contained in:
Roland Gruber 2015-05-23 12:10:55 +00:00
parent 3f175a9823
commit 209eeab251
4 changed files with 78 additions and 20 deletions

View File

@ -4,6 +4,7 @@ June 2015
- Zarafa users: allow to change display format of "Send As" - Zarafa users: allow to change display format of "Send As"
- User list: support to filter by account status - User list: support to filter by account status
- Lamdaemon: update group of home directory if user's primary group changes - Lamdaemon: update group of home directory if user's primary group changes
- Personal: allow to add ou=addressbook subentry for users
- LAM Pro: - LAM Pro:
-> Password Self Reset: added 389 Directory Server schema file -> Password Self Reset: added 389 Directory Server schema file

View File

@ -2,7 +2,7 @@
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
<book> <book>
<title>LDAP Account Manager - Manual</title> <title>lamlamghfhlllLDAP Account Manager - Manual</title>
<preface> <preface>
<title>Overview</title> <title>Overview</title>
@ -17,7 +17,7 @@
for account creation and use multiple configuration profiles.</para> for account creation and use multiple configuration profiles.</para>
<para><ulink <para><ulink
url="https://www.ldap-account-manager.org/">https://www.ldap-account-manager.org/</ulink></para> url="https://www.ldap-account-manager.org/">sdfdsfdshttps://www.ldap-account-manager.org/</ulink></para>
<para>Copyright (C) 2003 - 2014 Roland Gruber <para>Copyright (C) 2003 - 2014 Roland Gruber
&lt;post@rolandgruber.de&gt;</para> &lt;post@rolandgruber.de&gt;</para>
@ -2291,7 +2291,9 @@ Have fun!
all of them. You can hide fields in module settings.</para> all of them. You can hide fields in module settings.</para>
<para>In advanced options you may also set fields to read-only (for <para>In advanced options you may also set fields to read-only (for
existing accounts) and define limits for photo files.</para> existing accounts) and define limits for photo files. Additionally,
you can add an "ou=addressbook" subentry to each user in case you
manage user addressbooks.</para>
<screenshot> <screenshot>
<mediaobject> <mediaobject>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 61 KiB

View File

@ -870,6 +870,10 @@ class inetOrgPerson extends baseModule implements passwordService {
"Headline" => _('Image cropping'), "Headline" => _('Image cropping'),
"Text" => _('Uploaded images will be cropped to these maximum values.') "Text" => _('Uploaded images will be cropped to these maximum values.')
), ),
'addAddressbook' => array(
"Headline" => _('Add addressbook (ou=addressbook)'),
"Text" => _('Adds an "ou=addressbook" subentry to each user.')
),
); );
return $return; return $return;
} }
@ -976,6 +980,41 @@ class inetOrgPerson extends baseModule implements passwordService {
return $return; return $return;
} }
/**
* Runs the postmodify actions.
*
* @see baseModule::postModifyActions()
*
* @param boolean $newAccount
* @param array $attributes LDAP attributes of this entry
* @return array array which contains status messages. Each entry is an array containing the status message parameters.
*/
public function postModifyActions($newAccount, $attributes) {
$messages = array();
// add address book
if ($this->isBooleanConfigOptionSet('inetOrgPerson_addAddressbook')) {
$dn = 'ou=addressbook,' . $this->getAccountContainer()->finalDN;
$result = ldapGetDN($dn);
if (empty($result)) {
$ldapUser = $_SESSION['ldap']->decrypt_login();
$ldapUser = $ldapUser[0];
$attrs = array(
'objectClass' => array('organizationalUnit'),
'ou' => 'addressbook'
);
$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()) . ').');
$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);
}
}
}
return $messages;
}
/** /**
* Processes user input of the primary module page. * Processes user input of the primary module page.
* It checks if all input values are correct and updates the associated LDAP attributes. * It checks if all input values are correct and updates the associated LDAP attributes.
@ -2434,19 +2473,16 @@ class inetOrgPerson extends baseModule implements passwordService {
if (!checkIfWriteAccessIsAllowed($this->get_scope())) { if (!checkIfWriteAccessIsAllowed($this->get_scope())) {
die(); die();
} }
// mail sending is LAM Pro only
if (!isLAMProVersion()) {
return array (
'status' => 'finished',
'progress' => 100,
'errors' => array()
);
}
if (!isset($temp['counter'])) { if (!isset($temp['counter'])) {
$temp['counter'] = 0; $temp['counter'] = 0;
} }
$errors = array(); $errors = array();
if (!in_array($temp['counter'], $failed) && isset($ids['inetOrgPerson_email']) && ($data[$temp['counter']][$ids['inetOrgPerson_email']] != "")) { $dataSize = sizeof($data);
if (($temp['counter'] < $dataSize) && !in_array($temp['counter'], $failed)) {
// mail sending is LAM Pro only
if (isLAMProVersion()
&& isset($ids['inetOrgPerson_email'])
&& ($data[$temp['counter']][$ids['inetOrgPerson_email']] != "")) {
if (isset($ids['inetOrgPerson_sendPasswordMail']) && ($data[$temp['counter']][$ids['inetOrgPerson_sendPasswordMail']] == "true") if (isset($ids['inetOrgPerson_sendPasswordMail']) && ($data[$temp['counter']][$ids['inetOrgPerson_sendPasswordMail']] == "true")
&& isset($accounts[$temp['counter']]['INFO.userPasswordClearText'])) { && isset($accounts[$temp['counter']]['INFO.userPasswordClearText'])) {
$mailMessages = sendPasswordMail($accounts[$temp['counter']]['INFO.userPasswordClearText'], $accounts[$temp['counter']]); $mailMessages = sendPasswordMail($accounts[$temp['counter']]['INFO.userPasswordClearText'], $accounts[$temp['counter']]);
@ -2457,9 +2493,25 @@ class inetOrgPerson extends baseModule implements passwordService {
} }
} }
} }
// add addressbook entry
if ($this->isBooleanConfigOptionSet('inetOrgPerson_addAddressbook')) {
$attrs = array(
'objectClass' => array('organizationalUnit'),
'ou' => 'addressbook'
);
$dn = 'ou=addressbook,' . $accounts[$temp['counter']]['dn'];
$success = @ldap_add($_SESSION['ldap']->server(), $dn, $attrs);
if (!$success) {
logNewMessage(LOG_ERR, 'Unable to add addressbook for user ' . $accounts[$temp['counter']]['dn'] . ' (' . 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, 'Added addressbook for user ' . $accounts[$temp['counter']]['dn']);
}
}
}
$temp['counter']++; $temp['counter']++;
$dataSize = sizeof($data); if ($temp['counter'] < $dataSize) {
if ($temp['counter'] < ($dataSize - 1)) {
return array ( return array (
'status' => 'inProgress', 'status' => 'inProgress',
'progress' => ($temp['counter'] * 100) / $dataSize, 'progress' => ($temp['counter'] * 100) / $dataSize,
@ -3780,6 +3832,9 @@ class inetOrgPerson extends baseModule implements passwordService {
} }
$configContainer->addElement($configContainerOptions, true); $configContainer->addElement($configContainerOptions, true);
$advancedOptions = new htmlTable(); $advancedOptions = new htmlTable();
$addressbookTable = new htmlTable();
$addressbookTable->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_addAddressbook', false, _('Add addressbook (ou=addressbook)'), 'addAddressbook'));
$advancedOptions->addElement($addressbookTable, true);
$advancedOptions->addElement(new htmlSubTitle(_('Read-only fields')), true); $advancedOptions->addElement(new htmlSubTitle(_('Read-only fields')), true);
$readOnlyOptions = array( $readOnlyOptions = array(
_('Description') => 'inetOrgPerson_readOnly_description', _('Street') => 'inetOrgPerson_readOnly_street', _('Description') => 'inetOrgPerson_readOnly_description', _('Street') => 'inetOrgPerson_readOnly_street',