From 34c9a5e678a315e4e7b3ab33b37e5cdbb90c84f0 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 5 Oct 2006 17:51:17 +0000 Subject: [PATCH] added possibility to sync Samba password with Unix password in self service --- lam/lib/modules/sambaSamAccount.inc | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index 574a653f..16c6c3c5 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -174,6 +174,10 @@ class sambaSamAccount extends baseModule { 'sambaDomainName', 'sambaPrimaryGroupSID' ); + $return['selfServiceFieldSettings'] = array( + 'syncNTPassword' => _('Sync Samba NT password with Unix password'), + 'syncLMPassword' => _('Sync Samba LM password with Unix password') + ); // help Entries $return['help'] = array ( "displayName" => array( @@ -1627,6 +1631,38 @@ class sambaSamAccount extends baseModule { return $errors; } + /** + * Checks if all input values are correct and returns the LDAP commands which should be executed. + * + * @param string $fields input fields + * @param array $attributes LDAP attributes + * @return array messages and LDAP commands (array('messages' => array(), 'add' => array(), 'del' => array(), 'mod' => array())) + */ + function checkSelfServiceOptions($fields, $attributes) { + $return = array('messages' => array(), 'add' => array(), 'del' => array(), 'mod' => array()); + if (isset($_POST['posixAccount_password']) && ($_POST['posixAccount_password'] != '')) { + if ($_POST['posixAccount_password'] != $_POST['posixAccount_password2']) { + return; + } + else { + if (!get_preg($_POST['posixAccount_password'], 'password')) { + return; + } + else { + + // sync password + if (in_array('syncNTPassword', $fields)) { + $return['mod']['sambaNTPassword'][0] = ntPassword($_POST['posixAccount_password']); + } + if (in_array('syncLMPassword', $fields)) { + $return['mod']['sambaLMPassword'][0] = lmPassword($_POST['posixAccount_password']); + } + } + } + } + return $return; + } + } ?>