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