83cfce3127b50000cddbe339908d9eb4ebe0df26
1 <?php
2 /*
3 This code is part of GOsa (https://gosa.gonicus.de)
4 Copyright (C) 2004-2005 Cajus Pollmeier
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
21 class sambaAccount extends plugin
22 {
23 /* Definitions */
24 var $plHeadline= "Samba";
25 var $plDescription= "This does something";
26 var $view_logged = FALSE;
28 /* Switch for Samba version */
29 var $samba3= FALSE;
30 var $uidNumber= 65535;
31 var $gidNumber= 65535;
33 /* Samba 3 infos */
34 var $display_information = FALSE;
36 /* Samba 2 attributes */
37 var $pwdLastSet= "0";
38 var $logonTime= "0";
39 var $logoffTime= "2147483647";
40 var $kickoffTime= "2147483647";
41 var $pwdCanChange= "0";
42 var $pwdMustChange= "0";
43 var $password_expires= 0;
44 var $acctFlags= "[UX ]";
45 var $smbHome= "";
46 var $homeDrive= "";
47 var $scriptPath= "";
48 var $profilePath= "";
49 var $rid= "";
50 var $primaryGroupID= "";
52 /* Samba 3 attributes */
53 var $SID= "";
54 var $ridBase= 0;
55 var $sambaSID= "";
56 var $sambaPwdLastSet= "0";
57 var $sambaLogonTime= "0";
58 var $sambaLogoffTime= "2147483647";
59 var $sambaKickoffTime= "2147483647";
60 var $sambaPwdCanChange= "";
61 var $sambaPwdMustChange= "0";
62 var $sambaAcctFlags= "[UX ]";
63 var $sambaHomePath= "";
64 var $sambaHomeDrive= "";
65 var $sambaLogonScript= "";
66 var $sambaProfilePath= "";
67 var $sambaPrimaryGroupSID= "";
68 var $sambaDomainName= "";
69 var $sambaUserWorkstations= "";
70 var $sambaBadPasswordCount= "";
71 var $sambaBadPasswordTime= "";
72 var $sambaPasswordHistory= "";
73 var $sambaLogonHours= "";
74 var $orig_sambaDomainName= "";
75 var $sambaMungedDial= "";
76 var $mungedObject;
78 /* Helper */
79 var $show_ws_dialog= FALSE;
80 var $logon_time_set= 0;
81 var $logoff_time_set= 0;
82 var $kickoff_time_set= 0;
84 /* attribute list for save action */
85 var $ctxattributes= array();
86 var $attributes= array();
87 var $objectclasses= array();
89 var $uid= "";
90 var $CopyPasteVars = array("kickoff_time_set","logoff_time_set","logon_time_set","mungedObject","orig_sambaDomainName");
92 var $multiple_support = TRUE;
94 /* Only used for multiple edit */
95 var $temporary_disable = FALSE;
96 var $no_password_required = FALSE;
97 var $multiple_sambaUserWorkstations = array();
99 function sambaAccount (&$config, $dn= NULL)
100 {
101 /* Load attributes depending on the samba version */
102 $this->samba3= ($config->get_cfg_value("sambaversion") == 3);
104 if ($this->samba3){
105 $this->attributes= array ("sambaSID", "sambaPwdLastSet", "sambaLogonTime",
106 "sambaLogoffTime", "sambaKickoffTime", "sambaPwdCanChange",
107 "sambaPwdMustChange", "sambaAcctFlags", "uid", "sambaMungedDial",
108 "sambaHomePath", "sambaHomeDrive", "sambaLogonScript",
109 "sambaProfilePath", "sambaPrimaryGroupSID", "sambaDomainName",
110 "sambaUserWorkstations", "sambaPasswordHistory",
111 "sambaLogonHours", "sambaBadPasswordTime",
112 "sambaBadPasswordCount");
113 $this->objectclasses= array ("sambaSamAccount");
114 $this->mungedObject= new sambaMungedDial;
115 $this->ctxattributes= $this->mungedObject->ctxattributes;
116 } else {
117 $this->attributes= array ("pwdLastSet", "logonTime", "logoffTime", "kickoffTime",
118 "pwdCanChange", "pwdMustChange", "acctFlags", "profilePath", "uid",
119 "smbHome", "homeDrive", "scriptPath", "rid", "primaryGroupID");
120 $this->objectclasses= array ("sambaAccount");
121 }
123 plugin::plugin ($config, $dn);
125 /* Setting uid to default */
126 if(isset($this->attrs['uid'][0])){
127 $this->uid = $this->attrs['uid'][0];
128 }
130 /* Get samba Domain in case of samba 3 */
131 if ($this->samba3 && $this->sambaSID != ""){
132 $this->SID= preg_replace ("/-[^-]+$/", "", $this->sambaSID);
133 $ldap= $this->config->get_ldap_link();
134 $ldap->cd($this->config->current['BASE']);
135 $ldap->search ("(&(objectClass=sambaDomain)(sambaSID=$this->SID))",array("sambaAlgorithmicRidBase","sambaDomainName"));
136 if ($ldap->count() != 0){
137 $attrs= $ldap->fetch();
138 if(isset($attrs['sambaAlgorithmicRidBase'])){
139 $this->ridBase= $attrs['sambaAlgorithmicRidBase'][0];
140 } else {
141 $this->ridBase= $this->config->get_cfg_value("sambaRidBase");
142 }
143 if ($this->sambaDomainName == ""){
144 $this->sambaDomainName= $attrs['sambaDomainName'][0];
145 }
146 } else {
147 if ($this->sambaDomainName == ""){
148 $this->sambaDomainName= "DEFAULT";
149 }
150 $this->ridBase= $this->config->get_cfg_value("sambaRidBase");
151 $this->SID= $this->config->get_cfg_value("sambaSid");
152 }
154 /* Save in order to compare later on */
155 $this->orig_sambaDomainName= $this->sambaDomainName;
156 }
158 /* Fill mungedDial field */
159 if ($this->samba3 && isset($this->attrs['sambaMungedDial'])){
160 $this->mungedObject->load($this->sambaMungedDial);
161 }
163 /* Password expiery */
164 if(isset($this->attrs['sambaPwdMustChange']) &&
165 $this->attrs['sambaPwdMustChange'][0] != 0){
166 $this->password_expires= 1;
167 }
169 if(isset($this->attrs['sambaLogonTime']) && ! (
170 $this->attrs['sambaLogonTime'][0] == 0 ||
171 $this->attrs['sambaLogonTime'][0] == 2147483647
172 )){
173 $this->logon_time_set= 1;
174 }
175 if(isset($this->attrs['sambaLogoffTime']) && ! (
176 $this->attrs['sambaLogoffTime'][0] == 0 ||
177 $this->attrs['sambaLogoffTime'][0] == 2147483647
178 )){
179 $this->logoff_time_set= 1;
180 }
182 /* Account expiery */
183 if(isset($this->attrs['sambaKickoffTime']) && ! (
184 $this->attrs['sambaKickoffTime'][0] == 0 ||
185 $this->attrs['sambaKickoffTime'][0] == 2147483647
186 )){
187 $this->kickoff_time_set= 1;
188 }
190 /* Get global filter config */
191 if (!session::is_set("sambafilter")){
192 $ui= get_userinfo();
193 $base= get_base_from_people($ui->dn);
194 $sambafilter= array( "depselect" => $base, "regex" => "*");
195 session::set("sambafilter", $sambafilter);
196 }
198 /* Save initial account state */
199 $this->initially_was_account= $this->is_account;
200 }
202 function execute()
203 {
204 /* Call parent execute */
205 plugin::execute();
207 /* Log view */
208 if($this->is_account && !$this->view_logged){
209 $this->view_logged = TRUE;
210 new log("view","users/".get_class($this),$this->dn);
211 }
213 /* Do we need to flip is_account state? */
214 if (isset($_POST['modify_state'])){
215 $this->is_account= !$this->is_account;
216 }
217 /* Do we represent a valid account? */
218 if (!$this->is_account && $this->parent === NULL){
219 $display= "<img alt=\"\"src=\"images/small-error.png\" align=\"middle\"> <b>".
220 msgPool::noValidExtension(_("Samba"))."</b>";
221 $display.= back_to_main();
222 return ($display);
223 }
225 $display ="";
226 if(!$this->multiple_support_active){
228 /* Show tab dialog headers */
229 $display= "";
230 if ($this->parent !== NULL){
231 if ($this->is_account){
232 $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Samba")),
233 msgPool::featuresEnabled(_("Samba")));
234 } else {
235 $obj= $this->parent->by_object['posixAccount'];
237 /* Samba3 dependency on posix accounts are enabled
238 in the moment, because I need to rely on unique
239 uidNumbers. There'll be a better solution later
240 on. */
241 if ($obj->is_account){
242 $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Samba")),
243 msgPool::featuresDisabled(_("Samba")));
244 } else {
245 $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Samba")),
246 msgPool::featuresDisabled(_("Samba"), _("POSIX")), TRUE);
247 }
248 return ($display);
249 }
250 }
251 }
253 $SkipWrite = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
255 /* Open Samaba Logong hours dialog */
256 if(isset($_POST['SetSambaLogonHours']) && $this->samba3 && $this->acl_is_readable("sambaLogonHours")){
257 $this->dialog = new sambaLogonHours($this->config,$this->dn,$this->sambaLogonHours);
258 }
260 /* Cancel dialog */
261 if(isset($_POST['cancel_logonHours'])){
262 $this->dialog = FALSE;
263 }
265 /* Save selected logon hours */
266 if(isset($_POST['save_logonHours'])){
267 $this->dialog->save_object();
268 if($this->acl_is_writeable("sambaLogonHours")){
269 $this->sambaLogonHours = $this->dialog->save();
270 }
271 $this->dialog = FALSE;
272 }
274 /* Display dialog */
275 if((isset($this->dialog)) && (is_object($this->dialog))){
276 $this->dialog->save_object();
277 return($this->dialog->execute());
278 }
280 /* Prepare templating */
281 $smarty= get_smarty();
283 $tmp = $this->plInfo();
284 foreach($tmp['plProvidedAcls'] as $var => $rest){
285 $smarty->assign($var."ACL",$this->getacl($var,$SkipWrite));
286 }
288 if(!session::is_set('edit') && !isset($this->parent)){
289 $smarty->assign("sambaLogonHoursACL","");
290 }
292 if ($this->sambaPwdMustChange=="0"){
293 $date= getdate();
294 } else {
295 $date= getdate($this->sambaPwdMustChange);
296 }
298 if ($this->sambaLogonTime=="2147483647" || $this->sambaLogonTime=="0"){
299 $sambaLogonTime_date= getdate();
300 } else {
301 $sambaLogonTime_date= getdate($this->sambaLogonTime);
302 }
304 if ($this->sambaLogoffTime=="2147483647" || $this->sambaLogoffTime=="0"){
305 $sambaLogoffTime_date= getdate();
306 } else {
307 $sambaLogoffTime_date= getdate($this->sambaLogoffTime);
308 }
310 if ($this->sambaKickoffTime=="2147483647" || $this->sambaKickoffTime=="0"){
311 $sambaKickoffTime_date= getdate();
312 } else {
313 $sambaKickoffTime_date= getdate($this->sambaKickoffTime);
314 }
316 /* Remove user workstations? */
317 if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){
319 if($this->acl_is_writeable("sambaUserWorkstations",$SkipWrite)){
321 if($this->multiple_support_active){
322 foreach($_POST['workstation_list'] as $name){
323 if(isset($this->multiple_sambaUserWorkstations[trim($name)])){
324 unset($this->multiple_sambaUserWorkstations[trim($name)]);
325 }
326 }
327 }else{
328 $tmp= $this->sambaUserWorkstations;
329 foreach($_POST['workstation_list'] as $name){
330 $tmp= preg_replace("/$name/", '', $tmp);
331 $this->is_modified= TRUE;
332 }
333 $tmp= preg_replace('/,+/', ',', $tmp);
334 $this->sambaUserWorkstations= trim($tmp, ',');
335 }
336 }
337 }
339 /* Add user workstation? */
340 if (isset($_POST["add_ws"])){
341 if($this->acl_is_writeable("sambaUserWorkstations",$SkipWrite)){
342 $this->show_ws_dialog= TRUE;
343 $this->dialog= TRUE;
344 }
345 }
347 /* Add user workstation finished? */
348 if (isset($_POST["add_ws_cancel"])){
349 $this->show_ws_dialog= FALSE;
350 $this->dialog= FALSE;
351 }
353 /* Add user workstation? */
354 if (isset($_POST["add_ws_finish"])){
356 if (isset($_POST['wslist'])){
357 if($this->multiple_support_active){
358 foreach($_POST['wslist'] as $ws){
359 $this->multiple_sambaUserWorkstations[trim($we)] = array("Name" => trim($ws), "UsedByAllUsers" => TRUE);
360 }
361 }else{
362 $tmp= $this->sambaUserWorkstations;
363 foreach($_POST['wslist'] as $ws){
364 $tmp.= ",$ws";
365 }
366 $tmp= preg_replace('/,+/', ',', $tmp);
367 $this->sambaUserWorkstations= trim($tmp, ',');
368 }
369 $this->is_modified= TRUE;
371 $this->show_ws_dialog= FALSE;
372 $this->dialog= FALSE;
373 } else {
374 msg_dialog::display(_("Error"), _("Please select an entry!"), ERROR_DIALOG);
375 }
376 }
378 /* Show ws dialog */
379 if ($this->show_ws_dialog){
381 /* Save data */
382 $sambafilter= session::get("sambafilter");
383 foreach( array("depselect", "regex") as $type){
384 if (isset($_POST[$type])){
385 $sambafilter[$type]= $_POST[$type];
386 }
387 }
388 if (isset($_GET['search'])){
389 $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
390 if ($s == "**"){
391 $s= "*";
392 }
393 $sambafilter['regex']= $s;
394 }
395 session::set("sambafilter", $sambafilter);
397 /* Get workstation list */
398 $exclude= "";
400 if($this->multiple_support_active){
401 foreach($this->multiple_sambaUserWorkstations as $ws){
402 if($ws['UsedByAllUsers']){
403 $exclude.= "(cn=".$ws['Name']."$)";
404 }
405 }
406 }else{
407 foreach(split(',', $this->sambaUserWorkstations) as $ws){
408 $exclude.= "(cn=$ws$)";
409 }
410 }
411 if ($exclude != ""){
412 $exclude= "(!(|$exclude))";
413 }
414 $regex= $sambafilter['regex'];
415 $filter= "(&(objectClass=sambaSAMAccount)$exclude(uid=*$)(|(uid=$regex)(cn=$regex)))";
416 $res= get_list($filter, "winworkstation", $sambafilter['depselect'], array("uid"), GL_SUBSEARCH | GL_SIZELIMIT);
418 $wslist= array();
419 foreach ($res as $attrs){
420 $wslist[]= preg_replace('/\$/', '', $attrs['uid'][0]);
421 }
422 asort($wslist);
424 $smarty->assign("search_image", get_template_path('images/lists/search.png'));
425 $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
426 $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
427 $smarty->assign("deplist", $this->config->idepartments);
428 $smarty->assign("alphabet", generate_alphabet());
429 foreach( array("depselect", "regex") as $type){
430 $smarty->assign("$type", $sambafilter[$type]);
431 }
432 $smarty->assign("hint", print_sizelimit_warning());
433 $smarty->assign("wslist", $wslist);
434 $smarty->assign("apply", apply_filter());
435 $display= $smarty->fetch (get_template_path('samba3_workstations.tpl', TRUE,
436 dirname(__FILE__)));
437 return ($display);
438 }
440 /* Fill calendar */
441 $days= array();
442 for($d= 1; $d<32; $d++){
443 $days[]= $d;
444 }
445 $years= array();
446 for($y= $date['year']-4; $y<$date['year']+4; $y++){
447 $years[]= $y;
448 }
449 $months= msgPool::months();
450 $smarty->assign("day", $date["mday"]);
451 $smarty->assign("days", $days);
452 $smarty->assign("months", $months);
453 $smarty->assign("month", $date["mon"]-1);
454 $smarty->assign("years", $years);
455 $smarty->assign("year", $date["year"]);
457 $sambaLogonTime_days= array();
458 for($d= 1; $d<32; $d++){
459 $sambaLogonTime_days[]= $d;
460 }
461 $sambaLogonTime_years= array();
462 for($y= $date['year']-4; $y<$date['year']+4; $y++){
463 $sambaLogonTime_years[]= $y;
464 }
465 $sambaLogonTime_months= msgPool::months();
466 $smarty->assign("sambaLogonTime_day", $sambaLogonTime_date["mday"]);
467 $smarty->assign("sambaLogonTime_days", $sambaLogonTime_days);
468 $smarty->assign("sambaLogonTime_months", $sambaLogonTime_months);
469 $smarty->assign("sambaLogonTime_month", $sambaLogonTime_date["mon"]-1);
470 $smarty->assign("sambaLogonTime_years", $sambaLogonTime_years);
471 $smarty->assign("sambaLogonTime_year", $sambaLogonTime_date["year"]);
473 $sambaLogoffTime_days= array();
474 for($d= 1; $d<32; $d++){
475 $sambaLogoffTime_days[]= $d;
476 }
477 $sambaLogoffTime_years= array();
478 for($y= $date['year']-4; $y<$date['year']+4; $y++){
479 $sambaLogoffTime_years[]= $y;
480 }
481 $sambaLogoffTime_months= msgPool::months();
482 $smarty->assign("sambaLogoffTime_day", $sambaLogoffTime_date["mday"]);
483 $smarty->assign("sambaLogoffTime_days", $sambaLogoffTime_days);
484 $smarty->assign("sambaLogoffTime_months", $sambaLogoffTime_months);
485 $smarty->assign("sambaLogoffTime_month", $sambaLogoffTime_date["mon"]-1);
486 $smarty->assign("sambaLogoffTime_years", $sambaLogoffTime_years);
487 $smarty->assign("sambaLogoffTime_year", $sambaLogoffTime_date["year"]);
489 $sambaKickoffTime_days= array();
490 for($d= 1; $d<32; $d++){
491 $sambaKickoffTime_days[]= $d;
492 }
493 $sambaKickoffTime_years= array();
494 for($y= $date['year']-4; $y<$date['year']+4; $y++){
495 $sambaKickoffTime_years[]= $y;
496 }
497 $sambaKickoffTime_months= msgPool::months();
498 //$smarty->assign("sambaKickoffTime_day", $sambaKickoffTime_date["mday"]-1);
499 $smarty->assign("sambaKickoffTime_day", $sambaKickoffTime_date["mday"]); // hickert
500 $smarty->assign("sambaKickoffTime_days", $sambaKickoffTime_days);
501 $smarty->assign("sambaKickoffTime_months", $sambaKickoffTime_months);
502 $smarty->assign("sambaKickoffTime_month", $sambaKickoffTime_date["mon"]-1);
503 $smarty->assign("sambaKickoffTime_years", $sambaKickoffTime_years);
504 $smarty->assign("sambaKickoffTime_year", $sambaKickoffTime_date["year"]);
506 /* Fill boxes */
507 if ($this->samba3){
508 $domains= array();
509 foreach($this->config->data['SERVERS']['SAMBA'] as $name => $content){
510 $domains[]= $name;
511 }
512 $smarty->assign("domains", $domains);
513 }
514 $letters= array("");
515 for ($i= 68; $i<91; $i++){
516 $letters[]= chr($i).":";
517 }
518 $smarty->assign("drives", $letters);
520 /* Fill terminal server settings */
521 if ($this->samba3){
522 foreach ($this->ctxattributes as $attr){
523 /* Fill common attributes */
524 if (isset($this->mungedObject->ctx[$attr])){
525 $smarty->assign("$attr", $this->mungedObject->ctx[$attr]);
526 // Set field to blank if value is 0
527 if(in_array($attr, array("CtxMaxConnectionTime", "CtxMaxDisconnectionTime", "CtxMaxIdleTime"))) {
528 if($this->mungedObject->ctx[$attr] == 0) {
529 $smarty->assign("$attr", "");
530 }
531 }
532 } else {
533 $smarty->assign("$attr", "");
534 }
535 }
537 /* Assign enum values for preset items */
538 $shadowModeVals= array( "0" => _("disabled"),
539 "1" => _("input on, notify on"),
540 "2" => _("input on, notify off"),
541 "3" => _("input off, notify on"),
542 "4" => _("input off, nofify off"));
544 $brokenConnModeVals= array( "0" => _("disconnect"),
545 "1" => _("reset"));
547 $reConnModeVals= array( "0" => _("from any client"),
548 "1" => _("from previous client only"));
550 /* Fill preset items */
551 $smarty->assign("shadow", $shadowModeVals);
552 $smarty->assign("brokenconn", $brokenConnModeVals);
553 $smarty->assign("reconn", $reConnModeVals);
555 /* Fill preset items with values */
556 $smarty->assign("shadowmode", $this->mungedObject->getShadow());
557 $smarty->assign("brokenconnmode", $this->mungedObject->getBrokenConn());
558 $smarty->assign("reconnmode", $this->mungedObject->getReConn());
560 if(session::get('js')){
561 /* Set form elements to disabled/enable state */
562 $smarty->assign("tsloginstate", $this->mungedObject->getTsLogin()?"":"disabled");
564 $smarty->assign("inheritstate", "");
565 if($this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){
566 $smarty->assign("inheritstate", $this->mungedObject->getInheritMode()?"disabled":"");
567 }
568 }else{
569 $smarty->assign("tsloginstate", "");
570 $smarty->assign("inheritstate", "");
571 }
573 /* Set checkboxes to checked or unchecked state */
574 $smarty->assign("tslogin", $this->mungedObject->getTsLogin()?"checked":"");
575 $smarty->assign("inherit", $this->mungedObject->getInheritMode()?"checked":"");
576 $smarty->assign("connectclientdrives",
577 $this->mungedObject->getConnectClientDrives()?"checked":"");
578 $smarty->assign("connectclientprinters",
579 $this->mungedObject->getConnectClientPrinters()?"checked":"");
580 $smarty->assign("defaultprinter",
581 $this->mungedObject->getDefaultPrinter()?"checked":"");
582 $smarty->assign("CtxMaxConnectionTimeF",
583 $this->mungedObject->getCtxMaxConnectionTimeF()?"checked":"");
584 $smarty->assign("CtxMaxDisconnectionTimeF",
585 $this->mungedObject->getCtxMaxDisconnectionTimeF()?"checked":"");
586 $smarty->assign("CtxMaxIdleTimeF",
587 $this->mungedObject->getCtxMaxIdleTimeF()?"checked":"");
590 /* Fill sambaUserWorkstations */
591 $ws= split(",", $this->sambaUserWorkstations);
592 sort($ws);
594 /* Tidy checks for empty option, and smarty will produce one if array[0]="" */
595 if(($ws[0]=="")&&(count($ws)==1)) $ws=array();
597 if($this->multiple_support_active){
598 $smarty->assign("multiple_workstations",$this->multiple_sambaUserWorkstations);
599 }
601 $smarty->assign("workstations", $ws);
602 }
604 /* Variables */
605 foreach($this->attributes as $val){
606 $smarty->assign("$val", $this->$val);
607 }
609 /* 'sambaAcctFlags' checkboxes */
610 /* Check for 'lock-account'-flag: 'D' or 'L' */
611 if (is_integer(strpos($this->sambaAcctFlags, "D")) ||
612 is_integer(strpos($this->sambaAcctFlags, "L"))) {
613 $smarty->assign("flagsD", "checked");
614 } else {
615 $smarty->assign("flagsD", "");
616 }
618 /* Check for no_password_required flag 'N' */
619 if (is_integer(strpos($this->sambaAcctFlags, "N"))) {
620 $smarty->assign("flagsN", "checked");
621 } else {
622 $smarty->assign("flagsN", "");
623 }
625 if($this->samba3){
626 if ($this->sambaPwdCanChange=="1"){
627 $smarty->assign("flagsP", "checked");
628 } else {
629 $smarty->assign("flagsP", "");
630 }
631 }else{
632 if ($this->pwdCanChange=="1"){
633 $smarty->assign("flagsP", "checked");
634 } else {
635 $smarty->assign("flagsP", "");
636 }
637 }
639 if ($this->password_expires=="1"){
640 $smarty->assign("flagsC", "checked");
641 } else {
642 $smarty->assign("flagsC", "");
643 }
644 if ($this->logon_time_set=="1"){
645 $smarty->assign("flagsT", "checked");
646 } else {
647 $smarty->assign("flagsT", "");
648 }
649 if ($this->logoff_time_set=="1"){
650 $smarty->assign("flagsO", "checked");
651 } else {
652 $smarty->assign("flagsO", "");
653 }
654 if ($this->kickoff_time_set=="1"){
655 $smarty->assign("flagsK", "checked");
656 } else {
657 $smarty->assign("flagsK", "");
658 }
661 /* In case of javascript, disable some fields on demand */
662 if ($this->samba3){
663 foreach($this->mungedObject->getOnDemandFlags() as $key => $value) {
664 $smarty->assign("$key", "$value");
665 }
666 }
669 foreach($this->attributes as $attr){
670 if(in_array($attr,$this->multi_boxes)){
671 $smarty->assign("use_".$attr,TRUE);
672 }else{
673 $smarty->assign("use_".$attr,FALSE);
674 }
675 }
676 foreach(array("allow_pwchange","tslogin","CtxWFHomeDir","CtxWFHomeDirDrive","CtxWFProfilePath",
677 "inherit","CtxWorkDirectory","CtxInitialProgram","CtxMaxConnectionTimeF","CtxMaxConnectionTime","CtxMaxDisconnectionTimeF",
678 "CtxMaxDisconnectionTime","CtxMaxIdleTimeF","CtxMaxIdleTime","connectclientdrives",
679 "onnectclientprinters","defaultprinter","shadow","brokenconn",
680 "reconn","allow_pwchange","connectclientprinters","no_password_required","temporary_disable",
681 "password_expires","logon_time_set","logoff_time_set","kickoff_time_set","SetSambaLogonHours",
682 "workstation_list") as $attr){
683 if(in_array($attr,$this->multi_boxes)){
684 $smarty->assign("use_".$attr,TRUE);
685 }else{
686 $smarty->assign("use_".$attr,FALSE);
687 }
688 }
690 if($this->multiple_support_active){
691 $smarty->assign("tsloginstate","");
692 }
694 /* Create additional info for sambaKickOffTime and sambaPwdMustChange.
695 e.g. Display effective kickoff time. Domain policy + user settings.
696 */
697 $additional_info_KickoffTime = "";
698 $additional_info_PwdMustChange = "";
700 /* Calculate effective max Password Age
701 This can only be calculated if sambaPwdLastSet ist set.
702 */
703 $this->attrs['sambaPwdLastSet'][0] = time() - (60 *60);
704 if(isset($this->attrs['sambaPwdLastSet'][0])){
705 $last = $this->attrs['sambaPwdLastSet'][0];
707 $sid = $this->get_domain_info();
708 if(isset($sid['sambaMaxPwdAge'][0])){
709 $d = ($last + $sid['sambaMaxPwdAge'][0]) - time();
711 /* A negative value means the password is outdated
712 */
713 if($d < 0){
714 $additional_info_PwdMustChange = sprintf(_("Invalid by domain policiy, since %s."),
715 date("d.m.Y H:i:s",$last + $sid['sambaMaxPwdAge'][0]));
716 }else{
717 if($this->password_expires && ($last + $sid['sambaMaxPwdAge'][0]) > $this->sambaPwdMustChange){
718 $additional_info_PwdMustChange = sprintf(_("Invalid by user policiy, on %s."),
719 date("d.m.Y H:i:s", $this->sambaPwdMustChange));
720 }else{
721 $additional_info_PwdMustChange = sprintf(_("Invalid by domain policiy, on %s."),
722 date("d.m.Y H:i:s", ($last + $sid['sambaMaxPwdAge'][0])));
723 }
724 }
725 }
726 }
728 $additional_info_KickoffTime = "asdf";
730 $smarty->assign("additional_info_KickoffTime",$additional_info_KickoffTime);
731 $smarty->assign("additional_info_PwdMustChange",$additional_info_PwdMustChange);
733 /* Show main page */
734 $smarty->assign("multiple_support",$this->multiple_support_active);
735 if ($this->samba3){
737 $smarty->assign("samba_information","");
738 $smarty->assign("display_information",$this->display_information);
739 if($this->display_information){
740 $smarty->assign("samba_information",$this->get_samba_information());
741 }
743 $display.= $smarty->fetch (get_template_path('samba3.tpl', TRUE, dirname(__FILE__)));
744 } else {
745 $display.= $smarty->fetch (get_template_path('samba2.tpl', TRUE, dirname(__FILE__)));
746 }
748 return ($display);
749 }
752 /*! \brief Returns the samba Domain object, selected in the samba tab.
753 */
754 function get_domain_info()
755 {
756 /* Only search once, return last result if available
757 */
758 if(!isset($this->cache['DOMAIN'][$this->sambaDomainName])){
759 $this->cache['DOMAIN'][$this->sambaDomainName] = array();
760 if(!empty($this->sambaDomainName) && isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName])){
761 $cfg = $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName];
762 $ldap = $this->config->get_ldap_link();
763 $ldap->cd($this->config->current['BASE']);
764 $ldap->search("(&(objectClass=sambaDomain)(sambaSID=".$cfg['SID']."))",array("*"));
765 if($ldap->count()){
766 $this->cache['DOMAIN'][$this->sambaDomainName] = $ldap->fetch();
767 }
768 }
769 }
770 return($this->cache['DOMAIN'][$this->sambaDomainName]);
771 }
775 function get_samba_information()
776 {
778 /* Defaults
779 */
780 $sambaMinPwdLength = "unset";
781 $sambaPwdHistoryLength = "unset";
782 $sambaLogonToChgPwd = "unset";
783 $sambaMaxPwdAge = "unset";
784 $sambaMinPwdAge = "unset";
785 $sambaLockoutDuration = "unset";
786 $sambaLockoutThreshold = "unset";
787 $sambaForceLogoff = "unset";
788 $sambaRefuseMachinePwdChange = "unset";
789 $sambaPwdLastSet = "unset";
790 $sambaLogonTime = "unset";
791 $sambaLogoffTime = "unset";
793 $sambaKickoffTime = "unset";
794 $sambaPwdCanChange = "unset";
795 $sambaPwdMustChange = "unset";
796 $sambaBadPasswordCount = "unset";
797 $sambaBadPasswordTime = "unset";
799 /* Domain attributes
800 */
801 $domain_attributes = array("sambaMinPwdLength","sambaPwdHistoryLength","sambaMaxPwdAge",
802 "sambaMinPwdAge","sambaLockoutDuration","sambaRefuseMachinePwdChange",
803 "sambaLogonToChgPwd","sambaLockoutThreshold","sambaForceLogoff");
805 /* User attributes
806 */
807 $user_attributes = array("sambaBadPasswordTime","sambaPwdLastSet","sambaLogonTime","sambaLogoffTime",
808 "sambaKickoffTime","sambaPwdCanChange","sambaPwdMustChange","sambaBadPasswordCount");
810 /* Get samba SID object and parse settings.
811 */
812 $ldap = $this->config->get_ldap_link();
813 $ldap->cd($this->config->current['BASE']);
814 if(!empty($this->sambaDomainName) && isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName])){
815 $cfg = $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName];
816 $ldap->search("(&(objectClass=sambaDomain)(sambaSID=".$cfg['SID']."))",array("*"));
817 if($ldap->count() >= 1){
818 $attrs = $ldap->fetch();
819 foreach($domain_attributes as $attr){
820 if(isset($attrs[$attr])){
821 $$attr = $attrs[$attr][0];
822 }
823 }
824 }
825 }
827 /* Get user infos
828 */
829 foreach($user_attributes as $attr){
830 if(isset($this->attrs[$attr])){
831 $$attr = $this->attrs[$attr][0];
832 }
833 }
834 if($this->password_expires){
835 $sambaPwdMustChange = $this->sambaPwdMustChange;
836 }
837 if($this->kickoff_time_set){
838 $sambaKickoffTime = $this->sambaKickoffTime;
839 }
840 $sambaPwdCanChange = $this->sambaPwdCanChange;
843 /* DOMAIN Attributes
844 */
846 /* sambaMinPwdLength: Password length has a default of 5
847 */
848 if($sambaMinPwdLength == "unset" || $sambaMinPwdLength == 5){
849 $sambaMinPwdLength = "5 <i>("._("default").")</i>";
850 }
852 /* sambaPwdHistoryLength: Length of Password History Entries (default: 0 => off)
853 */
854 if($sambaPwdHistoryLength == "unset" || $sambaPwdHistoryLength == 0){
855 $sambaPwdHistoryLength = _("Off")." <i>("._("default").")</i>";
856 }
858 /* sambaLogonToChgPwd: Force Users to logon for password change (default: 0 => off, 2 => on)
859 */
860 if($sambaLogonToChgPwd == "unset" || $sambaLogonToChgPwd == 0){
861 $sambaLogonToChgPwd = _("Off")." <i>("._("default").")</i>";
862 }else{
863 $sambaLogonToChgPwd = _("On");
864 }
866 /* sambaMaxPwdAge: Maximum password age, in seconds (default: -1 => never expire passwords)'
867 */
868 if($sambaMaxPwdAge == "unset" || $sambaMaxPwdAge == "-1"){
869 $sambaMaxPwdAge = _("disabled")." <i>("._("default").")</i>";
870 }else{
871 $sambaMaxPwdAge .= " "._("seconds");
872 }
874 /* sambaMinPwdAge: Minimum password age, in seconds (default: 0 => allow immediate password change
875 */
876 if($sambaMinPwdAge == "unset" || $sambaMinPwdAge == 0){
877 $sambaMinPwdAge = _("disabled")." <i>("._("default").")</i>";
878 }else{
879 $sambaMinPwdAge .= " "._("seconds");
880 }
882 /* sambaLockoutDuration: Lockout duration in minutes (default: 30, -1 => forever)
883 */
884 if($sambaLockoutDuration == "unset" || $sambaLockoutDuration == 30){
885 $sambaLockoutDuration = "30 "._("minutes")." <i>("._("default").")</i>";
886 }elseif($sambaLockoutDuration == -1){
887 $sambaLockoutDuration = _("forever");
888 }else{
889 $sambaLockoutDuration .= " "._("minutes");
890 }
892 /* sambaLockoutThreshold: Lockout users after bad logon attempts (default: 0 => off
893 */
894 if($sambaLockoutThreshold == "unset" || $sambaLockoutThreshold == 0){
895 $sambaLockoutThreshold = _("disabled")." <i>("._("default").")</i>";
896 }
898 /* sambaForceLogoff: Disconnect Users outside logon hours (default: -1 => off, 0 => on
899 */
900 if($sambaForceLogoff == "unset" || $sambaForceLogoff == -1){
901 $sambaForceLogoff = _("off")." <i>("._("default").")</i>";
902 }else{
903 $sambaForceLogoff = _("on");
904 }
906 /* sambaRefuseMachinePwdChange: Allow Machine Password changes (default: 0 => off
907 */
908 if($sambaRefuseMachinePwdChange == "none" || $sambaRefuseMachinePwdChange == 0){
909 $sambaRefuseMachinePwdChange = _("off")." <i>("._("default").")</i>";
910 }else{
911 $sambaRefuseMachinePwdChange = _("on");
912 }
914 /* USER Attributes
915 */
916 /* sambaBadPasswordTime: Time of the last bad password attempt
917 */
918 if($sambaBadPasswordTime == "unset" || empty($sambaBadPasswordTime)){
919 $sambaBadPasswordTime = "<i>("._("unset").")</i>";
920 }else{
921 $sambaBadPasswordTime = date("d.m.Y H:i:s",$sambaBadPasswordTime);
922 }
924 /* sambaBadPasswordCount: Bad password attempt count
925 */
926 if($sambaBadPasswordCount == "unset" || empty($sambaBadPasswordCount)){
927 $sambaBadPasswordCount = "<i>("._("unset").")</i>";
928 }else{
929 $sambaBadPasswordCount = date("d.m.Y H:i:s",$sambaBadPasswordCount);
930 }
932 /* sambaPwdLastSet: Timestamp of the last password update
933 */
934 if($sambaPwdLastSet == "unset" || empty($sambaPwdLastSet)){
935 $sambaPwdLastSet = "<i>("._("unset").")</i>";
936 }else{
937 $sambaPwdLastSet = date("d.m.Y H:i:s",$sambaPwdLastSet);
938 }
940 /* sambaLogonTime: Timestamp of last logon
941 */
942 if($sambaLogonTime == "unset" || empty($sambaLogonTime)){
943 $sambaLogonTime = "<i>("._("unset").")</i>";
944 }else{
945 $sambaLogonTime = date("d.m.Y H:i:s",$sambaLogonTime);
946 }
948 /* sambaLogoffTime: Timestamp of last logoff
949 */
950 if($sambaLogoffTime == "unset" || empty($sambaLogoffTime)){
951 $sambaLogoffTime = "<i>("._("unset").")</i>";
952 }else{
953 $sambaLogoffTime = date("d.m.Y H:i:s",$sambaLogoffTime);
954 }
956 /* sambaKickoffTime: Timestamp of when the user will be logged off automatically
957 */
958 if($sambaKickoffTime == "unset" || empty($sambaKickoffTime)){
959 $sambaKickoffTime = "<i>("._("unset").")</i>";
960 }else{
961 $sambaKickoffTime = date("d.m.Y H:i:s",$sambaKickoffTime);
962 }
964 /* sambaPwdMustChange: Timestamp of when the password will expire
965 */
966 if($sambaPwdMustChange == "unset" || empty($sambaPwdMustChange)){
967 $sambaPwdMustChange = "<i>("._("unset").")</i>";
968 }else{
969 $sambaPwdMustChange = date("d.m.Y H:i:s",$sambaPwdMustChange);
970 }
972 /* sambaPwdCanChange: Timestamp of when the user is allowed to update the password
973 */
974 if($sambaPwdCanChange == "unset" || empty($sambaPwdCanChange)){
975 $sambaPwdCanChange = "<i>("._("unset").")</i>";
976 }elseif($sambaPwdCanChange != "unset" && time() > $sambaPwdCanChange){
977 $sambaPwdCanChange = _("immediately") ;
978 }else{
979 $days = floor((($sambaPwdCanChange - time()) / 60 / 60 / 24)) ;
980 $hours = floor((($sambaPwdCanChange - time()) / 60 / 60) % 24) ;
981 $minutes = floor((($sambaPwdCanChange - time()) / 60 ) % 60) ;
983 $sambaPwdCanChange = " ".$days." "._("days");
984 $sambaPwdCanChange.= " ".$hours." "._("hours");
985 $sambaPwdCanChange.= " ".$minutes." "._("minutes");
986 }
988 $str =
989 "\n<table style='width:100%;'><tr><td style='width:50%; border-right: solid 1px #B0B0B0;'>".
990 "\n<table>".
991 "\n<tr><td><b>"._("Domain attributes")."</b></td></tr>".
992 "\n<tr><td>"._("Min password length").": </td><td>".$sambaMinPwdLength."</td></tr>".
993 "\n<tr><td>"._("Min password length").": </td><td>".$sambaMinPwdLength."</td></tr>".
994 "\n<tr><td>"._("Password history").": </td><td>".$sambaPwdHistoryLength."</td></tr>".
995 "\n<tr><td>"._("Force password change").": </td><td>".$sambaLogonToChgPwd."</td></tr>".
996 "\n<tr><td>"._("Maximum password age").": </td><td>".$sambaMaxPwdAge."</td></tr>".
997 "\n<tr><td>"._("Minimum password age").": </td><td>".$sambaMinPwdAge."</td></tr>".
998 "\n<tr><td>"._("Lockout duration").": </td><td>".$sambaLockoutDuration."</td></tr>".
999 "\n<tr><td>"._("Bad lockout attempt").": </td><td>".$sambaLockoutThreshold."</td></tr>".
1000 "\n<tr><td>"._("Disconnect time").": </td><td>".$sambaForceLogoff."</td></tr>".
1001 "\n<tr><td>"._("Refuse machine password change").":</td><td>".$sambaRefuseMachinePwdChange."</td></tr>".
1002 "\n</table></td><td style='vertical-align: top;'><table>".
1003 "\n<tr><td><b>"._("User attributes")."</b></td></tr>".
1004 "\n<tr><td>"._("Last failed login").": </td><td>".$sambaBadPasswordTime."</td></tr>".
1005 "\n<tr><td>"._("Logon attempts").": </td><td>".$sambaBadPasswordCount."</td></tr>".
1006 "\n<tr><td>"._("Last password update").": </td><td>".$sambaPwdLastSet."</td></tr>".
1007 "\n<tr><td>"._("Last logon").": </td><td>".$sambaLogonTime."</td></tr>".
1008 "\n<tr><td>"._("Last logoff").": </td><td>".$sambaLogoffTime."</td></tr>".
1009 "\n<tr><td>"._("Automatic logoff").": </td><td>".$sambaKickoffTime."</td></tr>".
1010 "\n<tr><td>"._("Password expires").": </td><td>".$sambaPwdMustChange."</td></tr>".
1011 "\n<tr><td>"._("Password change available").": </td><td>".$sambaPwdCanChange."</td></tr>".
1012 "\n</table></td></tr></table>";
1013 return($str);
1014 }
1017 function remove_from_parent()
1018 {
1019 /* Cancel if there's nothing to do here */
1020 if (!$this->initially_was_account){
1021 return;
1022 }
1024 /* include global link_info */
1025 $ldap= $this->config->get_ldap_link();
1027 plugin::remove_from_parent();
1029 /* Keep uid attribute for gosaAccount */
1030 unset($this->attrs['uid']);
1031 unset($this->attrs['uidNumber']);
1032 unset($this->attrs['gidNumber']);
1034 /* Remove objectClass for sambaIdmapEntry */
1035 $tmp= array();
1036 for ($i= 0; $i<count($this->attrs["objectClass"]); $i++){
1037 if ($this->attrs['objectClass'][$i] != 'sambaIdmapEntry'){
1038 $tmp[]= $this->attrs['objectClass'][$i];
1039 }
1040 }
1041 $this->attrs['objectClass']= $tmp;
1043 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
1044 $this->attributes, "Save");
1045 $ldap->cd($this->dn);
1046 $this->cleanup();
1047 $ldap->modify ($this->attrs);
1049 new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1051 if (!$ldap->success()){
1052 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
1053 }
1055 /* Optionally execute a command after we're done */
1056 $this->handle_post_events("remove", array("uid" => $this->uid));
1057 }
1060 /* Check for input problems */
1061 function check()
1062 {
1063 /* Call common method to give check the hook */
1064 $message= plugin::check();
1066 if ($this->samba3){
1068 /* sambaHomePath requires sambaHomeDrive and vice versa */
1069 if(!empty($this->sambaHomePath) && empty($this->sambaHomeDrive)){
1070 $message[]= msgPool::required(_("Home drive"));
1071 }
1072 if(!empty($this->sambaHomeDrive) && empty($this->sambaHomePath)){
1073 $message[]= msgPool::required(_("Home path"));
1074 }
1076 /* Strings */
1077 foreach (array( "sambaHomePath" => _("Home directory"),
1078 "sambaProfilePath" => _("Profile path")) as $key => $val){
1079 if (!$this->mungedObject->is_samba_path($this->$key)){
1080 $message[]= msgPool::invalid($val);
1081 }
1082 }
1084 /* Numeric values */
1085 foreach (array( "CtxMaxConnectionTime" => _("Connection"),
1086 "CtxMaxDisconnectionTime" => _("Disconnection"),
1087 "CtxMaxIdleTime" => _("IDLE")) as $key => $val){
1089 if (isset($this->mungedObject->ctx[$key]) && !tests::is_id($this->mungedObject->ctx[$key]) && $val != 0){
1090 $message[]= msgPool::invalid($val);
1091 }
1092 }
1094 /* Too many workstations? Windows usrmgr only supports eight */
1095 if (substr_count($this->sambaUserWorkstations, ",") >= 8){
1096 $message[]= _("The windows usermanager allows eight clients at maximum!");
1097 }
1098 }
1100 return ($message);
1101 }
1104 /* Save data to object */
1105 function save_object()
1106 {
1108 $SkipWrite = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
1110 /* We only care if we are on the sambaTab... */
1111 if (isset($_POST['sambaTab'])){
1112 plugin::save_object();
1114 if(isset($_POST['display_information'])){
1115 $this->display_information = !$this->display_information;
1116 }
1118 /* Take care about access options */
1119 if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){
1120 if ($this->samba3){
1121 $attrname= "sambaPwdCanChange";
1122 } else {
1123 $attrname= "pwdCanChange";
1124 }
1125 if (isset($_POST["allow_pwchange"]) && $_POST["allow_pwchange"] == 1){
1126 $tmp= 1;
1127 } else {
1128 $tmp= 0;
1129 }
1130 if ($this->$attrname != $tmp){
1131 $this->is_modified= TRUE;
1132 }
1133 $this->pwdCanChange= $tmp;
1134 $this->sambaPwdCanChange= $tmp;
1135 }
1136 $tmp= "UX";
1137 $this->no_password_required = FALSE;
1138 if (isset($_POST["no_password_required"])){
1139 if ($_POST["no_password_required"] == 1){
1140 $tmp.= "N";
1141 $this->no_password_required = TRUE;
1142 }
1143 }
1144 if (isset($_POST["password_expires"])){
1145 if ($_POST["password_expires"] == 1){
1146 $this->password_expires= 1;
1147 }
1148 } else {
1149 $this->password_expires= 0;
1150 }
1151 $this->temporary_disable = FALSE;
1152 if (isset($_POST["temporary_disable"])){
1153 if ($_POST["temporary_disable"] == 1){
1154 $this->temporary_disable = TRUE;
1155 if (is_integer(strpos($this->sambaAcctFlags, "L"))) {
1156 $tmp.= "L";
1157 } else {
1158 $tmp.= "D";
1159 }
1160 }
1161 }
1162 if (isset($_POST["logon_time_set"])){
1163 if ($_POST["logon_time_set"] == 1){
1164 $this->logon_time_set= 1;
1165 }
1166 } else {
1167 $this->logon_time_set= 0;
1168 }
1169 if (isset($_POST["logoff_time_set"])){
1170 if ($_POST["logoff_time_set"] == 1){
1171 $this->logoff_time_set= 1;
1172 }
1173 } else {
1174 $this->logoff_time_set= 0;
1175 }
1176 if (isset($_POST["kickoff_time_set"])){
1177 if ($_POST["kickoff_time_set"] == 1){
1178 $this->kickoff_time_set= 1;
1179 }
1180 } else {
1181 $this->kickoff_time_set= 0;
1182 }
1184 $fill= "";
1185 for ($i= strlen($tmp); $i<12; $i++){
1186 $fill.= " ";
1187 }
1189 $tmp= "[$tmp$fill]";
1191 /* Only save if acl's are set */
1192 if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){
1193 if ($this->samba3){
1194 $attrname= "sambaAcctFlags";
1195 } else {
1196 $attrname= "acctFlags";
1197 }
1198 if ($this->$attrname != $tmp){
1199 $this->is_modified= TRUE;
1200 }
1201 $this->$attrname= $tmp;
1202 }
1204 /* Save sambaDomain attribute */
1205 if ($this->acl_is_writeable("sambaDomainName",$SkipWrite) && $this->samba3 && isset ($_POST['sambaDomainName'],$SkipWrite)){
1206 $this->sambaDomainName= validate($_POST['sambaDomainName']);
1207 }
1209 /* Save CTX values */
1210 if ($this->samba3){
1212 /* Save obvious values */
1213 foreach($this->ctxattributes as $val){
1214 if (isset($_POST[$val]) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){
1215 if (get_magic_quotes_gpc()) {
1216 $this->mungedObject->ctx[$val]= stripcslashes(validate($_POST[$val]));
1217 } else {
1218 $this->mungedObject->ctx[$val]= validate($_POST[$val]);
1219 }
1220 }
1221 }
1223 /* Save checkbox states. */
1224 $this->mungedObject->setTsLogin(!isset($_POST['tslogin'])
1225 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1226 // Need to do some index checking to avoid messages like "index ... not found"
1227 if(isset($_POST['brokenconn'])) {
1228 $this->mungedObject->setBrokenConn($_POST['brokenconn'] == '1'
1229 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1230 }
1231 if(isset($_POST['reconn'])) {
1232 $this->mungedObject->setReConn($_POST['reconn'] == '1'
1233 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1234 }
1235 $this->mungedObject->setInheritMode(isset($_POST['inherit'])
1236 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1237 $this->mungedObject->setCtxMaxConnectionTimeF(!isset($_POST['CtxMaxConnectionTimeF'])
1238 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1239 $this->mungedObject->setCtxMaxDisconnectionTimeF(
1240 !isset($_POST['CtxMaxDisconnectionTimeF'])
1241 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1242 $this->mungedObject->setCtxMaxIdleTimeF(!isset($_POST['CtxMaxIdleTimeF'])
1243 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1244 $this->mungedObject->setConnectClientDrives(isset($_POST['connectclientdrives'])
1245 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1246 $this->mungedObject->setConnectClientPrinters(isset($_POST['connectclientprinters'])
1247 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1248 $this->mungedObject->setDefaultPrinter(isset($_POST['defaultprinter'])
1249 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1251 /* Save combo boxes. Takes two values */
1252 if(isset($_POST['reconn'])) {
1253 $this->mungedObject->setShadow(isset($_POST['shadow']) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite),$_POST['shadow']);
1254 }
1256 /* Check for changes */
1257 if ($this->sambaMungedDial != $this->mungedObject->getMunged()){
1258 $this->is_modified= TRUE;
1259 }
1260 }
1261 }
1262 }
1265 /* Save to LDAP */
1266 function save()
1267 {
1268 /* Load uid and gid of this 'dn' */
1269 $ldap= $this->config->get_ldap_link();
1270 $ldap->cat($this->dn, array('uidNumber', 'gidNumber'));
1271 $tmp= $ldap->fetch();
1272 $this->uidNumber= $tmp['uidNumber'][0];
1273 $this->gidNumber= $tmp['gidNumber'][0];
1275 plugin::save();
1277 /* Remove objectClass for sambaIdmapEntry */
1278 $tmp= array();
1279 for ($i= 0; $i<count($this->attrs["objectClass"]); $i++){
1280 if ($this->attrs['objectClass'][$i] != 'sambaIdmapEntry'){
1281 $tmp[]= $this->attrs['objectClass'][$i];
1282 }
1283 }
1284 $this->attrs['objectClass']= $tmp;
1286 /* Generate rid / primaryGroupId */
1287 if ($this->samba3){
1288 if (!isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'])){
1289 msg_dialog::display(_("Warning"), _("Undefined Samba SID detected. Please fix this problem manually!"), WARNING_DIALOG);
1290 } else {
1291 $this->SID= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'];
1292 $this->ridBase= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE'];
1293 }
1295 /* Need to generate a new uniqe uid/gid combination? */
1296 if ($this->sambaSID == "" || $this->orig_sambaDomainName != $this->sambaDomainName){
1297 $uidNumber= $this->uidNumber;
1298 while(TRUE){
1299 $sid= $this->SID."-".($uidNumber*2 + $this->ridBase);
1300 $ldap->cd($this->config->current['BASE']);
1301 $ldap->search("(sambaSID=$sid)", array("sambaSID"));
1302 if ($ldap->count() == 0){
1303 break;
1304 }
1305 $uidNumber++;
1306 }
1307 $this->attrs['sambaSID']= $sid;
1309 /* Check for users primary group */
1310 $ldap->cd($this->config->current['BASE']);
1311 $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn"));
1312 if ($ldap->count() != 1){
1313 msg_dialog::display(_("Warning"), _("Cannot convert primary group to samba group: group cannot be identified!"), WARNING_DIALOG);
1314 } else {
1315 $attrs= $ldap->fetch();
1316 $g= new group($this->config, $ldap->getDN());
1317 if ($g->sambaSID == ""){
1318 $g->sambaDomainName= $this->sambaDomainName;
1319 $g->smbgroup= TRUE;
1320 $g->save ();
1321 }
1322 $this->attrs['sambaPrimaryGroupSID']= $g->sambaSID;
1323 }
1324 }
1326 if ($this->sambaHomeDrive == ""){
1327 $this->attrs["sambaHomeDrive"]= array();
1328 }
1330 /* Generate munged dial value */
1331 $this->attrs["sambaMungedDial"]= $this->mungedObject->getMunged();
1333 /* User wants me to fake the idMappings? This is useful for
1334 making winbind resolve the user names in a reasonable amount
1335 of time in combination with larger databases. */
1336 if ($this->config->get_cfg_value("sambaidmapping") == "true"){
1337 $this->attrs['objectClass'][]= "sambaIdmapEntry";
1338 }
1341 /* Password expiery */
1342 if ($this->password_expires == "1"){
1343 $this->attrs['sambaPwdMustChange']= $this->sambaPwdMustChange;
1344 } else {
1345 $this->attrs['sambaPwdMustChange']= array();
1346 }
1347 /* Make sure not to save zero in sambaPwdLastset */
1348 if ($this->sambaPwdLastSet != "0"){
1349 $this->attrs['sambaPwdLastSet']= $this->sambaPwdLastSet;
1350 } else {
1351 $this->attrs['sambaPwdLastSet']= array();
1352 }
1353 /* Account expiery */
1354 if ($this->logon_time_set == "1"){
1355 $this->attrs['sambaLogonTime']= $this->sambaLogonTime;
1356 } else {
1357 $this->attrs['sambaLogonTime']= array();
1358 }
1359 if ($this->logoff_time_set == "1"){
1360 $this->attrs['sambaLogoffTime']= $this->sambaLogoffTime;
1361 } else {
1362 $this->attrs['sambaLogoffTime']= array();
1363 }
1364 if ($this->kickoff_time_set == "1"){
1365 # Add one day in unixtime format to be compatible with usrmgr
1366 //$this->attrs['sambaKickoffTime']= $this->sambaKickoffTime + 86400;
1367 $this->attrs['sambaKickoffTime']= $this->sambaKickoffTime; //hickert
1368 } else {
1369 $this->attrs['sambaKickoffTime']= array();
1370 }
1371 } else {
1372 /* Not samba3 */
1373 $this->attrs['rid']= $this->uidNumber*2 + 1000;
1374 $this->attrs['primaryGroupID']= $this->gidNumber*2 +1001;
1376 if ($this->homeDrive == ""){
1377 $this->attrs["homeDrive"]= array();
1378 }
1380 /* Password expiery */
1381 if ($this->password_expires == "1"){
1382 $this->attrs['pwdMustChange']= $this->pwdMustChange;
1383 } else {
1384 $this->attrs['pwdMustChange']= 2147483647;
1385 }
1386 /* Make sure not to save zero in pwdLastset */
1387 if ($this->pwdLastSet != "0"){
1388 $this->attrs['pwdLastSet']= $this->pwdLastSet;
1389 } else {
1390 $this->attrs['pwdLastSet']= array();
1391 }
1392 /* Account expiery */
1393 if ($this->logon_time_set == "1"){
1394 $this->attrs['logonTime']= $this->logonTime;
1395 } else {
1396 $this->attrs['logonTime']= array();
1397 }
1398 if ($this->logoff_time_set == "1"){
1399 $this->attrs['logoffTime']= $this->logoffTime;
1400 } else {
1401 $this->attrs['logoffTime']= array();
1402 }
1403 if ($this->kickoff_time_set == "1"){
1404 # Add one day in unixtime format to be compatible with usrmgr
1405 $this->attrs['kickoffTime']= $this->kickoffTime + 86400;
1406 } else {
1407 $this->attrs['kickoffTime']= array();
1408 }
1409 }
1411 /* Write back to ldap */
1412 $ldap->cd($this->dn);
1413 $this->cleanup();
1414 $ldap->modify ($this->attrs);
1416 if($this->initially_was_account){
1417 new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1418 }else{
1419 new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1420 }
1422 if (!$ldap->success()){
1423 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
1424 }
1426 /* Optionally execute a command after we're done */
1427 if ($this->initially_was_account == $this->is_account){
1428 if ($this->is_modified){
1429 $this->handle_post_events("modify", array("uid" => $this->uid));
1430 }
1431 } else {
1432 $this->handle_post_events("add", array("uid" => $this->uid));
1433 }
1434 }
1437 /* Force password set, if this account doesn't have any samba passwords */
1438 function password_change_needed()
1439 {
1440 if(!$this->initially_was_account && $this->is_account){
1441 $ldap = $this->config->get_ldap_link();
1442 $ldap->cat($this->dn,array("sambaLMPassword","sambaNTPassword"));
1443 $attrs = $ldap->fetch();
1444 if(!isset($attrs['sambaLMPassword']) || !isset($attrs['sambaNTPassword'])){
1445 return(TRUE);
1446 }
1447 }
1448 return(FALSE);
1449 }
1452 function adapt_from_template($dn, $skip= array())
1453 {
1454 plugin::adapt_from_template($dn, $skip);
1457 $this->sambaSID= "";
1458 $this->sambaPrimaryGroupSID= "";
1460 /* Fill mungedDial field */
1461 if ($this->samba3 && isset($this->attrs['sambaMungedDial']) && !in_array('sambaMungedDial', $skip)){
1462 $this->mungedObject->load($this->sambaMungedDial);
1463 }
1465 /* Adapt munged attributes */
1466 foreach($this->ctxattributes as $attr){
1467 if(isset($this->mungedObject->ctx[$attr]))
1468 $val = $this->mungedObject->ctx[$attr];
1470 foreach (array("sn", "givenName", "uid") as $repl){
1471 if (preg_match("/%$repl/i", $val)){
1472 $val= preg_replace ("/%$repl/i", $this->parent->$repl, $val);
1473 }
1474 }
1475 $this->mungedObject->ctx[$attr] = $val;
1476 }
1478 /* Password expiery */
1479 if(isset($this->attrs['sambaPwdMustChange']) &&
1480 $this->attrs['sambaPwdMustChange'][0] != 0 && !in_array('sambaPwdMustChange', $skip)){
1481 $this->password_expires= 1;
1482 }
1484 if(isset($this->attrs['sambaLogonTime']) && ! (
1485 $this->attrs['sambaLogonTime'][0] == 0 ||
1486 $this->attrs['sambaLogonTime'][0] == 2147483647
1487 ) && !in_array('sambaLogonTime', $skip)){
1488 $this->logon_time_set= 1;
1489 }
1490 if(isset($this->attrs['sambaLogoffTime']) && ! (
1491 $this->attrs['sambaLogoffTime'][0] == 0 ||
1492 $this->attrs['sambaLogoffTime'][0] == 2147483647
1493 ) && !in_array('sambaLogonTime', $skip)){
1494 $this->logoff_time_set= 1;
1495 }
1497 /* Account expiery */
1498 if(isset($this->attrs['sambaKickoffTime']) && ! (
1499 $this->attrs['sambaKickoffTime'][0] == 0 ||
1500 $this->attrs['sambaKickoffTime'][0] == 2147483647
1501 ) && !in_array('sambaKickoffTime', $skip)){
1502 $this->kickoff_time_set= 1;
1503 }
1505 /* Get global filter config */
1506 if (!session::is_set("sambafilter")){
1507 $ui= get_userinfo();
1508 $base= get_base_from_people($ui->dn);
1509 $sambafilter= array( "depselect" => $base, "regex" => "*");
1510 session::set("sambafilter", $sambafilter);
1511 }
1512 }
1515 static function plInfo()
1516 {
1517 return (array(
1518 "plShortName" => _("Samba"),
1519 "plDescription" => _("Samba settings"),
1520 "plSelfModify" => TRUE,
1521 "plDepends" => array("user"),
1522 "plPriority" => 5,
1523 "plSection" => array("personal" => _("My account")),
1524 "plCategory" => array("users"),
1525 "plOptions" => array(),
1527 "plProvidedAcls" => array(
1529 "sambaHomePath" => _("Generic home directory") ,
1530 "sambaHomeDrive" => _("Generic samba home drive") ,
1531 "sambaDomainName" => _("Domain") ,
1532 "sambaLogonScript" => _("Generic script path") ,
1533 "sambaProfilePath" => _("Generic profile path") ,
1534 "AllowLoginOnTerminalServer" => _("Allow login on terminal server"),
1535 "InheritClientConfig" => _("Inherit client config"),
1536 "sambaPwdCanChange" => _("Allow user to change password") ,
1537 "sambaAcctFlagsN" => _("Login from windows client requires no password"),
1538 "sambaAcctFlagsL" => _("Lock samba account"),
1539 "sambaKickoffTime" => _("Account expires") ,
1540 "sambaPwdMustChange" => _("Password expires") ,
1541 "sambaLogonTime" => _("Limit Logon Time") ,
1542 "sambaLogoffTime" => _("Limit Logoff Time") ,
1543 "sambaLogonHours" => _("Logon hours") ,
1544 "sambaUserWorkstations" => _("Allow connection from"))
1545 ));
1546 }
1548 function enable_multiple_support()
1549 {
1550 plugin::enable_multiple_support();
1551 if($this->samba3){
1552 $this->multiple_support_active = TRUE;
1553 }else{
1554 $this->multiple_support_active = FALSE;
1555 }
1556 }
1558 function multiple_save_object()
1559 {
1560 if (isset($_POST['sambaTab'])){
1561 $this->save_object();
1562 plugin::multiple_save_object();
1563 foreach(array("allow_pwchange","tslogin","CtxWFHomeDir","CtxWFHomeDirDrive","CtxWFProfilePath",
1564 "inherit","CtxWorkDirectory","CtxInitialProgram","CtxMaxConnectionTimeF","CtxMaxConnectionTime","CtxMaxDisconnectionTimeF",
1565 "CtxMaxDisconnectionTime","CtxMaxIdleTimeF","CtxMaxIdleTime","connectclientdrives",
1566 "onnectclientprinters","defaultprinter","shadow","brokenconn",
1567 "reconn","allow_pwchange","connectclientprinters","no_password_required","temporary_disable",
1568 "password_expires","logon_time_set","logoff_time_set","kickoff_time_set","SetSambaLogonHours",
1569 "workstation_list") as $attr){
1570 if(isset($_POST["use_".$attr])){
1571 $this->multi_boxes[] = $attr;
1572 }
1573 }
1574 }
1575 }
1578 function multiple_check()
1579 {
1580 $message = plugin::multiple_check();
1582 /* Strings */
1583 foreach (array( "sambaHomePath" => _("Home directory"),
1584 "sambaProfilePath" => _("Profile path")) as $key => $val){
1585 if (in_array($key,$this->multi_boxes) && !$this->mungedObject->is_samba_path($this->$key)){
1586 $message[]= msgPool::invalid($val);
1587 }
1588 }
1590 /* Numeric values */
1591 foreach (array( "CtxMaxConnectionTime" => _("Connection"),
1592 "CtxMaxDisconnectionTime" => _("Disconnection"),
1593 "CtxMaxIdleTime" => _("IDLE")) as $key => $val){
1594 if (in_array($key,$this->multi_boxes) &&
1595 isset($this->mungedObject->ctx[$key]) &&
1596 !tests::is_id($this->mungedObject->ctx[$key]) && $val != 0){
1597 $message[]=msgPool::invalid($val);
1598 }
1599 }
1601 /* Too many workstations? Windows usrmgr only supports eight */
1602 if (substr_count($this->sambaUserWorkstations, ",") >= 8){
1603 $message[]= _("The windows user manager only allows eight clients. You've specified more than eight.");
1604 }
1605 return($message);
1606 }
1609 function get_multi_init_values()
1610 {
1611 $ret = plugin::get_multi_init_values();
1613 /* Parse given sambaUserWorkstations into array
1614 * to allow "init_multiple_support()" to detect multiple used workstations.
1615 * Those workstations will be displayed in light grey.
1616 */
1617 $tmp2 = array("count" => 0);
1618 $tmp = split(",", $this->sambaUserWorkstations);
1619 foreach($tmp as $station){
1620 $station = trim($station);
1621 if(!empty($station)){
1622 $tmp2[] = $station;
1623 $tmp2['count'] ++;
1624 }
1625 }
1626 $ret['sambaUserWorkstations'] = $tmp2;
1627 return($ret);
1628 }
1632 function init_multiple_support($attrs,$all)
1633 {
1634 plugin::init_multiple_support($attrs,$all);
1636 $this->multiple_sambaUserWorkstations = array();
1637 if(isset($all['sambaUserWorkstations'])){
1638 for($i = 0 ; $i < $all['sambaUserWorkstations']['count'] ; $i++){
1639 $station = trim($all['sambaUserWorkstations'][$i]);
1640 $this->multiple_sambaUserWorkstations[$station] = array("Name" => $station, "UsedByAllUsers" => FALSE);
1641 }
1642 }
1643 if(isset($attrs['sambaUserWorkstations'])){
1644 for($i = 0 ; $i < $attrs['sambaUserWorkstations']['count'] ; $i++){
1645 $station = trim($attrs['sambaUserWorkstations'][$i]);
1646 $this->multiple_sambaUserWorkstations[$station] = array("Name" => $station, "UsedByAllUsers" => TRUE);
1647 }
1648 }
1649 }
1651 function multiple_execute()
1652 {
1653 return($this->execute());
1654 }
1656 function get_multi_edit_values()
1657 {
1658 $ret = plugin::get_multi_edit_values();
1660 /* Terminal Server */
1661 if(in_array("tslogin",$this->multi_boxes)){
1662 $ret['tslogin'] = $this->mungedObject->getTsLogin();
1663 }
1664 if(in_array("CtxWFHomeDirDrive",$this->multi_boxes)){
1665 $ret['CtxWFHomeDirDrive'] = $this->mungedObject->ctx['CtxWFHomeDirDrive'];
1666 }
1667 if(in_array("CtxWFHomeDir",$this->multi_boxes)){
1668 $ret['CtxWFHomeDir'] = $this->mungedObject->ctx['CtxWFHomeDir'];
1669 }
1670 if(in_array("CtxWFProfilePath",$this->multi_boxes)){
1671 $ret['CtxWFProfilePath'] = $this->mungedObject->ctx['CtxWFProfilePath'];
1672 }
1674 if(in_array("inherit",$this->multi_boxes)){
1675 $ret['inherit'] = $this->mungedObject->getInheritMode();
1676 }
1677 if(in_array("CtxInitialProgram",$this->multi_boxes)){
1678 $ret['CtxInitialProgram'] = $this->mungedObject->ctx['CtxInitialProgram'];
1679 }
1680 if(in_array("CtxWorkDirectory",$this->multi_boxes)){
1681 $ret['CtxWorkDirectory'] = $this->mungedObject->ctx['CtxWorkDirectory'];
1682 }
1684 /* Time Limits. Be careful here, there are some negations */
1685 if(in_array("CtxMaxConnectionTimeF",$this->multi_boxes)){
1686 $ret["CtxMaxConnectionTimeF"] = !$this->mungedObject->getCtxMaxConnectionTimeF();
1687 if(!$ret["CtxMaxConnectionTimeF"]){
1688 $ret["CtxMaxConnectionTime"] = $this->mungedObject->ctx['CtxMaxConnectionTime'];
1689 }
1690 }
1691 if(in_array("CtxMaxDisconnectionTimeF",$this->multi_boxes)){
1692 $ret["CtxMaxDisconnectionTimeF"]= !$this->mungedObject->getCtxMaxDisconnectionTimeF();
1693 if(!$ret["CtxMaxDisconnectionTimeF"]){
1694 $ret["CtxMaxDisconnectionTime"]= $this->mungedObject->ctx['CtxMaxDisconnectionTime'];
1695 }
1696 }
1697 if(in_array("CtxMaxIdleTimeF",$this->multi_boxes)){
1698 $ret["CtxMaxIdleTimeF"] = !$this->mungedObject->getCtxMaxIdleTimeF();
1699 if(!$ret["CtxMaxIdleTimeF"]){
1700 $ret["CtxMaxIdleTime"] = $this->mungedObject->ctx['CtxMaxIdleTime'];
1701 }
1702 }
1704 /* Client Devices */
1705 if(in_array("connectclientdrives",$this->multi_boxes)){
1706 $ret["connectclientdrives"] = $this->mungedObject->getConnectClientDrives();
1707 }
1708 if(in_array("connectclientprinters",$this->multi_boxes)){
1709 $ret["connectclientprinters"] = $this->mungedObject->getConnectClientPrinters();
1710 }
1711 if(in_array("defaultprinter",$this->multi_boxes)){
1712 $ret["defaultprinter"] = $this->mungedObject->getDefaultPrinter();
1713 }
1715 /* Misc */
1716 if(in_array("shadow",$this->multi_boxes)){
1717 $ret["shadow"] =$this->mungedObject->getShadow();
1718 }
1719 if(in_array("brokenconn",$this->multi_boxes)){
1720 $ret["brokenconn"]=$this->mungedObject->getBrokenConn();
1721 }
1722 if(in_array("reconn",$this->multi_boxes)){
1723 $ret["reconn"] =$this->mungedObject->getReConn();
1724 }
1726 /* Flags */
1727 if(in_array("allow_pwchange",$this->multi_boxes)){
1728 $ret['sambaPwdCanChange'] = $this->sambaPwdCanChange;
1729 $ret['pwdCanChange'] = $this->pwdCanChange;
1730 }
1732 if(in_array("password_expires",$this->multi_boxes)){
1733 $ret['password_expires'] = $this->password_expires;
1734 $ret['sambaPwdMustChange']= $this->sambaPwdMustChange;
1735 }
1736 if(in_array("logon_time_set",$this->multi_boxes)){
1737 $ret['logon_time_set'] = $this->logon_time_set;
1738 $ret['sambaLogonTime'] = $this->sambaLogonTime;
1739 }
1740 if(in_array("logoff_time_set",$this->multi_boxes)){
1741 $ret['logoff_time_set'] = $this->logoff_time_set;
1742 $ret['sambaLogoffTime'] = $this->sambaLogoffTime;
1743 }
1744 if(in_array("kickoff_time_set",$this->multi_boxes)){
1745 $ret['kickoff_time_set'] = $this->kickoff_time_set;
1746 $ret['sambaKickoffTime'] = $this->sambaKickoffTime;
1747 }
1749 if(in_array("no_password_required",$this->multi_boxes)){
1750 $ret['no_password_required'] = $this->no_password_required;
1751 }
1753 if(in_array("temporary_disable",$this->multi_boxes)){
1754 $ret['temporary_disable'] = $this->temporary_disable;
1755 }
1757 if(in_array("SetSambaLogonHours",$this->multi_boxes)){
1758 $ret['sambaLogonHours'] = $this->sambaLogonHours;
1759 }
1761 if(in_array("workstation_list",$this->multi_boxes)){
1762 $ret['multiple_sambaUserWorkstations'] = $this->multiple_sambaUserWorkstations;
1763 }
1764 return($ret);
1765 }
1767 function set_multi_edit_values($values)
1768 {
1769 plugin::set_multi_edit_values($values);
1771 /* Prepare current workstation settings to be merged
1772 * with multiple edit settings.
1773 */
1774 if(isset($values['multiple_sambaUserWorkstations'])){
1775 $cur_ws = array();
1776 $m_ws = $values['multiple_sambaUserWorkstations'];
1778 /* Prepare current settings to be merged */
1779 if(isset($this->sambaUserWorkstations)){
1780 $ttmp = split(",",$this->sambaUserWorkstations);
1781 foreach($ttmp as $station){
1782 $station = trim($station);
1783 if(!empty($station)){
1784 $cur_ws[$station] = array("Name" => $station, "UsedByAllUsers" => TRUE);
1785 }
1786 }
1787 }
1789 /* Unset removed workstations */
1790 foreach($cur_ws as $cur_name => $cur_station){
1791 if(!isset($m_ws[$cur_name])){
1792 unset($cur_ws[$cur_name]);
1793 }
1794 }
1796 /* Add all added workstations */
1797 foreach($m_ws as $name => $station){
1798 if($station['UsedByAllUsers']){
1799 $cur_ws[$name] = $station;
1800 }
1801 }
1803 $this->sambaUserWorkstations = "";
1804 foreach($cur_ws as $name => $ws){
1805 $this->sambaUserWorkstations .= $name.",";
1806 }
1807 $this->sambaUserWorkstations=preg_replace("/,$/","",$this->sambaUserWorkstations);
1808 }
1810 /* Enable disabled terminal login, this is inverted somehow */
1811 if(isset($values['tslogin'])) $this->mungedObject->setTsLogin(!$values['tslogin']);
1813 /* Imherit client configuration */
1814 if(isset($values['inherit'])) $this->mungedObject->setInheritMode($values['inherit']);
1816 /* Get all ctx values posted */
1817 $ctx = array("CtxWFHomeDirDrive","CtxWFHomeDir","CtxWFProfilePath","CtxInitialProgram","CtxWorkDirectory",
1818 "CtxMaxConnectionTime","CtxMaxDisconnectionTime","CtxMaxIdleTime");
1819 foreach($ctx as $attr){
1820 if(isset($values[$attr])){
1821 $this->mungedObject->ctx[$attr] = $values[$attr] ;
1822 }
1823 }
1825 if(isset($values['CtxMaxConnectionTimeF'])) $this->mungedObject->setCtxMaxConnectionTimeF($values['CtxMaxConnectionTimeF']);
1826 if(isset($values['CtxMaxDisconnectionTimeF']))$this->mungedObject->setCtxMaxDisconnectionTimeF($values['CtxMaxDisconnectionTimeF']);
1827 if(isset($values['CtxMaxIdleTimeF'])) $this->mungedObject->setCtxMaxIdleTimeF($values['CtxMaxIdleTimeF']);
1829 if(isset($values['connectclientdrives'])) $this->mungedObject->setConnectClientDrives($values['connectclientdrives']);
1830 if(isset($values['connectclientprinters'])) $this->mungedObject->setConnectClientPrinters($values['connectclientprinters']);
1831 if(isset($values['defaultprinter'])) $this->mungedObject->setDefaultPrinter($values['defaultprinter']);
1833 if(isset($values['shadow'])) $this->mungedObject->setShadow($values['shadow'],$values['shadow']);
1834 if(isset($values['brokenconn'])) $this->mungedObject->setBrokenConn($values['brokenconn'],$values['brokenconn']);
1835 if(isset($values['reconn'])) $this->mungedObject->setReConn($values['reconn'],$values['reconn']);
1838 if(isset($values['sambaPwdCanChange'])) $this->sambaPwdCanChange = $values['sambaPwdCanChange'];
1839 if(isset($values['pwdCanChange'])) $this->pwdCanChange = $values['pwdCanChange'];
1844 if(isset($values['password_expires'])){
1845 $this->password_expires = $values['password_expires'];
1846 $this->sambaPwdMustChange = $values['sambaPwdMustChange'];
1847 }
1848 if(isset($values['logon_time_set'])){
1849 $this->logon_time_set = $values['logon_time_set'];
1850 $this->sambaLogonTime = $values['sambaLogonTime'];
1851 }
1852 if(isset($values['logoff_time_set'])){
1853 $this->logoff_time_set = $values['logoff_time_set'];
1854 $this->sambaLogoffTime = $values['sambaLogoffTime'];
1855 }
1856 if(isset($values['kickoff_time_set'])){
1857 $this->kickoff_time_set = $values['kickoff_time_set'];
1858 $this->sambaKickoffTime = $values['sambaKickoffTime'];
1859 }
1861 if(isset($values['no_password_required'])){
1862 if($values['no_password_required']){
1863 if(!preg_match("/N/",$this->sambaAcctFlags)) {
1864 $this->sambaAcctFlags = preg_replace("/ /","N",$this->sambaAcctFlags,1);
1865 }
1866 }else{
1867 $this->sambaAcctFlags = preg_replace("/N/"," ",$this->sambaAcctFlags,1);
1868 }
1869 }
1871 if(isset($values['temporary_disable'])){
1872 if($values['temporary_disable']){
1873 if(preg_match("/L/",$this->sambaAcctFlags)) {
1874 // Keep L
1875 }else{
1876 $this->sambaAcctFlags = preg_replace("/ /","D",$this->sambaAcctFlags,1);
1877 }
1878 }else{
1879 $this->sambaAcctFlags = preg_replace("/D/"," ",$this->sambaAcctFlags,1);
1880 }
1881 }
1882 }
1885 function PrepareForCopyPaste($source)
1886 {
1887 plugin::PrepareForCopyPaste($source);
1889 /* Set a new SID */
1890 $this->sambaSID = "";
1891 }
1893 }
1895 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1896 ?>