diff --git a/lam/lib/account.inc b/lam/lib/account.inc index 68e318ff..2d900b72 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -281,6 +281,21 @@ function pwd_is_enabled($hash) { else return true; } +/** + * Generates a random password with 12 digits. + * + * @return String password + */ +function generateRandomPassword() { + $list = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_'; + $password = ''; + for ($i = 0; $i < 12; $i++) { + $rand = $_SESSION['ldap']->new_rand() % 65; + $password .= $list[$rand]; + } + return $password; +} + /** * Returns an array with all Samba 3 domain entries under the given suffix *