From 221a2d4eb6a2dfe3475ebf428de78781463f04f2 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 18 Mar 2011 13:47:12 +0000 Subject: [PATCH] read users full name from password file and create email address according to configured rules for automatic created accounts --- phpgwapi/inc/class.auth_pam.inc.php | 71 +++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 phpgwapi/inc/class.auth_pam.inc.php diff --git a/phpgwapi/inc/class.auth_pam.inc.php b/phpgwapi/inc/class.auth_pam.inc.php new file mode 100644 index 0000000000..100c75e7b7 --- /dev/null +++ b/phpgwapi/inc/class.auth_pam.inc.php @@ -0,0 +1,71 @@ +accounts->name2id($username) && + function_exists('posix_getpwnam') && ($data = posix_getpwnam($username))) + { + list($fullname) = explode(',',$data['gecos']); + $parts = explode(' ',$fullname); + if (count($parts) > 1) + { + $lastname = array_pop($parts); + $firstname = implode(' ',$parts); + $email = common::email_address($firstname, $lastname, $username); + + $GLOBALS['auto_create_acct'] = array( + 'firstname' => $firstname, + 'lastname' => $lastname, + 'email' => $email, + 'account_id' => $data['uid'], + ); + } + } + return True; + } + return False; + } + + /** + * changes password + * + * @param string $old_passwd must be cleartext or empty to not to be checked + * @param string $new_passwd must be cleartext + * @param int $account_id=0 account id of user whose passwd should be changed + * @return boolean true if password successful changed, false otherwise + */ + function change_password($old_passwd, $new_passwd, $account_id=0) + { + // deny password changes. + return False; + } +}