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 2 attributes */
34 var $pwdLastSet= "0";
35 var $logonTime= "0";
36 var $logoffTime= "2147483647";
37 var $kickoffTime= "2147483647";
38 var $pwdCanChange= "0";
39 var $pwdMustChange= "0";
40 var $password_expires= 0;
41 var $acctFlags= "[UX ]";
42 var $smbHome= "";
43 var $homeDrive= "";
44 var $scriptPath= "";
45 var $profilePath= "";
46 var $rid= "";
47 var $primaryGroupID= "";
49 /* Samba 3 attributes */
50 var $SID= "";
51 var $ridBase= 0;
52 var $sambaSID= "";
53 var $sambaPwdLastSet= "0";
54 var $sambaLogonTime= "0";
55 var $sambaLogoffTime= "2147483647";
56 var $sambaKickoffTime= "2147483647";
57 var $sambaPwdCanChange= "";
58 var $sambaPwdMustChange= "0";
59 var $sambaAcctFlags= "[UX ]";
60 var $sambaHomePath= "";
61 var $sambaHomeDrive= "";
62 var $sambaLogonScript= "";
63 var $sambaProfilePath= "";
64 var $sambaPrimaryGroupSID= "";
65 var $sambaDomainName= "";
66 var $sambaUserWorkstations= "";
67 var $sambaBadPasswordCount= "";
68 var $sambaBadPasswordTime= "";
69 var $sambaPasswordHistory= "";
70 var $sambaLogonHours= "";
71 var $orig_sambaDomainName= "";
72 var $sambaMungedDial= "";
73 var $mungedObject;
75 /* Helper */
76 var $cache = array();
77 var $show_ws_dialog= FALSE;
78 var $logon_time_set= 0;
79 var $logoff_time_set= 0;
80 var $kickoff_time_set= 0;
82 /* attribute list for save action */
83 var $ctxattributes= array();
84 var $attributes= array();
85 var $objectclasses= array();
87 var $uid= "";
88 var $CopyPasteVars = array("kickoff_time_set","logoff_time_set","logon_time_set","mungedObject","orig_sambaDomainName");
90 var $multiple_support = TRUE;
92 /* Only used for multiple edit */
93 var $temporary_disable = FALSE;
94 var $no_password_required = FALSE;
95 var $no_expiry = FALSE;
96 var $multiple_sambaUserWorkstations = array();
98 function sambaAccount (&$config, $dn= NULL)
99 {
100 /* Load attributes depending on the samba version */
101 $this->samba3= ($config->get_cfg_value("sambaversion") == 3);
103 if ($this->samba3){
104 $this->attributes= array ("sambaSID", "sambaPwdLastSet", "sambaLogonTime",
105 "sambaLogoffTime", "sambaKickoffTime", "sambaPwdCanChange",
106 "sambaPwdMustChange", "sambaAcctFlags", "uid", "sambaMungedDial",
107 "sambaHomePath", "sambaHomeDrive", "sambaLogonScript",
108 "sambaProfilePath", "sambaPrimaryGroupSID", "sambaDomainName",
109 "sambaUserWorkstations", "sambaPasswordHistory",
110 "sambaLogonHours", "sambaBadPasswordTime",
111 "sambaBadPasswordCount");
112 $this->objectclasses= array ("sambaSamAccount");
113 $this->mungedObject= new sambaMungedDial;
114 $this->ctxattributes= $this->mungedObject->ctxattributes;
115 } else {
116 $this->attributes= array ("pwdLastSet", "logonTime", "logoffTime", "kickoffTime",
117 "pwdCanChange", "pwdMustChange", "acctFlags", "profilePath", "uid",
118 "smbHome", "homeDrive", "scriptPath", "rid", "primaryGroupID");
119 $this->objectclasses= array ("sambaAccount");
120 }
122 plugin::plugin ($config, $dn);
124 /* Setting uid to default */
125 if(isset($this->attrs['uid'][0])){
126 $this->uid = $this->attrs['uid'][0];
127 }
129 /* Get samba Domain in case of samba 3 */
130 if ($this->samba3 && $this->sambaSID != ""){
131 $this->SID= preg_replace ("/-[^-]+$/", "", $this->sambaSID);
132 $ldap= $this->config->get_ldap_link();
133 $ldap->cd($this->config->current['BASE']);
134 $ldap->search ("(&(objectClass=sambaDomain)(sambaSID=$this->SID))",array("sambaAlgorithmicRidBase","sambaDomainName"));
135 if ($ldap->count() != 0){
136 $attrs= $ldap->fetch();
137 if(isset($attrs['sambaAlgorithmicRidBase'])){
138 $this->ridBase= $attrs['sambaAlgorithmicRidBase'][0];
139 } else {
140 $this->ridBase= $this->config->get_cfg_value("sambaRidBase");
141 }
142 if ($this->sambaDomainName == ""){
143 $this->sambaDomainName= $attrs['sambaDomainName'][0];
144 }
145 } else {
146 if ($this->sambaDomainName == ""){
147 $this->sambaDomainName= "DEFAULT";
148 }
149 $this->ridBase= $this->config->get_cfg_value("sambaRidBase");
150 $this->SID= $this->config->get_cfg_value("sambaSid");
151 }
153 /* Save in order to compare later on */
154 $this->orig_sambaDomainName= $this->sambaDomainName;
155 }
157 /* Fill mungedDial field */
158 if ($this->samba3 && isset($this->attrs['sambaMungedDial'])){
159 $this->mungedObject->load($this->sambaMungedDial);
160 }
162 /* Password expiery */
163 if(isset($this->attrs['sambaPwdMustChange']) &&
164 $this->attrs['sambaPwdMustChange'][0] != 0){
165 $this->password_expires= 1;
166 }
168 if(isset($this->attrs['sambaLogonTime']) && ! (
169 $this->attrs['sambaLogonTime'][0] == 0 ||
170 $this->attrs['sambaLogonTime'][0] == 2147483647
171 )){
172 $this->logon_time_set= 1;
173 }
174 if(isset($this->attrs['sambaLogoffTime']) && ! (
175 $this->attrs['sambaLogoffTime'][0] == 0 ||
176 $this->attrs['sambaLogoffTime'][0] == 2147483647
177 )){
178 $this->logoff_time_set= 1;
179 }
181 /* Account expiery */
182 if(isset($this->attrs['sambaKickoffTime']) && ! (
183 $this->attrs['sambaKickoffTime'][0] == 0 ||
184 $this->attrs['sambaKickoffTime'][0] == 2147483647
185 )){
186 $this->kickoff_time_set= 1;
187 }
189 /* Get global filter config */
190 if (!session::is_set("sambafilter")){
191 $ui= get_userinfo();
192 $base= get_base_from_people($ui->dn);
193 $sambafilter= array( "depselect" => $base, "regex" => "*");
194 session::set("sambafilter", $sambafilter);
195 }
197 /* Save initial account state */
198 $this->initially_was_account= $this->is_account;
200 /* Convert kickoff */
201 #TODO: use date format
202 $this->sambaKickoffTime= $this->sambaKickoffTime == 0?"":date('d.m.Y', $this->sambaKickoffTime);
203 $this->sambaPwdMustChange= $this->sambaPwdMustChange == 2147483647?"":date('d.m.Y', $this->sambaPwdMustChange);
204 }
206 function execute()
207 {
208 /* Call parent execute */
209 plugin::execute();
211 /* Log view */
212 if($this->is_account && !$this->view_logged){
213 $this->view_logged = TRUE;
214 new log("view","users/".get_class($this),$this->dn);
215 }
217 /* Do we need to flip is_account state? */
218 if (isset($_POST['modify_state'])){
219 $this->is_account= !$this->is_account;
220 }
221 /* Do we represent a valid account? */
222 if (!$this->is_account && $this->parent === NULL){
223 $display= "<img alt=\"\"src=\"images/small-error.png\" align=\"middle\"> <b>".
224 msgPool::noValidExtension(_("Samba"))."</b>";
225 $display.= back_to_main();
226 return ($display);
227 }
229 $display ="";
230 if(!$this->multiple_support_active){
232 /* Show tab dialog headers */
233 $display= "";
234 if ($this->parent !== NULL){
235 if ($this->is_account){
236 $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Samba")),
237 msgPool::featuresEnabled(_("Samba")));
238 } else {
239 $obj= $this->parent->by_object['posixAccount'];
241 /* Samba3 dependency on posix accounts are enabled
242 in the moment, because I need to rely on unique
243 uidNumbers. There'll be a better solution later
244 on. */
245 if ($obj->is_account){
246 $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Samba")),
247 msgPool::featuresDisabled(_("Samba")));
248 } else {
249 $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Samba")),
250 msgPool::featuresDisabled(_("Samba"), _("POSIX")), TRUE);
251 }
252 return ($display);
253 }
254 }
255 }
257 $SkipWrite = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
259 /* Open Samaba Logong hours dialog */
260 if(isset($_POST['SetSambaLogonHours']) && $this->samba3 && $this->acl_is_readable("sambaLogonHours")){
261 $this->dialog = new sambaLogonHours($this->config,$this->dn,$this->sambaLogonHours);
262 }
264 /* Cancel dialog */
265 if(isset($_POST['cancel_logonHours'])){
266 $this->dialog = FALSE;
267 }
269 /* Save selected logon hours */
270 if(isset($_POST['save_logonHours'])){
271 $this->dialog->save_object();
272 if($this->acl_is_writeable("sambaLogonHours")){
273 $this->sambaLogonHours = $this->dialog->save();
274 }
275 $this->dialog = FALSE;
276 }
278 /* Display dialog */
279 if((isset($this->dialog)) && (is_object($this->dialog))){
280 $this->dialog->save_object();
281 return($this->dialog->execute());
282 }
284 /* Prepare templating */
285 $smarty= get_smarty();
286 $smarty->assign("usePrototype", "true");
288 $tmp = $this->plInfo();
289 foreach($tmp['plProvidedAcls'] as $var => $rest){
290 $smarty->assign($var."ACL",$this->getacl($var,$SkipWrite));
291 }
293 if(!session::is_set('edit') && !isset($this->parent)){
294 $smarty->assign("sambaLogonHoursACL","");
295 }
297 if ($this->sambaLogonTime=="2147483647" || $this->sambaLogonTime=="0"){
298 $sambaLogonTime_date= getdate();
299 } else {
300 $sambaLogonTime_date= getdate($this->sambaLogonTime);
301 }
303 if ($this->sambaLogoffTime=="2147483647" || $this->sambaLogoffTime=="0"){
304 $sambaLogoffTime_date= getdate();
305 } else {
306 $sambaLogoffTime_date= getdate($this->sambaLogoffTime);
307 }
309 /* Remove user workstations? */
310 if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){
312 if($this->acl_is_writeable("sambaUserWorkstations",$SkipWrite)){
314 if($this->multiple_support_active){
315 foreach($_POST['workstation_list'] as $name){
316 if(isset($this->multiple_sambaUserWorkstations[trim($name)])){
317 unset($this->multiple_sambaUserWorkstations[trim($name)]);
318 }
319 }
320 }else{
321 $tmp= $this->sambaUserWorkstations;
322 foreach($_POST['workstation_list'] as $name){
323 $tmp= preg_replace("/$name/", '', $tmp);
324 $this->is_modified= TRUE;
325 }
326 $tmp= preg_replace('/,+/', ',', $tmp);
327 $this->sambaUserWorkstations= trim($tmp, ',');
328 }
329 }
330 }
332 /* Add user workstation? */
333 if (isset($_POST["add_ws"])){
334 if($this->acl_is_writeable("sambaUserWorkstations",$SkipWrite)){
335 $this->show_ws_dialog= TRUE;
336 $this->dialog= TRUE;
337 }
338 }
340 /* Add user workstation finished? */
341 if (isset($_POST["add_ws_cancel"])){
342 $this->show_ws_dialog= FALSE;
343 $this->dialog= FALSE;
344 }
346 /* Add user workstation? */
347 if (isset($_POST["add_ws_finish"])){
349 if (isset($_POST['wslist'])){
350 if($this->multiple_support_active){
351 foreach($_POST['wslist'] as $ws){
352 $this->multiple_sambaUserWorkstations[trim($we)] = array("Name" => trim($ws), "UsedByAllUsers" => TRUE);
353 }
354 }else{
355 $tmp= $this->sambaUserWorkstations;
356 foreach($_POST['wslist'] as $ws){
357 $tmp.= ",$ws";
358 }
359 $tmp= preg_replace('/,+/', ',', $tmp);
360 $this->sambaUserWorkstations= trim($tmp, ',');
361 }
362 $this->is_modified= TRUE;
364 $this->show_ws_dialog= FALSE;
365 $this->dialog= FALSE;
366 } else {
367 msg_dialog::display(_("Error"), _("Please select an entry!"), ERROR_DIALOG);
368 }
369 }
371 /* Show ws dialog */
372 if ($this->show_ws_dialog){
374 /* Save data */
375 $sambafilter= session::get("sambafilter");
376 foreach( array("depselect", "regex") as $type){
377 if (isset($_POST[$type])){
378 $sambafilter[$type]= $_POST[$type];
379 }
380 }
381 if (isset($_GET['search'])){
382 $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
383 if ($s == "**"){
384 $s= "*";
385 }
386 $sambafilter['regex']= $s;
387 }
388 session::set("sambafilter", $sambafilter);
390 /* Get workstation list */
391 $exclude= "";
393 if($this->multiple_support_active){
394 foreach($this->multiple_sambaUserWorkstations as $ws){
395 if($ws['UsedByAllUsers']){
396 $exclude.= "(cn=".$ws['Name']."$)";
397 }
398 }
399 }else{
400 foreach(split(',', $this->sambaUserWorkstations) as $ws){
401 $exclude.= "(cn=$ws$)";
402 }
403 }
404 if ($exclude != ""){
405 $exclude= "(!(|$exclude))";
406 }
407 $regex= $sambafilter['regex'];
408 $filter= "(&(objectClass=sambaSAMAccount)$exclude(uid=*$)(|(uid=$regex)(cn=$regex)))";
409 $res= get_list($filter, "winworkstation", $sambafilter['depselect'], array("uid"), GL_SUBSEARCH | GL_SIZELIMIT);
411 $wslist= array();
412 foreach ($res as $attrs){
413 $wslist[]= preg_replace('/\$/', '', $attrs['uid'][0]);
414 }
415 asort($wslist);
417 $smarty->assign("search_image", get_template_path('images/lists/search.png'));
418 $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
419 $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
420 $smarty->assign("deplist", $this->config->idepartments);
421 $smarty->assign("alphabet", generate_alphabet());
422 foreach( array("depselect", "regex") as $type){
423 $smarty->assign("$type", $sambafilter[$type]);
424 }
425 $smarty->assign("hint", print_sizelimit_warning());
426 $smarty->assign("wslist", $wslist);
427 $smarty->assign("apply", apply_filter());
428 $display= $smarty->fetch (get_template_path('samba3_workstations.tpl', TRUE,
429 dirname(__FILE__)));
430 return ($display);
431 }
433 /* Fill boxes */
434 if ($this->samba3){
435 $domains= array();
436 foreach($this->config->data['SERVERS']['SAMBA'] as $name => $content){
437 $domains[]= $name;
438 }
439 $smarty->assign("domains", $domains);
440 }
441 $letters= array("");
442 for ($i= 68; $i<91; $i++){
443 $letters[]= chr($i).":";
444 }
445 $smarty->assign("drives", $letters);
447 /* Fill terminal server settings */
448 if ($this->samba3){
449 foreach ($this->ctxattributes as $attr){
450 /* Fill common attributes */
451 if (isset($this->mungedObject->ctx[$attr])){
452 $smarty->assign("$attr", $this->mungedObject->ctx[$attr]);
453 // Set field to blank if value is 0
454 if(in_array($attr, array("CtxMaxConnectionTime", "CtxMaxDisconnectionTime", "CtxMaxIdleTime"))) {
455 if($this->mungedObject->ctx[$attr] == 0) {
456 $smarty->assign("$attr", "");
457 }
458 }
459 } else {
460 $smarty->assign("$attr", "");
461 }
462 }
464 /* Assign enum values for preset items */
465 $shadowModeVals= array( "0" => _("disabled"),
466 "1" => _("input on, notify on"),
467 "2" => _("input on, notify off"),
468 "3" => _("input off, notify on"),
469 "4" => _("input off, nofify off"));
471 $brokenConnModeVals= array( "0" => _("disconnect"),
472 "1" => _("reset"));
474 $reConnModeVals= array( "0" => _("from any client"),
475 "1" => _("from previous client only"));
477 /* Fill preset items */
478 $smarty->assign("shadow", $shadowModeVals);
479 $smarty->assign("brokenconn", $brokenConnModeVals);
480 $smarty->assign("reconn", $reConnModeVals);
482 /* Fill preset items with values */
483 $smarty->assign("shadowmode", $this->mungedObject->getShadow());
484 $smarty->assign("brokenconnmode", $this->mungedObject->getBrokenConn());
485 $smarty->assign("reconnmode", $this->mungedObject->getReConn());
487 if(session::get('js')){
488 /* Set form elements to disabled/enable state */
489 $smarty->assign("tsloginstate", $this->mungedObject->getTsLogin()?"":"disabled");
491 $smarty->assign("inheritstate", "");
492 if($this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){
493 $smarty->assign("inheritstate", $this->mungedObject->getInheritMode()?"disabled":"");
494 }
495 }else{
496 $smarty->assign("tsloginstate", "");
497 $smarty->assign("inheritstate", "");
498 }
500 /* Set checkboxes to checked or unchecked state */
501 $smarty->assign("tslogin", $this->mungedObject->getTsLogin()?"checked":"");
502 $smarty->assign("inherit", $this->mungedObject->getInheritMode()?"checked":"");
503 $smarty->assign("connectclientdrives",
504 $this->mungedObject->getConnectClientDrives()?"checked":"");
505 $smarty->assign("connectclientprinters",
506 $this->mungedObject->getConnectClientPrinters()?"checked":"");
507 $smarty->assign("defaultprinter",
508 $this->mungedObject->getDefaultPrinter()?"checked":"");
509 $smarty->assign("CtxMaxConnectionTimeF",
510 $this->mungedObject->getCtxMaxConnectionTimeF()?"checked":"");
511 $smarty->assign("CtxMaxDisconnectionTimeF",
512 $this->mungedObject->getCtxMaxDisconnectionTimeF()?"checked":"");
513 $smarty->assign("CtxMaxIdleTimeF",
514 $this->mungedObject->getCtxMaxIdleTimeF()?"checked":"");
517 /* Fill sambaUserWorkstations */
518 $ws= split(",", $this->sambaUserWorkstations);
519 sort($ws);
521 /* Tidy checks for empty option, and smarty will produce one if array[0]="" */
522 if(($ws[0]=="")&&(count($ws)==1)) $ws=array();
524 if($this->multiple_support_active){
525 $smarty->assign("multiple_workstations",$this->multiple_sambaUserWorkstations);
526 }
528 $smarty->assign("workstations", $ws);
529 }
531 /* Variables */
532 foreach($this->attributes as $val){
533 $smarty->assign("$val", $this->$val);
534 }
536 /* 'sambaAcctFlags' checkboxes */
537 /* Check for 'lock-account'-flag: 'D' or 'L' */
538 if (is_integer(strpos($this->sambaAcctFlags, "D")) ||
539 is_integer(strpos($this->sambaAcctFlags, "L"))) {
540 $smarty->assign("flagsD", "checked");
541 } else {
542 $smarty->assign("flagsD", "");
543 }
545 /* Check for no_password_required flag 'N' */
546 if (is_integer(strpos($this->sambaAcctFlags, "N"))) {
547 $smarty->assign("flagsN", "checked");
548 } else {
549 $smarty->assign("flagsN", "");
550 }
552 // check if password never expires
553 if (is_integer(strpos($this->sambaAcctFlags, "X"))) {
554 $smarty->assign("flagsX", "checked");
555 } else {
556 $smarty->assign("flagsX", "");
557 }
559 if($this->samba3){
560 if ($this->sambaPwdCanChange=="1"){
561 $smarty->assign("flagsP", "checked");
562 } else {
563 $smarty->assign("flagsP", "");
564 }
565 }else{
566 if ($this->pwdCanChange=="1"){
567 $smarty->assign("flagsP", "checked");
568 } else {
569 $smarty->assign("flagsP", "");
570 }
571 }
573 if ($this->password_expires=="1"){
574 $smarty->assign("flagsC", "checked");
575 } else {
576 $smarty->assign("flagsC", "");
577 }
578 if ($this->logon_time_set=="1"){
579 $smarty->assign("flagsT", "checked");
580 } else {
581 $smarty->assign("flagsT", "");
582 }
583 if ($this->logoff_time_set=="1"){
584 $smarty->assign("flagsO", "checked");
585 } else {
586 $smarty->assign("flagsO", "");
587 }
588 if ($this->kickoff_time_set=="1"){
589 $smarty->assign("flagsK", "checked");
590 } else {
591 $smarty->assign("flagsK", "");
592 }
595 /* In case of javascript, disable some fields on demand */
596 if ($this->samba3){
597 foreach($this->mungedObject->getOnDemandFlags() as $key => $value) {
598 $smarty->assign("$key", "$value");
599 }
600 }
603 foreach($this->attributes as $attr){
604 if(in_array($attr,$this->multi_boxes)){
605 $smarty->assign("use_".$attr,TRUE);
606 }else{
607 $smarty->assign("use_".$attr,FALSE);
608 }
609 }
610 foreach(array("allow_pwchange","tslogin","CtxWFHomeDir","CtxWFHomeDirDrive","CtxWFProfilePath",
611 "inherit","CtxWorkDirectory","CtxInitialProgram","CtxMaxConnectionTimeF","CtxMaxConnectionTime","CtxMaxDisconnectionTimeF",
612 "CtxMaxDisconnectionTime","CtxMaxIdleTimeF","CtxMaxIdleTime","connectclientdrives",
613 "onnectclientprinters","defaultprinter","shadow","brokenconn",
614 "reconn","allow_pwchange","connectclientprinters","no_expiry","no_password_required","temporary_disable",
615 "password_expires","logon_time_set","logoff_time_set","kickoff_time_set","SetSambaLogonHours",
616 "workstation_list") as $attr){
617 if(in_array($attr,$this->multi_boxes)){
618 $smarty->assign("use_".$attr,TRUE);
619 }else{
620 $smarty->assign("use_".$attr,FALSE);
621 }
622 }
624 if($this->multiple_support_active){
625 $smarty->assign("tsloginstate","");
626 }
628 /* Create additional info for sambaKickOffTime and sambaPwdMustChange.
629 e.g. Display effective kickoff time. Domain policy + user settings.
630 */
631 $additional_info_PwdMustChange = "";
633 /* Calculate effective max Password Age
634 This can only be calculated if sambaPwdLastSet ist set.
635 */
636 if(isset($this->attrs['sambaPwdLastSet'][0])){
637 $last = $this->attrs['sambaPwdLastSet'][0];
639 $sid = $this->get_domain_info();
640 if(isset($sid['sambaMaxPwdAge'][0])){
641 $d = ($last + $sid['sambaMaxPwdAge'][0]) - time();
643 /* A negative value means the password is outdated
644 */
645 if($d < 0){
646 $additional_info_PwdMustChange = sprintf(_("The password is outdated since %s, by domain policy."),
647 date("d.m.Y H:i:s",$last + $sid['sambaMaxPwdAge'][0]));
648 }else{
649 if($this->password_expires && ($last + $sid['sambaMaxPwdAge'][0]) > $this->sambaPwdMustChange){
650 $additional_info_PwdMustChange = sprintf(_("The password is valid till %s, by user policy."),
651 date("d.m.Y H:i:s", $this->sambaPwdMustChange));
652 }else{
653 $additional_info_PwdMustChange = sprintf(_("The password is valid till %s, by domain policy."),
654 date("d.m.Y H:i:s", ($last + $sid['sambaMaxPwdAge'][0])));
655 }
656 }
657 }
658 }
659 $smarty->assign("additional_info_PwdMustChange",$additional_info_PwdMustChange);
660 $smarty->assign("no_expiry",$this->no_expiry);
662 /* Show main page */
663 $smarty->assign("multiple_support",$this->multiple_support_active);
664 if ($this->samba3){
665 $display.= $smarty->fetch (get_template_path('samba3.tpl', TRUE, dirname(__FILE__)));
666 } else {
667 $display.= $smarty->fetch (get_template_path('samba2.tpl', TRUE, dirname(__FILE__)));
668 }
670 return ($display);
671 }
674 /*! \brief Returns the samba Domain object, selected in the samba tab.
675 */
676 function get_domain_info()
677 {
678 /* Only search once, return last result if available
679 */
680 if(!isset($this->cache['DOMAIN'][$this->sambaDomainName])){
681 $this->cache['DOMAIN'][$this->sambaDomainName] = array();
682 if(!empty($this->sambaDomainName) && isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName])){
683 $cfg = $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName];
684 $ldap = $this->config->get_ldap_link();
685 $ldap->cd($this->config->current['BASE']);
686 $ldap->search("(&(objectClass=sambaDomain)(sambaSID=".$cfg['SID']."))",array("*"));
687 if($ldap->count()){
688 $this->cache['DOMAIN'][$this->sambaDomainName] = $ldap->fetch();
689 }
690 }
691 }
692 return($this->cache['DOMAIN'][$this->sambaDomainName]);
693 }
697 function get_samba_information()
698 {
700 /* Defaults
701 */
702 $sambaMinPwdLength = "unset";
703 $sambaPwdHistoryLength = "unset";
704 $sambaLogonToChgPwd = "unset";
705 $sambaMaxPwdAge = "unset";
706 $sambaMinPwdAge = "unset";
707 $sambaLockoutDuration = "unset";
708 $sambaLockoutThreshold = "unset";
709 $sambaForceLogoff = "unset";
710 $sambaRefuseMachinePwdChange = "unset";
711 $sambaPwdLastSet = "unset";
712 $sambaLogonTime = "unset";
713 $sambaLogoffTime = "unset";
715 $sambaKickoffTime = "unset";
716 $sambaPwdCanChange = "unset";
717 $sambaPwdMustChange = "unset";
718 $sambaBadPasswordCount = "unset";
719 $sambaBadPasswordTime = "unset";
721 /* Domain attributes
722 */
723 $domain_attributes = array("sambaMinPwdLength","sambaPwdHistoryLength","sambaMaxPwdAge",
724 "sambaMinPwdAge","sambaLockoutDuration","sambaRefuseMachinePwdChange",
725 "sambaLogonToChgPwd","sambaLockoutThreshold","sambaForceLogoff");
727 /* User attributes
728 */
729 $user_attributes = array("sambaBadPasswordTime","sambaPwdLastSet","sambaLogonTime","sambaLogoffTime",
730 "sambaKickoffTime","sambaPwdCanChange","sambaPwdMustChange","sambaBadPasswordCount");
732 /* Get samba SID object and parse settings.
733 */
734 $ldap = $this->config->get_ldap_link();
735 $ldap->cd($this->config->current['BASE']);
736 if(!empty($this->sambaDomainName) && isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName])){
737 $attrs = $this->get_domain_info();
738 foreach($domain_attributes as $attr){
739 if(isset($attrs[$attr])){
740 $$attr = $attrs[$attr][0];
741 }
742 }
743 }
745 /* Get user infos
746 */
747 foreach($user_attributes as $attr){
748 if(isset($this->attrs[$attr])){
749 $$attr = $this->attrs[$attr][0];
750 }
751 }
752 if($this->password_expires){
753 $sambaPwdMustChange = $this->sambaPwdMustChange;
754 } else {
755 $sambaPwdMustChange= date('d.m.Y', $sambaPwdMustChange);
756 }
757 if($this->kickoff_time_set){
758 $sambaKickoffTime = $this->sambaKickoffTime;
759 } else {
760 $sambaKickoffTime= date('d.m.Y', $sambaKickoffTime);
761 }
762 $sambaPwdCanChange = $this->sambaPwdCanChange;
765 /* DOMAIN Attributes
766 */
768 /* sambaMinPwdLength: Password length has a default of 5
769 */
770 if($sambaMinPwdLength == "unset" || $sambaMinPwdLength == 5){
771 $sambaMinPwdLength = "5 <i>("._("default").")</i>";
772 }
774 /* sambaPwdHistoryLength: Length of Password History Entries (default: 0 => off)
775 */
776 if($sambaPwdHistoryLength == "unset" || $sambaPwdHistoryLength == 0){
777 $sambaPwdHistoryLength = _("Off")." <i>("._("default").")</i>";
778 }
780 /* sambaLogonToChgPwd: Force Users to logon for password change (default: 0 => off, 2 => on)
781 */
782 if($sambaLogonToChgPwd == "unset" || $sambaLogonToChgPwd == 0){
783 $sambaLogonToChgPwd = _("Off")." <i>("._("default").")</i>";
784 }else{
785 $sambaLogonToChgPwd = _("On");
786 }
788 /* sambaMaxPwdAge: Maximum password age, in seconds (default: -1 => never expire passwords)'
789 */
790 if($sambaMaxPwdAge == "unset" || $sambaMaxPwdAge == "-1"){
791 $sambaMaxPwdAge = _("disabled")." <i>("._("default").")</i>";
792 }else{
793 $sambaMaxPwdAge .= " "._("seconds");
794 }
796 /* sambaMinPwdAge: Minimum password age, in seconds (default: 0 => allow immediate password change
797 */
798 if($sambaMinPwdAge == "unset" || $sambaMinPwdAge == 0){
799 $sambaMinPwdAge = _("disabled")." <i>("._("default").")</i>";
800 }else{
801 $sambaMinPwdAge .= " "._("seconds");
802 }
804 /* sambaLockoutDuration: Lockout duration in minutes (default: 30, -1 => forever)
805 */
806 if($sambaLockoutDuration == "unset" || $sambaLockoutDuration == 30){
807 $sambaLockoutDuration = "30 "._("minutes")." <i>("._("default").")</i>";
808 }elseif($sambaLockoutDuration == -1){
809 $sambaLockoutDuration = _("forever");
810 }else{
811 $sambaLockoutDuration .= " "._("minutes");
812 }
814 /* sambaLockoutThreshold: Lockout users after bad logon attempts (default: 0 => off
815 */
816 if($sambaLockoutThreshold == "unset" || $sambaLockoutThreshold == 0){
817 $sambaLockoutThreshold = _("disabled")." <i>("._("default").")</i>";
818 }
820 /* sambaForceLogoff: Disconnect Users outside logon hours (default: -1 => off, 0 => on
821 */
822 if($sambaForceLogoff == "unset" || $sambaForceLogoff == -1){
823 $sambaForceLogoff = _("off")." <i>("._("default").")</i>";
824 }else{
825 $sambaForceLogoff = _("on");
826 }
828 /* sambaRefuseMachinePwdChange: Allow Machine Password changes (default: 0 => off
829 */
830 if($sambaRefuseMachinePwdChange == "none" || $sambaRefuseMachinePwdChange == 0){
831 $sambaRefuseMachinePwdChange = _("off")." <i>("._("default").")</i>";
832 }else{
833 $sambaRefuseMachinePwdChange = _("on");
834 }
836 /* USER Attributes
837 */
838 /* sambaBadPasswordTime: Time of the last bad password attempt
839 */
840 if($sambaBadPasswordTime == "unset" || empty($sambaBadPasswordTime)){
841 $sambaBadPasswordTime = "<i>("._("unset").")</i>";
842 }else{
843 $sambaBadPasswordTime = date("d.m.Y H:i:s",$sambaBadPasswordTime);
844 }
846 /* sambaBadPasswordCount: Bad password attempt count
847 */
848 if($sambaBadPasswordCount == "unset" || empty($sambaBadPasswordCount)){
849 $sambaBadPasswordCount = "<i>("._("unset").")</i>";
850 }else{
851 $sambaBadPasswordCount = date("d.m.Y H:i:s",$sambaBadPasswordCount);
852 }
854 /* sambaPwdLastSet: Timestamp of the last password update
855 */
856 if($sambaPwdLastSet == "unset" || empty($sambaPwdLastSet)){
857 $sambaPwdLastSet = "<i>("._("unset").")</i>";
858 }else{
859 $sambaPwdLastSet = date("d.m.Y H:i:s",$sambaPwdLastSet);
860 }
862 /* sambaLogonTime: Timestamp of last logon
863 */
864 if($sambaLogonTime == "unset" || empty($sambaLogonTime)){
865 $sambaLogonTime = "<i>("._("unset").")</i>";
866 }else{
867 $sambaLogonTime = date("d.m.Y H:i:s",$sambaLogonTime);
868 }
870 /* sambaLogoffTime: Timestamp of last logoff
871 */
872 if($sambaLogoffTime == "unset" || empty($sambaLogoffTime)){
873 $sambaLogoffTime = "<i>("._("unset").")</i>";
874 }else{
875 $sambaLogoffTime = date("d.m.Y H:i:s",$sambaLogoffTime);
876 }
878 /* sambaKickoffTime: Timestamp of when the user will be logged off automatically
879 */
880 if($sambaKickoffTime == "unset" || empty($sambaKickoffTime)){
881 $sambaKickoffTime = "<i>("._("unset").")</i>";
882 }
884 /* sambaPwdMustChange: Timestamp of when the password will expire
885 */
886 if($sambaPwdMustChange == "unset" || empty($sambaPwdMustChange)){
887 $sambaPwdMustChange = "<i>("._("unset").")</i>";
888 }
890 /* sambaPwdCanChange: Timestamp of when the user is allowed to update the password
891 */
892 if($sambaPwdCanChange == "unset" || empty($sambaPwdCanChange)){
893 $sambaPwdCanChange = "<i>("._("unset").")</i>";
894 }elseif($sambaPwdCanChange != "unset" && time() > $sambaPwdCanChange){
895 $sambaPwdCanChange = _("immediately") ;
896 }else{
897 $days = floor((($sambaPwdCanChange - time()) / 60 / 60 / 24)) ;
898 $hours = floor((($sambaPwdCanChange - time()) / 60 / 60) % 24) ;
899 $minutes = floor((($sambaPwdCanChange - time()) / 60 ) % 60) ;
901 $sambaPwdCanChange = " ".$days." "._("days");
902 $sambaPwdCanChange.= " ".$hours." "._("hours");
903 $sambaPwdCanChange.= " ".$minutes." "._("minutes");
904 }
906 $str =
907 "\n<div style='height:200px; overflow: auto;'>".
908 "\n<table style='width:100%;'>".
909 "\n<tr><td><b>"._("Domain attributes")."</b></td></tr>".
910 "\n<tr><td>"._("Min password length").": </td><td>".$sambaMinPwdLength."</td></tr>".
911 "\n<tr><td>"._("Min password length").": </td><td>".$sambaMinPwdLength."</td></tr>".
912 "\n<tr><td>"._("Password history").": </td><td>".$sambaPwdHistoryLength."</td></tr>".
913 "\n<tr><td>"._("Force password change").": </td><td>".$sambaLogonToChgPwd."</td></tr>".
914 "\n<tr><td>"._("Maximum password age").": </td><td>".$sambaMaxPwdAge."</td></tr>".
915 "\n<tr><td>"._("Minimum password age").": </td><td>".$sambaMinPwdAge."</td></tr>".
916 "\n<tr><td>"._("Lockout duration").": </td><td>".$sambaLockoutDuration."</td></tr>".
917 "\n<tr><td>"._("Bad lockout attempt").": </td><td>".$sambaLockoutThreshold."</td></tr>".
918 "\n<tr><td>"._("Disconnect time").": </td><td>".$sambaForceLogoff."</td></tr>".
919 "\n<tr><td>"._("Refuse machine password change").":</td><td>".$sambaRefuseMachinePwdChange."</td></tr>".
920 "\n<tr><td> </td></tr>".
921 "\n<tr><td><b>"._("User attributes")."</b></td></tr>".
922 "\n<tr><td>"._("Last failed login").": </td><td>".$sambaBadPasswordTime."</td></tr>".
923 "\n<tr><td>"._("Logon attempts").": </td><td>".$sambaBadPasswordCount."</td></tr>".
924 "\n<tr><td>"._("Last password update").": </td><td>".$sambaPwdLastSet."</td></tr>".
925 "\n<tr><td>"._("Last logon").": </td><td>".$sambaLogonTime."</td></tr>".
926 "\n<tr><td>"._("Last logoff").": </td><td>".$sambaLogoffTime."</td></tr>".
927 "\n<tr><td>"._("Automatic logoff").": </td><td>".$sambaKickoffTime."</td></tr>";
929 if($this->no_expiry){
930 $str .= "\n<tr><td>"._("Password expires").": </td><td>"._("No")."</td></tr>";
931 $str .= "\n<tr><td colspan='2'><font color='gray'>".
932 sprintf(_("The password would expire on %s, but the password expiry is disabled."),$sambaPwdMustChange).
933 "</font></td></tr>";
934 }else{
935 $str .= "\n<tr><td>"._("Password expires").": </td><td>".$sambaPwdMustChange."</td></tr>";
936 }
938 $str .= "\n<tr><td>"._("Password change available").": </td><td>".$sambaPwdCanChange."</td></tr>".
939 "\n</table>";
940 "\n</div>";
941 return($str);
942 }
945 function remove_from_parent()
946 {
947 /* Cancel if there's nothing to do here */
948 if (!$this->initially_was_account){
949 return;
950 }
952 /* include global link_info */
953 $ldap= $this->config->get_ldap_link();
955 plugin::remove_from_parent();
957 /* Keep uid attribute for gosaAccount */
958 unset($this->attrs['uid']);
959 unset($this->attrs['uidNumber']);
960 unset($this->attrs['gidNumber']);
962 /* Remove objectClass for sambaIdmapEntry */
963 $tmp= array();
964 for ($i= 0; $i<count($this->attrs["objectClass"]); $i++){
965 if ($this->attrs['objectClass'][$i] != 'sambaIdmapEntry'){
966 $tmp[]= $this->attrs['objectClass'][$i];
967 }
968 }
969 $this->attrs['objectClass']= $tmp;
971 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
972 $this->attributes, "Save");
973 $ldap->cd($this->dn);
974 $this->cleanup();
975 $ldap->modify ($this->attrs);
977 new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
979 if (!$ldap->success()){
980 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
981 }
983 /* Optionally execute a command after we're done */
984 $this->handle_post_events("remove", array("uid" => $this->uid));
985 }
988 /* Check for input problems */
989 function check()
990 {
991 /* Call common method to give check the hook */
992 $message= plugin::check();
994 if ($this->samba3){
996 /* sambaHomePath requires sambaHomeDrive and vice versa */
997 if(!empty($this->sambaHomePath) && empty($this->sambaHomeDrive)){
998 $message[]= msgPool::required(_("Home drive"));
999 }
1000 if(!empty($this->sambaHomeDrive) && empty($this->sambaHomePath)){
1001 $message[]= msgPool::required(_("Home path"));
1002 }
1004 /* Strings */
1005 foreach (array( "sambaHomePath" => _("Home directory"),
1006 "sambaProfilePath" => _("Profile path")) as $key => $val){
1007 if (!$this->mungedObject->is_samba_path($this->$key)){
1008 $message[]= msgPool::invalid($val);
1009 }
1010 }
1012 /* Numeric values */
1013 foreach (array( "CtxMaxConnectionTime" => _("Connection"),
1014 "CtxMaxDisconnectionTime" => _("Disconnection"),
1015 "CtxMaxIdleTime" => _("IDLE")) as $key => $val){
1017 if (isset($this->mungedObject->ctx[$key]) && !tests::is_id($this->mungedObject->ctx[$key]) && $val != 0){
1018 $message[]= msgPool::invalid($val);
1019 }
1020 }
1022 /* Too many workstations? Windows usrmgr only supports eight */
1023 if (substr_count($this->sambaUserWorkstations, ",") >= 8){
1024 $message[]= _("The windows usermanager allows eight clients at maximum!");
1025 }
1026 }
1028 return ($message);
1029 }
1032 /* Save data to object */
1033 function save_object()
1034 {
1036 $SkipWrite = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
1038 /* We only care if we are on the sambaTab... */
1039 if (isset($_POST['sambaTab'])){
1040 plugin::save_object();
1042 if(isset($_POST['display_information'])){
1043 msg_dialog::display(_("Information"),
1044 $this->get_samba_information(),
1045 INFO_DIALOG);
1046 }
1048 /* Take care about access options */
1049 if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){
1050 if ($this->samba3){
1051 $attrname= "sambaPwdCanChange";
1052 } else {
1053 $attrname= "pwdCanChange";
1054 }
1055 if (isset($_POST["allow_pwchange"]) && $_POST["allow_pwchange"] == 1){
1056 $tmp= 1;
1057 } else {
1058 $tmp= 0;
1059 }
1060 if ($this->$attrname != $tmp){
1061 $this->is_modified= TRUE;
1062 }
1063 $this->pwdCanChange= $tmp;
1064 $this->sambaPwdCanChange= $tmp;
1065 }
1066 $tmp= "U";
1068 $this->no_expiry = FALSE;
1069 if (isset($_POST["no_expiry"])){
1070 if ($_POST["no_expiry"] == 1){
1071 $tmp.= "X";
1072 $this->no_expiry = TRUE;
1073 }
1074 }
1076 $this->no_password_required = FALSE;
1077 if (isset($_POST["no_password_required"])){
1078 if ($_POST["no_password_required"] == 1){
1079 $tmp.= "N";
1080 $this->no_password_required = TRUE;
1081 }
1082 }
1083 if (isset($_POST["password_expires"])){
1084 if ($_POST["password_expires"] == 1){
1085 $this->password_expires= 1;
1086 }
1087 } else {
1088 $this->password_expires= 0;
1089 }
1090 $this->temporary_disable = FALSE;
1091 if (isset($_POST["temporary_disable"])){
1092 if ($_POST["temporary_disable"] == 1){
1093 $this->temporary_disable = TRUE;
1094 if (is_integer(strpos($this->sambaAcctFlags, "L"))) {
1095 $tmp.= "L";
1096 } else {
1097 $tmp.= "D";
1098 }
1099 }
1100 }
1101 if (isset($_POST["logon_time_set"])){
1102 if ($_POST["logon_time_set"] == 1){
1103 $this->logon_time_set= 1;
1104 }
1105 } else {
1106 $this->logon_time_set= 0;
1107 }
1108 if (isset($_POST["logoff_time_set"])){
1109 if ($_POST["logoff_time_set"] == 1){
1110 $this->logoff_time_set= 1;
1111 }
1112 } else {
1113 $this->logoff_time_set= 0;
1114 }
1115 if (isset($_POST["kickoff_time_set"])){
1116 if ($_POST["kickoff_time_set"] == 1){
1117 $this->kickoff_time_set= 1;
1118 }
1119 } else {
1120 $this->kickoff_time_set= 0;
1121 }
1123 $fill= "";
1124 for ($i= strlen($tmp); $i<12; $i++){
1125 $fill.= " ";
1126 }
1128 $tmp= "[$tmp$fill]";
1130 /* Only save if acl's are set */
1131 if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){
1132 if ($this->samba3){
1133 $attrname= "sambaAcctFlags";
1134 } else {
1135 $attrname= "acctFlags";
1136 }
1137 if ($this->$attrname != $tmp){
1138 $this->is_modified= TRUE;
1139 }
1140 $this->$attrname= $tmp;
1141 }
1143 /* Save sambaDomain attribute */
1144 if ($this->acl_is_writeable("sambaDomainName",$SkipWrite) && $this->samba3 && isset ($_POST['sambaDomainName'],$SkipWrite)){
1145 $this->sambaDomainName= validate($_POST['sambaDomainName']);
1146 }
1148 /* Save CTX values */
1149 if ($this->samba3){
1151 /* Save obvious values */
1152 foreach($this->ctxattributes as $val){
1153 if (isset($_POST[$val]) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){
1154 if (get_magic_quotes_gpc()) {
1155 $this->mungedObject->ctx[$val]= stripcslashes(validate($_POST[$val]));
1156 } else {
1157 $this->mungedObject->ctx[$val]= validate($_POST[$val]);
1158 }
1159 }
1160 }
1162 /* Save checkbox states. */
1163 $this->mungedObject->setTsLogin(!isset($_POST['tslogin'])
1164 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1165 // Need to do some index checking to avoid messages like "index ... not found"
1166 if(isset($_POST['brokenconn'])) {
1167 $this->mungedObject->setBrokenConn($_POST['brokenconn'] == '1'
1168 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1169 }
1170 if(isset($_POST['reconn'])) {
1171 $this->mungedObject->setReConn($_POST['reconn'] == '1'
1172 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1173 }
1174 $this->mungedObject->setInheritMode(isset($_POST['inherit'])
1175 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1176 $this->mungedObject->setCtxMaxConnectionTimeF(!isset($_POST['CtxMaxConnectionTimeF'])
1177 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1178 $this->mungedObject->setCtxMaxDisconnectionTimeF(
1179 !isset($_POST['CtxMaxDisconnectionTimeF'])
1180 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1181 $this->mungedObject->setCtxMaxIdleTimeF(!isset($_POST['CtxMaxIdleTimeF'])
1182 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1183 $this->mungedObject->setConnectClientDrives(isset($_POST['connectclientdrives'])
1184 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1185 $this->mungedObject->setConnectClientPrinters(isset($_POST['connectclientprinters'])
1186 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1187 $this->mungedObject->setDefaultPrinter(isset($_POST['defaultprinter'])
1188 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1190 /* Save combo boxes. Takes two values */
1191 if(isset($_POST['reconn'])) {
1192 $this->mungedObject->setShadow(isset($_POST['shadow']) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite),$_POST['shadow']);
1193 }
1195 /* Check for changes */
1196 if ($this->sambaMungedDial != $this->mungedObject->getMunged()){
1197 $this->is_modified= TRUE;
1198 }
1199 }
1200 }
1201 }
1204 /* Save to LDAP */
1205 function save()
1206 {
1207 /* Load uid and gid of this 'dn' */
1208 $ldap= $this->config->get_ldap_link();
1209 $ldap->cat($this->dn, array('uidNumber', 'gidNumber'));
1210 $tmp= $ldap->fetch();
1211 $this->uidNumber= $tmp['uidNumber'][0];
1212 $this->gidNumber= $tmp['gidNumber'][0];
1214 plugin::save();
1216 /* Remove objectClass for sambaIdmapEntry */
1217 $tmp= array();
1218 for ($i= 0; $i<count($this->attrs["objectClass"]); $i++){
1219 if ($this->attrs['objectClass'][$i] != 'sambaIdmapEntry'){
1220 $tmp[]= $this->attrs['objectClass'][$i];
1221 }
1222 }
1223 $this->attrs['objectClass']= $tmp;
1225 /* Generate rid / primaryGroupId */
1226 if ($this->samba3){
1227 if (!isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'])){
1228 msg_dialog::display(_("Warning"), _("Undefined Samba SID detected. Please fix this problem manually!"), WARNING_DIALOG);
1229 } else {
1230 $this->SID= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'];
1231 $this->ridBase= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE'];
1232 }
1234 /* Need to generate a new uniqe uid/gid combination? */
1235 if ($this->sambaSID == "" || $this->orig_sambaDomainName != $this->sambaDomainName){
1236 $uidNumber= $this->uidNumber;
1237 while(TRUE){
1238 $sid= $this->SID."-".($uidNumber*2 + $this->ridBase);
1239 $ldap->cd($this->config->current['BASE']);
1240 $ldap->search("(sambaSID=$sid)", array("sambaSID"));
1241 if ($ldap->count() == 0){
1242 break;
1243 }
1244 $uidNumber++;
1245 }
1246 $this->attrs['sambaSID']= $sid;
1248 /* Check for users primary group */
1249 $ldap->cd($this->config->current['BASE']);
1250 $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn"));
1251 if ($ldap->count() != 1){
1252 msg_dialog::display(_("Warning"), _("Cannot convert primary group to samba group: group cannot be identified!"), WARNING_DIALOG);
1253 } else {
1254 $attrs= $ldap->fetch();
1255 $g= new group($this->config, $ldap->getDN());
1256 if ($g->sambaSID == ""){
1257 $g->sambaDomainName= $this->sambaDomainName;
1258 $g->smbgroup= TRUE;
1259 $g->save ();
1260 }
1261 $this->attrs['sambaPrimaryGroupSID']= $g->sambaSID;
1262 }
1263 }
1265 if ($this->sambaHomeDrive == ""){
1266 $this->attrs["sambaHomeDrive"]= array();
1267 }
1269 /* Generate munged dial value */
1270 $this->attrs["sambaMungedDial"]= $this->mungedObject->getMunged();
1272 /* User wants me to fake the idMappings? This is useful for
1273 making winbind resolve the user names in a reasonable amount
1274 of time in combination with larger databases. */
1275 if ($this->config->get_cfg_value("sambaidmapping") == "true"){
1276 $this->attrs['objectClass'][]= "sambaIdmapEntry";
1277 }
1280 /* Password expiery */
1281 if ($this->password_expires == "1"){
1282 #TODO: check for date format
1283 if ($this->attrs['sambaPwdMustChange'] == ""){
1284 $this->attrs['sambaPwdMustChange']= 0;
1285 } else {
1286 list($day, $month, $year)= split('\.', $this->sambaPwdMustChange);
1287 $this->attrs['sambaPwdMustChange']= mktime(0,0,0,$month, $day, $year);
1288 }
1289 } else {
1290 $this->attrs['sambaPwdMustChange']= array();
1291 }
1292 /* Make sure not to save zero in sambaPwdLastset */
1293 if ($this->sambaPwdLastSet != "0"){
1294 $this->attrs['sambaPwdLastSet']= $this->sambaPwdLastSet;
1295 } else {
1296 $this->attrs['sambaPwdLastSet']= array();
1297 }
1298 /* Account expiery */
1299 if ($this->logon_time_set == "1"){
1300 $this->attrs['sambaLogonTime']= $this->sambaLogonTime;
1301 } else {
1302 $this->attrs['sambaLogonTime']= array();
1303 }
1304 if ($this->logoff_time_set == "1"){
1305 $this->attrs['sambaLogoffTime']= $this->sambaLogoffTime;
1306 } else {
1307 $this->attrs['sambaLogoffTime']= array();
1308 }
1309 if ($this->kickoff_time_set == "1"){
1310 /* Adapt values to be timestamps */
1311 #TODO: check for date format
1312 if ($this->attrs['sambaKickoffTime'] == ""){
1313 $this->attrs['sambaKickoffTime']= 2147483647;
1314 } else {
1315 list($day, $month, $year)= split('\.', $this->sambaKickoffTime);
1316 $this->attrs['sambaKickoffTime']= mktime(0,0,0,$month, $day, $year);
1317 }
1318 } else {
1319 $this->attrs['sambaKickoffTime']= array();
1320 }
1321 } else {
1322 /* Not samba3 */
1323 $this->attrs['rid']= $this->uidNumber*2 + 1000;
1324 $this->attrs['primaryGroupID']= $this->gidNumber*2 +1001;
1326 if ($this->homeDrive == ""){
1327 $this->attrs["homeDrive"]= array();
1328 }
1330 /* Password expiery */
1331 if ($this->password_expires == "1"){
1332 $this->attrs['pwdMustChange']= $this->pwdMustChange;
1333 } else {
1334 $this->attrs['pwdMustChange']= 2147483647;
1335 }
1336 /* Make sure not to save zero in pwdLastset */
1337 if ($this->pwdLastSet != "0"){
1338 $this->attrs['pwdLastSet']= $this->pwdLastSet;
1339 } else {
1340 $this->attrs['pwdLastSet']= array();
1341 }
1342 /* Account expiery */
1343 if ($this->logon_time_set == "1"){
1344 $this->attrs['logonTime']= $this->logonTime;
1345 } else {
1346 $this->attrs['logonTime']= array();
1347 }
1348 if ($this->logoff_time_set == "1"){
1349 $this->attrs['logoffTime']= $this->logoffTime;
1350 } else {
1351 $this->attrs['logoffTime']= array();
1352 }
1353 if ($this->kickoff_time_set == "1"){
1354 # Add one day in unixtime format to be compatible with usrmgr
1355 $this->attrs['kickoffTime']= $this->kickoffTime + 86400;
1356 } else {
1357 $this->attrs['kickoffTime']= array();
1358 }
1359 }
1361 /* Write back to ldap */
1362 $ldap->cd($this->dn);
1363 $this->cleanup();
1364 $ldap->modify ($this->attrs);
1366 if($this->initially_was_account){
1367 new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1368 }else{
1369 new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1370 }
1372 if (!$ldap->success()){
1373 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
1374 }
1376 /* Optionally execute a command after we're done */
1377 if ($this->initially_was_account == $this->is_account){
1378 if ($this->is_modified){
1379 $this->handle_post_events("modify", array("uid" => $this->uid));
1380 }
1381 } else {
1382 $this->handle_post_events("add", array("uid" => $this->uid));
1383 }
1384 }
1387 /* Force password set, if this account doesn't have any samba passwords */
1388 function password_change_needed()
1389 {
1390 if(!$this->initially_was_account && $this->is_account){
1391 $ldap = $this->config->get_ldap_link();
1392 $ldap->cat($this->dn,array("sambaLMPassword","sambaNTPassword"));
1393 $attrs = $ldap->fetch();
1394 if(!isset($attrs['sambaLMPassword']) || !isset($attrs['sambaNTPassword'])){
1395 return(TRUE);
1396 }
1397 }
1398 return(FALSE);
1399 }
1402 function adapt_from_template($dn, $skip= array())
1403 {
1404 plugin::adapt_from_template($dn, $skip);
1407 $this->sambaSID= "";
1408 $this->sambaPrimaryGroupSID= "";
1410 /* Fill mungedDial field */
1411 if ($this->samba3 && isset($this->attrs['sambaMungedDial']) && !in_array('sambaMungedDial', $skip)){
1412 $this->mungedObject->load($this->sambaMungedDial);
1413 }
1415 /* Adapt munged attributes */
1416 foreach($this->ctxattributes as $attr){
1417 if(isset($this->mungedObject->ctx[$attr]))
1418 $val = $this->mungedObject->ctx[$attr];
1420 foreach (array("sn", "givenName", "uid") as $repl){
1421 if (preg_match("/%$repl/i", $val)){
1422 $val= preg_replace ("/%$repl/i", $this->parent->$repl, $val);
1423 }
1424 }
1425 $this->mungedObject->ctx[$attr] = $val;
1426 }
1428 /* Password expiery */
1429 if(isset($this->attrs['sambaPwdMustChange']) &&
1430 $this->attrs['sambaPwdMustChange'][0] != 0 && !in_array('sambaPwdMustChange', $skip)){
1431 $this->password_expires= 1;
1432 }
1434 if(isset($this->attrs['sambaLogonTime']) && ! (
1435 $this->attrs['sambaLogonTime'][0] == 0 ||
1436 $this->attrs['sambaLogonTime'][0] == 2147483647
1437 ) && !in_array('sambaLogonTime', $skip)){
1438 $this->logon_time_set= 1;
1439 }
1440 if(isset($this->attrs['sambaLogoffTime']) && ! (
1441 $this->attrs['sambaLogoffTime'][0] == 0 ||
1442 $this->attrs['sambaLogoffTime'][0] == 2147483647
1443 ) && !in_array('sambaLogonTime', $skip)){
1444 $this->logoff_time_set= 1;
1445 }
1447 /* Account expiery */
1448 if(isset($this->attrs['sambaKickoffTime']) && ! (
1449 $this->attrs['sambaKickoffTime'][0] == 0 ||
1450 $this->attrs['sambaKickoffTime'][0] == 2147483647
1451 ) && !in_array('sambaKickoffTime', $skip)){
1452 $this->kickoff_time_set= 1;
1453 }
1455 /* Get global filter config */
1456 if (!session::is_set("sambafilter")){
1457 $ui= get_userinfo();
1458 $base= get_base_from_people($ui->dn);
1459 $sambafilter= array( "depselect" => $base, "regex" => "*");
1460 session::set("sambafilter", $sambafilter);
1461 }
1462 }
1465 static function plInfo()
1466 {
1467 return (array(
1468 "plShortName" => _("Samba"),
1469 "plDescription" => _("Samba settings"),
1470 "plSelfModify" => TRUE,
1471 "plDepends" => array("user"),
1472 "plPriority" => 5,
1473 "plSection" => array("personal" => _("My account")),
1474 "plCategory" => array("users"),
1475 "plOptions" => array(),
1477 "plProvidedAcls" => array(
1479 "sambaHomePath" => _("Generic home directory") ,
1480 "sambaHomeDrive" => _("Generic samba home drive") ,
1481 "sambaDomainName" => _("Domain") ,
1482 "sambaLogonScript" => _("Generic script path") ,
1483 "sambaProfilePath" => _("Generic profile path") ,
1484 "AllowLoginOnTerminalServer" => _("Allow login on terminal server"),
1485 "InheritClientConfig" => _("Inherit client config"),
1486 "sambaPwdCanChange" => _("Allow user to change password") ,
1487 "sambaAcctFlagsN" => _("Login from windows client requires no password"),
1488 "sambaAcctFlagsX" => _("Password never expires"),
1489 "sambaAcctFlagsL" => _("Lock samba account"),
1490 "sambaKickoffTime" => _("Account expires") ,
1491 "sambaPwdMustChange" => _("Password expires") ,
1492 "sambaLogonTime" => _("Limit Logon Time") ,
1493 "sambaLogoffTime" => _("Limit Logoff Time") ,
1494 "sambaLogonHours" => _("Logon hours") ,
1495 "sambaUserWorkstations" => _("Allow connection from"))
1496 ));
1497 }
1499 function enable_multiple_support()
1500 {
1501 plugin::enable_multiple_support();
1502 if($this->samba3){
1503 $this->multiple_support_active = TRUE;
1504 }else{
1505 $this->multiple_support_active = FALSE;
1506 }
1507 }
1509 function multiple_save_object()
1510 {
1511 if (isset($_POST['sambaTab'])){
1512 $this->save_object();
1513 plugin::multiple_save_object();
1514 foreach(array("allow_pwchange","tslogin","CtxWFHomeDir","CtxWFHomeDirDrive","CtxWFProfilePath",
1515 "inherit","CtxWorkDirectory","CtxInitialProgram","CtxMaxConnectionTimeF","CtxMaxConnectionTime","CtxMaxDisconnectionTimeF",
1516 "CtxMaxDisconnectionTime","CtxMaxIdleTimeF","CtxMaxIdleTime","connectclientdrives",
1517 "onnectclientprinters","defaultprinter","shadow","brokenconn",
1518 "reconn","allow_pwchange","connectclientprinters","no_expiry","no_password_required","temporary_disable",
1519 "password_expires","logon_time_set","logoff_time_set","kickoff_time_set","SetSambaLogonHours",
1520 "workstation_list") as $attr){
1521 if(isset($_POST["use_".$attr])){
1522 $this->multi_boxes[] = $attr;
1523 }
1524 }
1525 }
1526 }
1529 function multiple_check()
1530 {
1531 $message = plugin::multiple_check();
1533 /* Strings */
1534 foreach (array( "sambaHomePath" => _("Home directory"),
1535 "sambaProfilePath" => _("Profile path")) as $key => $val){
1536 if (in_array($key,$this->multi_boxes) && !$this->mungedObject->is_samba_path($this->$key)){
1537 $message[]= msgPool::invalid($val);
1538 }
1539 }
1541 /* Numeric values */
1542 foreach (array( "CtxMaxConnectionTime" => _("Connection"),
1543 "CtxMaxDisconnectionTime" => _("Disconnection"),
1544 "CtxMaxIdleTime" => _("IDLE")) as $key => $val){
1545 if (in_array($key,$this->multi_boxes) &&
1546 isset($this->mungedObject->ctx[$key]) &&
1547 !tests::is_id($this->mungedObject->ctx[$key]) && $val != 0){
1548 $message[]=msgPool::invalid($val);
1549 }
1550 }
1552 /* Too many workstations? Windows usrmgr only supports eight */
1553 if (substr_count($this->sambaUserWorkstations, ",") >= 8){
1554 $message[]= _("The windows user manager only allows eight clients. You've specified more than eight.");
1555 }
1556 return($message);
1557 }
1560 function get_multi_init_values()
1561 {
1562 $ret = plugin::get_multi_init_values();
1564 /* Parse given sambaUserWorkstations into array
1565 * to allow "init_multiple_support()" to detect multiple used workstations.
1566 * Those workstations will be displayed in light grey.
1567 */
1568 $tmp2 = array("count" => 0);
1569 $tmp = split(",", $this->sambaUserWorkstations);
1570 foreach($tmp as $station){
1571 $station = trim($station);
1572 if(!empty($station)){
1573 $tmp2[] = $station;
1574 $tmp2['count'] ++;
1575 }
1576 }
1577 $ret['sambaUserWorkstations'] = $tmp2;
1578 return($ret);
1579 }
1583 function init_multiple_support($attrs,$all)
1584 {
1585 plugin::init_multiple_support($attrs,$all);
1587 $this->multiple_sambaUserWorkstations = array();
1588 if(isset($all['sambaUserWorkstations'])){
1589 for($i = 0 ; $i < $all['sambaUserWorkstations']['count'] ; $i++){
1590 $station = trim($all['sambaUserWorkstations'][$i]);
1591 $this->multiple_sambaUserWorkstations[$station] = array("Name" => $station, "UsedByAllUsers" => FALSE);
1592 }
1593 }
1594 if(isset($attrs['sambaUserWorkstations'])){
1595 for($i = 0 ; $i < $attrs['sambaUserWorkstations']['count'] ; $i++){
1596 $station = trim($attrs['sambaUserWorkstations'][$i]);
1597 $this->multiple_sambaUserWorkstations[$station] = array("Name" => $station, "UsedByAllUsers" => TRUE);
1598 }
1599 }
1600 }
1602 function multiple_execute()
1603 {
1604 return($this->execute());
1605 }
1607 function get_multi_edit_values()
1608 {
1609 $ret = plugin::get_multi_edit_values();
1611 /* Terminal Server */
1612 if(in_array("tslogin",$this->multi_boxes)){
1613 $ret['tslogin'] = $this->mungedObject->getTsLogin();
1614 }
1615 if(in_array("CtxWFHomeDirDrive",$this->multi_boxes)){
1616 $ret['CtxWFHomeDirDrive'] = $this->mungedObject->ctx['CtxWFHomeDirDrive'];
1617 }
1618 if(in_array("CtxWFHomeDir",$this->multi_boxes)){
1619 $ret['CtxWFHomeDir'] = $this->mungedObject->ctx['CtxWFHomeDir'];
1620 }
1621 if(in_array("CtxWFProfilePath",$this->multi_boxes)){
1622 $ret['CtxWFProfilePath'] = $this->mungedObject->ctx['CtxWFProfilePath'];
1623 }
1625 if(in_array("inherit",$this->multi_boxes)){
1626 $ret['inherit'] = $this->mungedObject->getInheritMode();
1627 }
1628 if(in_array("CtxInitialProgram",$this->multi_boxes)){
1629 $ret['CtxInitialProgram'] = $this->mungedObject->ctx['CtxInitialProgram'];
1630 }
1631 if(in_array("CtxWorkDirectory",$this->multi_boxes)){
1632 $ret['CtxWorkDirectory'] = $this->mungedObject->ctx['CtxWorkDirectory'];
1633 }
1635 /* Time Limits. Be careful here, there are some negations */
1636 if(in_array("CtxMaxConnectionTimeF",$this->multi_boxes)){
1637 $ret["CtxMaxConnectionTimeF"] = !$this->mungedObject->getCtxMaxConnectionTimeF();
1638 if(!$ret["CtxMaxConnectionTimeF"]){
1639 $ret["CtxMaxConnectionTime"] = $this->mungedObject->ctx['CtxMaxConnectionTime'];
1640 }
1641 }
1642 if(in_array("CtxMaxDisconnectionTimeF",$this->multi_boxes)){
1643 $ret["CtxMaxDisconnectionTimeF"]= !$this->mungedObject->getCtxMaxDisconnectionTimeF();
1644 if(!$ret["CtxMaxDisconnectionTimeF"]){
1645 $ret["CtxMaxDisconnectionTime"]= $this->mungedObject->ctx['CtxMaxDisconnectionTime'];
1646 }
1647 }
1648 if(in_array("CtxMaxIdleTimeF",$this->multi_boxes)){
1649 $ret["CtxMaxIdleTimeF"] = !$this->mungedObject->getCtxMaxIdleTimeF();
1650 if(!$ret["CtxMaxIdleTimeF"]){
1651 $ret["CtxMaxIdleTime"] = $this->mungedObject->ctx['CtxMaxIdleTime'];
1652 }
1653 }
1655 /* Client Devices */
1656 if(in_array("connectclientdrives",$this->multi_boxes)){
1657 $ret["connectclientdrives"] = $this->mungedObject->getConnectClientDrives();
1658 }
1659 if(in_array("connectclientprinters",$this->multi_boxes)){
1660 $ret["connectclientprinters"] = $this->mungedObject->getConnectClientPrinters();
1661 }
1662 if(in_array("defaultprinter",$this->multi_boxes)){
1663 $ret["defaultprinter"] = $this->mungedObject->getDefaultPrinter();
1664 }
1666 /* Misc */
1667 if(in_array("shadow",$this->multi_boxes)){
1668 $ret["shadow"] =$this->mungedObject->getShadow();
1669 }
1670 if(in_array("brokenconn",$this->multi_boxes)){
1671 $ret["brokenconn"]=$this->mungedObject->getBrokenConn();
1672 }
1673 if(in_array("reconn",$this->multi_boxes)){
1674 $ret["reconn"] =$this->mungedObject->getReConn();
1675 }
1677 /* Flags */
1678 if(in_array("allow_pwchange",$this->multi_boxes)){
1679 $ret['sambaPwdCanChange'] = $this->sambaPwdCanChange;
1680 $ret['pwdCanChange'] = $this->pwdCanChange;
1681 }
1683 if(in_array("password_expires",$this->multi_boxes)){
1684 $ret['password_expires'] = $this->password_expires;
1685 $ret['sambaPwdMustChange']= $this->sambaPwdMustChange;
1686 }
1687 if(in_array("logon_time_set",$this->multi_boxes)){
1688 $ret['logon_time_set'] = $this->logon_time_set;
1689 $ret['sambaLogonTime'] = $this->sambaLogonTime;
1690 }
1691 if(in_array("logoff_time_set",$this->multi_boxes)){
1692 $ret['logoff_time_set'] = $this->logoff_time_set;
1693 $ret['sambaLogoffTime'] = $this->sambaLogoffTime;
1694 }
1695 if(in_array("kickoff_time_set",$this->multi_boxes)){
1696 $ret['kickoff_time_set'] = $this->kickoff_time_set;
1697 $ret['sambaKickoffTime'] = $this->sambaKickoffTime;
1698 }
1700 if(in_array("no_password_required",$this->multi_boxes)){
1701 $ret['no_password_required'] = $this->no_password_required;
1702 }
1704 if(in_array("no_expiry",$this->multi_boxes)){
1705 $ret['no_expiry'] = $this->no_expiry;
1706 }
1708 if(in_array("temporary_disable",$this->multi_boxes)){
1709 $ret['temporary_disable'] = $this->temporary_disable;
1710 }
1712 if(in_array("SetSambaLogonHours",$this->multi_boxes)){
1713 $ret['sambaLogonHours'] = $this->sambaLogonHours;
1714 }
1716 if(in_array("workstation_list",$this->multi_boxes)){
1717 $ret['multiple_sambaUserWorkstations'] = $this->multiple_sambaUserWorkstations;
1718 }
1719 return($ret);
1720 }
1722 function set_multi_edit_values($values)
1723 {
1724 plugin::set_multi_edit_values($values);
1726 /* Prepare current workstation settings to be merged
1727 * with multiple edit settings.
1728 */
1729 if(isset($values['multiple_sambaUserWorkstations'])){
1730 $cur_ws = array();
1731 $m_ws = $values['multiple_sambaUserWorkstations'];
1733 /* Prepare current settings to be merged */
1734 if(isset($this->sambaUserWorkstations)){
1735 $ttmp = split(",",$this->sambaUserWorkstations);
1736 foreach($ttmp as $station){
1737 $station = trim($station);
1738 if(!empty($station)){
1739 $cur_ws[$station] = array("Name" => $station, "UsedByAllUsers" => TRUE);
1740 }
1741 }
1742 }
1744 /* Unset removed workstations */
1745 foreach($cur_ws as $cur_name => $cur_station){
1746 if(!isset($m_ws[$cur_name])){
1747 unset($cur_ws[$cur_name]);
1748 }
1749 }
1751 /* Add all added workstations */
1752 foreach($m_ws as $name => $station){
1753 if($station['UsedByAllUsers']){
1754 $cur_ws[$name] = $station;
1755 }
1756 }
1758 $this->sambaUserWorkstations = "";
1759 foreach($cur_ws as $name => $ws){
1760 $this->sambaUserWorkstations .= $name.",";
1761 }
1762 $this->sambaUserWorkstations=preg_replace("/,$/","",$this->sambaUserWorkstations);
1763 }
1765 /* Enable disabled terminal login, this is inverted somehow */
1766 if(isset($values['tslogin'])) $this->mungedObject->setTsLogin(!$values['tslogin']);
1768 /* Imherit client configuration */
1769 if(isset($values['inherit'])) $this->mungedObject->setInheritMode($values['inherit']);
1771 /* Get all ctx values posted */
1772 $ctx = array("CtxWFHomeDirDrive","CtxWFHomeDir","CtxWFProfilePath","CtxInitialProgram","CtxWorkDirectory",
1773 "CtxMaxConnectionTime","CtxMaxDisconnectionTime","CtxMaxIdleTime");
1774 foreach($ctx as $attr){
1775 if(isset($values[$attr])){
1776 $this->mungedObject->ctx[$attr] = $values[$attr] ;
1777 }
1778 }
1780 if(isset($values['CtxMaxConnectionTimeF'])) $this->mungedObject->setCtxMaxConnectionTimeF($values['CtxMaxConnectionTimeF']);
1781 if(isset($values['CtxMaxDisconnectionTimeF']))$this->mungedObject->setCtxMaxDisconnectionTimeF($values['CtxMaxDisconnectionTimeF']);
1782 if(isset($values['CtxMaxIdleTimeF'])) $this->mungedObject->setCtxMaxIdleTimeF($values['CtxMaxIdleTimeF']);
1784 if(isset($values['connectclientdrives'])) $this->mungedObject->setConnectClientDrives($values['connectclientdrives']);
1785 if(isset($values['connectclientprinters'])) $this->mungedObject->setConnectClientPrinters($values['connectclientprinters']);
1786 if(isset($values['defaultprinter'])) $this->mungedObject->setDefaultPrinter($values['defaultprinter']);
1788 if(isset($values['shadow'])) $this->mungedObject->setShadow($values['shadow'],$values['shadow']);
1789 if(isset($values['brokenconn'])) $this->mungedObject->setBrokenConn($values['brokenconn'],$values['brokenconn']);
1790 if(isset($values['reconn'])) $this->mungedObject->setReConn($values['reconn'],$values['reconn']);
1793 if(isset($values['sambaPwdCanChange'])) $this->sambaPwdCanChange = $values['sambaPwdCanChange'];
1794 if(isset($values['pwdCanChange'])) $this->pwdCanChange = $values['pwdCanChange'];
1799 if(isset($values['password_expires'])){
1800 $this->password_expires = $values['password_expires'];
1801 $this->sambaPwdMustChange = $values['sambaPwdMustChange'];
1802 }
1803 if(isset($values['logon_time_set'])){
1804 $this->logon_time_set = $values['logon_time_set'];
1805 $this->sambaLogonTime = $values['sambaLogonTime'];
1806 }
1807 if(isset($values['logoff_time_set'])){
1808 $this->logoff_time_set = $values['logoff_time_set'];
1809 $this->sambaLogoffTime = $values['sambaLogoffTime'];
1810 }
1811 if(isset($values['kickoff_time_set'])){
1812 $this->kickoff_time_set = $values['kickoff_time_set'];
1813 $this->sambaKickoffTime = $values['sambaKickoffTime'];
1814 }
1816 if(isset($values['no_password_required'])){
1817 if($values['no_password_required']){
1818 if(!preg_match("/N/",$this->sambaAcctFlags)) {
1819 $this->sambaAcctFlags = preg_replace("/ /","N",$this->sambaAcctFlags,1);
1820 }
1821 }else{
1822 $this->sambaAcctFlags = preg_replace("/N/"," ",$this->sambaAcctFlags,1);
1823 }
1824 }
1826 if(isset($values['no_expiry'])){
1827 if($values['no_expiry']){
1828 if(!preg_match("/N/",$this->sambaAcctFlags)) {
1829 $this->sambaAcctFlags = preg_replace("/ /","N",$this->sambaAcctFlags,1);
1830 }
1831 }else{
1832 $this->sambaAcctFlags = preg_replace("/N/"," ",$this->sambaAcctFlags,1);
1833 }
1834 }
1836 if(isset($values['temporary_disable'])){
1837 if($values['temporary_disable']){
1838 if(preg_match("/L/",$this->sambaAcctFlags)) {
1839 // Keep L
1840 }else{
1841 $this->sambaAcctFlags = preg_replace("/ /","D",$this->sambaAcctFlags,1);
1842 }
1843 }else{
1844 $this->sambaAcctFlags = preg_replace("/D/"," ",$this->sambaAcctFlags,1);
1845 }
1846 }
1847 }
1850 function PrepareForCopyPaste($source)
1851 {
1852 plugin::PrepareForCopyPaste($source);
1854 /* Set a new SID */
1855 $this->sambaSID = "";
1856 }
1858 }
1860 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1861 ?>