From 4066f8772d3fadca17e243cff94743f4e72435bf Mon Sep 17 00:00:00 2001 From: cajus Date: Thu, 21 Feb 2008 14:28:12 +0000 Subject: [PATCH] Added gosa-si function for smbpasswd git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9024 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/functions.inc | 50 +++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index c0281e743..7b135d285 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -2530,31 +2530,39 @@ function change_password ($dn, $password, $mode=0, $hash= "") function generate_smb_nt_hash($password) { global $config; - $tmp= $config->data['MAIN']['SMBHASH']." ".escapeshellarg($password); - @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $tmp, "Execute"); - exec($tmp, $ar); - flush(); - reset($ar); - $hash= current($ar); + # Try to use gosa-si? + if (isset($config->data['MAIN']['GOSA_SI'])){ + $hash= gosaSupportDaemon::send("gosa_gen_smb_hash", "GOSA", array("password" => $password)); + } else { + $tmp= $config->data['MAIN']['SMBHASH']." ".escapeshellarg($password); + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $tmp, "Execute"); + + exec($tmp, $ar); + flush(); + reset($ar); + $hash= current($ar); + } + if ($hash == "") { - msg_dialog::display(_("Configuration error"), _("Setting for SMBHASH in gosa.conf is incorrect! Cannot change Samba password."), ERROR_DIALOG); + msg_dialog::display(_("Configuration error"), _("Cannot generate samba hash!"), ERROR_DIALOG); + return (""); + } + + list($lm,$nt)= split (":", trim($hash)); + + if ($config->current['SAMBAVERSION'] == 3) { + $attrs['sambaLMPassword']= $lm; + $attrs['sambaNTPassword']= $nt; + $attrs['sambaPwdLastSet']= date('U'); + $attrs['sambaBadPasswordCount']= "0"; + $attrs['sambaBadPasswordTime']= "0"; } else { - list($lm,$nt)= split (":", trim($hash)); - - if ($config->current['SAMBAVERSION'] == 3) { - $attrs['sambaLMPassword']= $lm; - $attrs['sambaNTPassword']= $nt; - $attrs['sambaPwdLastSet']= date('U'); - $attrs['sambaBadPasswordCount']= "0"; - $attrs['sambaBadPasswordTime']= "0"; - } else { - $attrs['lmPassword']= $lm; - $attrs['ntPassword']= $nt; - $attrs['pwdLastSet']= date('U'); - } - return($attrs); + $attrs['lmPassword']= $lm; + $attrs['ntPassword']= $nt; + $attrs['pwdLastSet']= date('U'); } + return($attrs); } -- 2.30.2