"ou=groups,",
- "applicationou" => "ou=apps,",
- "systemsou" => "ou=systems,",
- "serverou" => "ou=servers,ou=systems,",
- "terminalou" => "ou=terminals,ou=systems,",
- "workstationou" => "ou=workstations,ou=systems,",
- "printerou" => "ou=printers,ou=systems,",
- "phoneou" => "ou=phones,ou=systems,",
- "componentou" => "ou=netdevices,ou=systems,",
- "winstations" => "ou=winstation,",
-
- "blocklistou" => "ou=gofax,ou=systems,",
- "incomingou" => "ou=incoming,",
- "aclroleou" => "ou=aclroles,",
- "macroou" => "ou=macros,ou=asterisk,ou=configs,ou=systems,",
- "conferenceou" => "ou=conferences,ou=asterisk,ou=configs,ou=systems,",
-
- "faiou" => "ou=fai,ou=configs,ou=systems,",
- "faiscriptou" => "ou=scripts,",
- "faihookou" => "ou=hooks,",
- "faitemplateou" => "ou=templates,",
- "faivariableou" => "ou=variables,",
- "faiprofileou" => "ou=profiles,",
- "faipackageou" => "ou=packages,",
- "faipartitionou"=> "ou=disk,",
-
- "deviceou" => "ou=devices,",
- "mimetypeou" => "ou=mime,");
+ "roleRDN" => "ou=roles,",
+ "ogroupRDN" => "ou=groups,",
+ "applicationRDN" => "ou=apps,",
+ "systemRDN" => "ou=systems,",
+ "serverRDN" => "ou=servers,ou=systems,",
+ "terminalRDN" => "ou=terminals,ou=systems,",
+ "workstationRDN" => "ou=workstations,ou=systems,",
+ "printerRDN" => "ou=printers,ou=systems,",
+ "phoneRDN" => "ou=phones,ou=systems,",
+ "componentRDN" => "ou=netdevices,ou=systems,",
+ "sambaMachineAccountRDN" => "ou=winstation,",
+
+ "faxBlocklistRDN" => "ou=gofax,ou=systems,",
+ "systemIncomingRDN" => "ou=incoming,",
+ "aclRoleRDN" => "ou=aclroles,",
+ "phoneMacroRDN" => "ou=macros,ou=asterisk,ou=configs,ou=systems,",
+ "phoneConferenceRDN" => "ou=conferences,ou=asterisk,ou=configs,ou=systems,",
+
+ "faiBaseRDN" => "ou=fai,ou=configs,ou=systems,",
+ "faiScriptRDN" => "ou=scripts,",
+ "faiHookRDN" => "ou=hooks,",
+ "faiTemplateRDN" => "ou=templates,",
+ "faiVariableRDN" => "ou=variables,",
+ "faiProfileRDN" => "ou=profiles,",
+ "faiPackageRDN" => "ou=packages,",
+ "faiPartitionRDN"=> "ou=disk,",
+
+ "sudoRDN" => "ou=sudoers,",
+
+ "deviceRDN" => "ou=devices,",
+ "mimetypeRDN" => "ou=mime,");
/* Preset ou... */
if ($config->get_cfg_value($name, "_not_set_") != "_not_set_"){
@@ -1201,7 +1216,7 @@ function get_ou($name)
$ou = @LDAP::convert("$ou");
}
- if(preg_match("/".normalizePreg($config->current['BASE'])."$/",$ou)){
+ if(preg_match("/".preg_quote($config->current['BASE'], '/')."$/",$ou)){
return($ou);
}else{
return("$ou,");
@@ -1215,19 +1230,19 @@ function get_ou($name)
function get_people_ou()
{
- return (get_ou("USERRDN"));
+ return (get_ou("userRDN"));
}
function get_groups_ou()
{
- return (get_ou("GROUPS"));
+ return (get_ou("groupRDN"));
}
function get_winstations_ou()
{
- return (get_ou("WINSTATIONS"));
+ return (get_ou("sambaMachineAccountRDN"));
}
@@ -1235,7 +1250,7 @@ function get_base_from_people($dn)
{
global $config;
- $pattern= "/^[^,]+,".preg_quote(get_people_ou())."/i";
+ $pattern= "/^[^,]+,".preg_quote(get_people_ou(), '/')."/i";
$base= preg_replace($pattern, '', $dn);
/* Set to base, if we're not on a correct subtree */
@@ -1252,7 +1267,7 @@ function strict_uid_mode()
global $config;
if (isset($config)){
- return ($config->get_cfg_value("strict") == "true");
+ return ($config->get_cfg_value("strictNamingRules") == "true");
}
return (TRUE);
}
@@ -1270,7 +1285,7 @@ function get_uid_regexp()
}
-function gen_locked_message($user, $dn)
+function gen_locked_message($user, $dn, $allow_readonly = FALSE)
{
global $plug, $config;
@@ -1307,7 +1322,7 @@ function gen_locked_message($user, $dn)
/* Prepare and show template */
$smarty= get_smarty();
-
+ $smarty->assign("allow_readonly",$allow_readonly);
if(is_array($dn)){
$msg = "";
foreach($dn as $sub_dn){
@@ -1362,7 +1377,7 @@ function rewrite($s)
global $REWRITE;
foreach ($REWRITE as $key => $val){
- $s= preg_replace("/$key/", "$val", $s);
+ $s= str_replace("$key", "$val", $s);
}
return ($s);
@@ -1613,7 +1628,7 @@ function recurse($rule, $variables)
unset ($variables[$key]);
foreach($val as $possibility){
- $nrule= preg_replace("/\{$key\}/", $possibility, $rule);
+ $nrule= str_replace("{$key}", $possibility, $rule);
$result= array_merge($result, recurse($nrule, $variables));
}
@@ -1631,7 +1646,7 @@ function expand_id($rule, $attributes)
/* Check for clean attribute */
if (preg_match('/^%[a-zA-Z0-9]+$/', $rule)){
$rule= preg_replace('/^%/', '', $rule);
- $val= rewrite(preg_replace('/ /', '', strtolower($attributes[$rule])));
+ $val= rewrite(str_replace(' ', '', strtolower($attributes[$rule])));
return (array($val));
}
@@ -1639,7 +1654,7 @@ function expand_id($rule, $attributes)
if (preg_match('/^%[a-zA-Z0-9]+\[[0-9-]+\]$/', $rule)){
$param= preg_replace('/^[^[]+\[([^]]+)]$/', '\\1', $rule);
$part= preg_replace('/^%/', '', preg_replace('/\[.*$/', '', $rule));
- $val= rewrite(preg_replace('/ /', '', strtolower($attributes[$part])));
+ $val= rewrite(str_replace(' ', '', strtolower($attributes[$part])));
$start= preg_replace ('/-.*$/', '', $param);
$stop = preg_replace ('/^[^-]+-/', '', $param);
@@ -1651,7 +1666,7 @@ function expand_id($rule, $attributes)
return ($result);
}
- echo "Error in idgen string: don't know how to handle rule $rule.\n";
+ echo "Error in idGenerator string: don't know how to handle rule $rule.\n";
return (array($rule));
}
@@ -1667,7 +1682,7 @@ function gen_uids($rule, $attributes)
$stripped= "";
$variables= array();
- for ($pos= 0; $pos < strlen($rule); $pos++){
+ for ($pos= 0, $l= strlen($rule); $pos < $l; $pos++){
if ($rule[$pos] == "{" ){
$trigger= true;
@@ -1710,7 +1725,7 @@ function gen_uids($rule, $attributes)
if(preg_match('/\{id:\d+}/',$uid)){
$size= preg_replace('/^.*{id:(\d+)}.*$/', '\\1', $uid);
- for ($i= 0; $i < pow(10,$size); $i++){
+ for ($i= 0, $p= pow(10,$size); $i < $p; $i++){
$number= sprintf("%0".$size."d", $i);
$res= preg_replace('/{id:(\d+)}/', $number, $uid);
if (!in_array($res, $used)){
@@ -1720,27 +1735,28 @@ function gen_uids($rule, $attributes)
}
}
- if(preg_match('/\{id#\d+}/',$uid)){
- $size= preg_replace('/^.*{id#(\d+)}.*$/', '\\1', $uid);
+ if(preg_match('/\{id#\d+}/',$uid)){
+ $size= preg_replace('/^.*{id#(\d+)}.*$/', '\\1', $uid);
- while (true){
- mt_srand((double) microtime()*1000000);
- $number= sprintf("%0".$size."d", mt_rand(0, pow(10, $size)-1));
- $res= preg_replace('/{id#(\d+)}/', $number, $uid);
- if (!in_array($res, $used)){
- $uid= $res;
- break;
+ while (true){
+ mt_srand((double) microtime()*1000000);
+ $number= sprintf("%0".$size."d", mt_rand(0, pow(10, $size)-1));
+ $res= preg_replace('/{id#(\d+)}/', $number, $uid);
+ if (!in_array($res, $used)){
+ $uid= $res;
+ break;
+ }
}
}
- }
-/* Don't assign used ones */
-if (!in_array($uid, $used)){
- $ret[]= $uid;
-}
-}
+ /* Don't assign used ones */
+ if (!in_array($uid, $used)){
+ /* Add uid, but remove {} first. These are invalid anyway. */
+ $ret[]= preg_replace('/[{}]/', '', $uid);
+ }
+ }
-return(array_unique($ret));
+ return(array_unique($ret));
}
@@ -1772,18 +1788,8 @@ function to_byte($value) {
function in_array_ics($value, $items)
{
- if (!is_array($items)){
- return (FALSE);
- }
-
- foreach ($items as $item){
- if (strcasecmp($item, $value) == 0) {
- return (TRUE);
- }
- }
-
- return (FALSE);
-}
+ return preg_grep('/^'.preg_quote($value, '/').'$/i', $items);
+}
function generate_alphabet($count= 10)
@@ -1793,7 +1799,7 @@ function generate_alphabet($count= 10)
$c= 0;
/* Fill cells with charaters */
- for ($i= 0; $i";
}
@@ -1819,7 +1825,7 @@ function generate_alphabet($count= 10)
function validate($string)
{
- return (strip_tags(preg_replace('/\0/', '', $string)));
+ return (strip_tags(str_replace('\0', '', $string)));
}
@@ -1977,56 +1983,19 @@ function compare_revision($revision_file, $revision)
function progressbar($percentage,$width=100,$height=15,$showvalue=false)
{
- $str = ""; // Our return value will be saved in this var
-
- $color = dechex($percentage+150);
- $color2 = dechex(150 - $percentage);
- $bgcolor= $showvalue?"FFFFFF":"DDDDDD";
-
- $progress = (int)(($percentage /100)*$width);
-
- /* If theres a better solution for this, use it... */
- $str = "\n ";
-
- $str.= "\n
";
-
- if(($height >10)&&($showvalue)){
- $str.= "\n
";
- $str.= "\n ".$percentage."% ";
- $str.= "\n ";
- }
-
- $str.= "\n
";
- $str.= "\n
";
- $str.= "\n
";
- $str.= "\n
";
-
- return($str);
+ return("");
}
function array_key_ics($ikey, $items)
{
- /* Gather keys, make them lowercase */
- $tmp= array();
- foreach ($items as $key => $value){
- $tmp[strtolower($key)]= $key;
- }
-
- if (isset($tmp[strtolower($ikey)])){
- return($tmp[strtolower($ikey)]);
+ $tmp= array_change_key_case($items, CASE_LOWER);
+ $ikey= strtolower($ikey);
+ if (isset($tmp[$ikey])){
+ return($tmp[$ikey]);
}
- return ("");
+ return ('');
}
@@ -2037,15 +2006,7 @@ function array_differs($src, $dst)
return (TRUE);
}
- /* So the count is the same - lets check the contents */
- $differs= FALSE;
- foreach($src as $value){
- if (!in_array($value, $dst)){
- $differs= TRUE;
- }
- }
-
- return ($differs);
+ return (count(array_diff($src, $dst)) != 0);
}
@@ -2076,13 +2037,6 @@ function saveFilter($a_filter, $values)
}
-/* Escape all preg_* relevant characters */
-function normalizePreg($input)
-{
- return (addcslashes($input, '[]()|/.*+-'));
-}
-
-
/* Escape all LDAP filter relevant characters */
function normalizeLdap($input)
{
@@ -2192,10 +2146,10 @@ function get_base_from_hook($dn, $attrib)
{
global $config;
- if ($config->get_cfg_value("base_hook") != ""){
+ if ($config->get_cfg_value("baseIdHook") != ""){
/* Call hook script - if present */
- $command= $config->get_cfg_value("base_hook");
+ $command= $config->get_cfg_value("baseIdHook");
if ($command != ""){
$command.= " '".LDAP::fix($dn)."' $attrib";
@@ -2205,18 +2159,18 @@ function get_base_from_hook($dn, $attrib)
if (preg_match("/^[0-9]+$/", $output[0])){
return ($output[0]);
} else {
- msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base!"), WARNING_DIALOG);
- return ($config->get_cfg_value("uidbase"));
+ msg_dialog::display(_("Warning"), _("'baseIdHook' is not available. Using default base!"), WARNING_DIALOG);
+ return ($config->get_cfg_value("uidNumberBase"));
}
} else {
- msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base!"), WARNING_DIALOG);
- return ($config->get_cfg_value("uidbase"));
+ msg_dialog::display(_("Warning"), _("'baseIdHook' is not available. Using default base!"), WARNING_DIALOG);
+ return ($config->get_cfg_value("uidNumberBase"));
}
} else {
- msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base!"), WARNING_DIALOG);
- return ($config->get_cfg_value("uidbase"));
+ msg_dialog::display(_("Warning"), _("'baseIdHook' is not available. Using default base!"), WARNING_DIALOG);
+ return ($config->get_cfg_value("uidNumberBase"));
}
}
@@ -2234,7 +2188,7 @@ function check_schema($cfg,$rfc2307bis = FALSE)
$messages= array();
/* Get objectclasses */
- $ldap = new ldapMultiplexer(new LDAP($cfg['admin'],$cfg['password'],$cfg['connection'] ,FALSE,$cfg['tls']));
+ $ldap = new ldapMultiplexer(new LDAP($cfg['admin'],$cfg['password'],$cfg['connection'] ,FALSE, $cfg['tls']));
$objectclasses = $ldap->get_objectclasses();
if(count($objectclasses) == 0){
msg_dialog::display(_("LDAP warning"), _("Cannot get schema information from server. No schema check possible!"), WARNING_DIALOG);
@@ -2253,20 +2207,20 @@ function check_schema($cfg,$rfc2307bis = FALSE)
/* The gosa base schema */
$checks['gosaObject'] = $def_check;
- $checks['gosaObject']['REQUIRED_VERSION'] = "2.4";
+ $checks['gosaObject']['REQUIRED_VERSION'] = "2.6.1";
$checks['gosaObject']['SCHEMA_FILES'] = array("gosa+samba3.schema","gosa.schema");
$checks['gosaObject']['CLASSES_REQUIRED'] = array("gosaObject");
$checks['gosaObject']['IS_MUST_HAVE'] = TRUE;
/* GOsa Account class */
- $checks["gosaAccount"]["REQUIRED_VERSION"]= "2.4";
+ $checks["gosaAccount"]["REQUIRED_VERSION"]= "2.6.1";
$checks["gosaAccount"]["SCHEMA_FILES"] = array("gosa+samba3.schema","gosa.schema");
$checks["gosaAccount"]["CLASSES_REQUIRED"]= array("gosaAccount");
$checks["gosaAccount"]["IS_MUST_HAVE"] = TRUE;
$checks["gosaAccount"]["INFO"] = _("Used to store account specific informations.");
/* GOsa lock entry, used to mark currently edited objects as 'in use' */
- $checks["gosaLockEntry"]["REQUIRED_VERSION"] = "2.4";
+ $checks["gosaLockEntry"]["REQUIRED_VERSION"] = "2.6.1";
$checks["gosaLockEntry"]["SCHEMA_FILES"] = array("gosa+samba3.schema","gosa.schema");
$checks["gosaLockEntry"]["CLASSES_REQUIRED"] = array("gosaLockEntry");
$checks["gosaLockEntry"]["IS_MUST_HAVE"] = TRUE;
@@ -2274,28 +2228,28 @@ function check_schema($cfg,$rfc2307bis = FALSE)
/* Some other checks */
foreach(array(
- "gosaCacheEntry" => array("version" => "2.4"),
- "gosaDepartment" => array("version" => "2.4"),
+ "gosaCacheEntry" => array("version" => "2.6.1"),
+ "gosaDepartment" => array("version" => "2.6.1"),
"goFaxAccount" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
"goFaxSBlock" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
"goFaxRBlock" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
- "gosaUserTemplate" => array("version" => "2.4", "class" => "posixAccount","file" => "nis.schema"),
- "gosaMailAccount" => array("version" => "2.4", "class" => "mailAccount","file" => "gosa+samba3.schema"),
- "gosaProxyAccount" => array("version" => "2.4", "class" => "proxyAccount","file" => "gosa+samba3.schema"),
- "gosaApplication" => array("version" => "2.4", "class" => "appgroup","file" => "gosa.schema"),
- "gosaApplicationGroup" => array("version" => "2.4", "class" => "appgroup","file" => "gosa.schema"),
- "GOhard" => array("version" => "2.5", "class" => "terminals","file" => "goto.schema"),
- "gotoTerminal" => array("version" => "2.5", "class" => "terminals","file" => "goto.schema"),
- "goServer" => array("version" => "2.4","class" => "server","file" => "goserver.schema"),
- "goTerminalServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
- "goShareServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
- "goNtpServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
- "goSyslogServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
- "goLdapServer" => array("version" => "2.4"),
- "goCupsServer" => array("version" => "2.4", "class" => array("posixAccount", "terminals"),),
- "goImapServer" => array("version" => "2.4", "class" => array("mailAccount", "mailgroup"),"file" => "gosa+samba3. schema"),
- "goKrbServer" => array("version" => "2.4"),
- "goFaxServer" => array("version" => "2.4", "class" => "gofaxAccount","file" => "gofax.schema"),
+ "gosaUserTemplate" => array("version" => "2.6.1", "class" => "posixAccount","file" => "nis.schema"),
+ "gosaMailAccount" => array("version" => "2.6.1", "class" => "mailAccount","file" => "gosa+samba3.schema"),
+ "gosaProxyAccount" => array("version" => "2.6.1", "class" => "proxyAccount","file" => "gosa+samba3.schema"),
+ "gosaApplication" => array("version" => "2.6.1", "class" => "appgroup","file" => "gosa.schema"),
+ "gosaApplicationGroup" => array("version" => "2.6.1", "class" => "appgroup","file" => "gosa.schema"),
+ "GOhard" => array("version" => "2.6.1", "class" => "terminals","file" => "goto.schema"),
+ "gotoTerminal" => array("version" => "2.6.1", "class" => "terminals","file" => "goto.schema"),
+ "goServer" => array("version" => "2.6.1","class" => "server","file" => "goserver.schema"),
+ "goTerminalServer" => array("version" => "2.6.1", "class" => "terminals","file" => "goto.schema"),
+ "goShareServer" => array("version" => "2.6.1", "class" => "terminals","file" => "goto.schema"),
+ "goNtpServer" => array("version" => "2.6.1", "class" => "terminals","file" => "goto.schema"),
+ "goSyslogServer" => array("version" => "2.6.1", "class" => "terminals","file" => "goto.schema"),
+ "goLdapServer" => array("version" => "2.6.1"),
+ "goCupsServer" => array("version" => "2.6.1", "class" => array("posixAccount", "terminals"),),
+ "goImapServer" => array("version" => "2.6.1", "class" => array("mailAccount", "mailgroup"),"file" => "gosa+samba3. schema"),
+ "goKrbServer" => array("version" => "2.6.1"),
+ "goFaxServer" => array("version" => "2.6.1", "class" => "gofaxAccount","file" => "gofax.schema"),
) as $name => $values){
$checks[$name] = $def_check;
@@ -2336,7 +2290,7 @@ function check_schema($cfg,$rfc2307bis = FALSE)
/* The gosa base schema */
$checks['posixGroup'] = $def_check;
- $checks['posixGroup']['REQUIRED_VERSION'] = "2.4";
+ $checks['posixGroup']['REQUIRED_VERSION'] = "2.6.1";
$checks['posixGroup']['SCHEMA_FILES'] = array("gosa+samba3.schema","gosa.schema");
$checks['posixGroup']['CLASSES_REQUIRED'] = array("posixGroup");
$checks['posixGroup']['STATUS'] = TRUE;
@@ -2373,7 +2327,7 @@ function get_languages($languages_in_own_language = FALSE,$strip_region_tag = FA
"en_US" => "English",
"nl_NL" => "Dutch",
"pl_PL" => "Polish",
- "sv_SE" => "Swedish",
+ #"sv_SE" => "Swedish",
"zh_CN" => "Chinese",
"vi_VN" => "Vietnamese",
"ru_RU" => "Russian");
@@ -2386,7 +2340,7 @@ function get_languages($languages_in_own_language = FALSE,$strip_region_tag = FA
"en_US" => _("English"),
"nl_NL" => _("Dutch"),
"pl_PL" => _("Polish"),
- "sv_SE" => _("Swedish"),
+ #"sv_SE" => _("Swedish"),
"zh_CN" => _("Chinese"),
"vi_VN" => _("Vietnamese"),
"ru_RU" => _("Russian"));
@@ -2478,13 +2432,6 @@ function change_password ($dn, $password, $mode=0, $hash= "")
$ldap->cat ($dn, array("shadowLastChange", "userPassword", "uid"));
$attrs = $ldap->fetch ();
- // Check if user account was deactivated, indicated by ! after } ... {crypt}!###
- if(isset($attrs['userPassword'][0]) && preg_match("/^[^\}]*+\}!/",$attrs['userPassword'][0])){
- $deactivated = TRUE;
- }else{
- $deactivated = FALSE;
- }
-
/* Is ensure that clear passwords will stay clear */
if($hash == "" && isset($attrs['userPassword'][0]) && !preg_match ("/^{([^}]+)}(.+)/", $attrs['userPassword'][0])){
$hash = "clear";
@@ -2510,72 +2457,77 @@ function change_password ($dn, $password, $mode=0, $hash= "")
$test = new $available['md5']($config);
}
- /* Feed password backends with information */
- $test->dn= $dn;
- $test->attrs= $attrs;
- $newpass= $test->generate_hash($password);
-
- // Update shadow timestamp?
- if (isset($attrs["shadowLastChange"][0])){
- $shadow= (int)(date("U") / 86400);
- } else {
- $shadow= 0;
- }
+ if($test instanceOf passwordMethod){
- // Write back modified entry
- $ldap->cd($dn);
- $attrs= array();
+ $deactivated = $test->is_locked($config,$dn);
- // Not for groups
- if ($mode == 0){
+ /* Feed password backends with information */
+ $test->dn= $dn;
+ $test->attrs= $attrs;
+ $newpass= $test->generate_hash($password);
- if ($shadow != 0){
- $attrs['shadowLastChange']= $shadow;
+ // Update shadow timestamp?
+ if (isset($attrs["shadowLastChange"][0])){
+ $shadow= (int)(date("U") / 86400);
+ } else {
+ $shadow= 0;
}
- // Create SMB Password
- $attrs= generate_smb_nt_hash($password);
- }
+ // Write back modified entry
+ $ldap->cd($dn);
+ $attrs= array();
- /* Read ! if user was deactivated */
- if($deactivated){
- $newpass = preg_replace("/(^[^\}]+\})(.*$)/","\\1!\\2",$newpass);
- }
+ // Not for groups
+ if ($mode == 0){
- $attrs['userPassword']= array();
- $attrs['userPassword']= $newpass;
+ if ($shadow != 0){
+ $attrs['shadowLastChange']= $shadow;
+ }
- $ldap->modify($attrs);
+ // Create SMB Password
+ $attrs= generate_smb_nt_hash($password);
+ }
- new log("modify","users/passwordMethod",$dn,array_keys($attrs),$ldap->get_error());
+ $attrs['userPassword']= array();
+ $attrs['userPassword']= $newpass;
- if (!$ldap->success()) {
- msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, ERROR_DIALOG));
- } else {
+ $ldap->modify($attrs);
- /* Run backend method for change/create */
- if(!$test->set_password($password)){
- return(FALSE);
+ /* Read ! if user was deactivated */
+ if($deactivated){
+ $test->lock_account($config,$dn);
}
- /* Find postmodify entries for this class */
- $command= $config->search("password", "POSTMODIFY",array('menu'));
+ new log("modify","users/passwordMethod",$dn,array_keys($attrs),$ldap->get_error());
- if ($command != ""){
- /* Walk through attribute list */
- $command= preg_replace("/%userPassword/", $password, $command);
- $command= preg_replace("/%dn/", $dn, $command);
+ if (!$ldap->success()) {
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, ERROR_DIALOG));
+ } else {
- if (check_command($command)){
- @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute");
- exec($command);
- } else {
- $message= sprintf(_("Command '%s', specified as POSTMODIFY for plugin '%s' doesn't seem to exist."), $command, "password");
- msg_dialog::display(_("Configuration error"), $message, ERROR_DIALOG);
+ /* Run backend method for change/create */
+ if(!$test->set_password($password)){
+ return(FALSE);
+ }
+
+ /* Find postmodify entries for this class */
+ $command= $config->search("password", "POSTMODIFY",array('menu'));
+
+ if ($command != ""){
+ /* Walk through attribute list */
+ $command= preg_replace("/%userPassword/", $password, $command);
+ $command= preg_replace("/%dn/", $dn, $command);
+
+ if (check_command($command)){
+ @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute");
+ exec($command);
+ } else {
+ $message= sprintf(_("Command '%s', specified as POSTMODIFY for plugin '%s' doesn't seem to exist."), $command, "password");
+ msg_dialog::display(_("Configuration error"), $message, ERROR_DIALOG);
+ }
}
}
+ return(TRUE);
}
- return(TRUE);
}
@@ -2585,13 +2537,18 @@ function generate_smb_nt_hash($password)
global $config;
# Try to use gosa-si?
- if ($config->get_cfg_value("gosa_si") != ""){
+ if ($config->get_cfg_value("gosaSupportURI") != ""){
$res= gosaSupportDaemon::send("gosa_gen_smb_hash", "GOSA", array("password" => $password), TRUE);
if (isset($res['XML']['HASH'])){
$hash= $res['XML']['HASH'];
} else {
$hash= "";
}
+
+ if ($hash == "") {
+ msg_dialog::display(_("Configuration error"), _("Cannot generate samba hash!"), ERROR_DIALOG);
+ return ("");
+ }
} else {
$tmp= $config->get_cfg_value('sambaHashHook')." ".escapeshellarg($password);
@DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $tmp, "Execute");
@@ -2600,11 +2557,11 @@ function generate_smb_nt_hash($password)
flush();
reset($ar);
$hash= current($ar);
- }
- if ($hash == "") {
- msg_dialog::display(_("Configuration error"), _("Cannot generate samba hash!"), ERROR_DIALOG);
- return ("");
+ if ($hash == "") {
+ msg_dialog::display(_("Configuration error"), sprintf(_("Cannot generate samba hash: running '%s' failed, check the 'sambaHashHook'!"),$config->get_cfg_value('sambaHashHook')), ERROR_DIALOG);
+ return ("");
+ }
}
list($lm,$nt)= split (":", trim($hash));
@@ -2826,6 +2783,16 @@ function cred_decrypt($input,$password) {
return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $password, pack("H*", $input), MCRYPT_MODE_ECB, $iv);
}
+function get_object_info()
+{
+ return(session::get('objectinfo'));
+}
+
+function set_object_info($str = "")
+{
+ session::set('objectinfo',$str);
+}
+
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>