a7928ba6a1c2c4b894e480c523b11b30d6fcd841
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", "sambaSID");
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 if (is_numeric($sambaPwdMustChange)) {
729 $sambaPwdMustChange= date('d.m.Y', $sambaPwdMustChange);
730 }
731 }
732 if($this->kickoff_time_set){
733 $sambaKickoffTime = $this->sambaKickoffTime;
734 } else {
735 if (is_numeric($sambaKickoffTime)) {
736 $sambaKickoffTime= date('d.m.Y', $sambaKickoffTime);
737 }
738 }
739 $sambaPwdCanChange = $this->sambaPwdCanChange;
742 /* DOMAIN Attributes
743 */
745 /* sambaMinPwdLength: Password length has a default of 5
746 */
747 if($sambaMinPwdLength == "unset" || $sambaMinPwdLength == 5){
748 $sambaMinPwdLength = "5 <i>("._("default").")</i>";
749 }
751 /* sambaPwdHistoryLength: Length of Password History Entries (default: 0 => off)
752 */
753 if($sambaPwdHistoryLength == "unset" || $sambaPwdHistoryLength == 0){
754 $sambaPwdHistoryLength = _("Off")." <i>("._("default").")</i>";
755 }
757 /* sambaLogonToChgPwd: Force Users to logon for password change (default: 0 => off, 2 => on)
758 */
759 if($sambaLogonToChgPwd == "unset" || $sambaLogonToChgPwd == 0){
760 $sambaLogonToChgPwd = _("Off")." <i>("._("default").")</i>";
761 }else{
762 $sambaLogonToChgPwd = _("On");
763 }
765 /* sambaMaxPwdAge: Maximum password age, in seconds (default: -1 => never expire passwords)'
766 */
767 if($sambaMaxPwdAge == "unset" || $sambaMaxPwdAge == "-1"){
768 $sambaMaxPwdAge = _("disabled")." <i>("._("default").")</i>";
769 }else{
770 $sambaMaxPwdAge .= " "._("seconds");
771 }
773 /* sambaMinPwdAge: Minimum password age, in seconds (default: 0 => allow immediate password change
774 */
775 if($sambaMinPwdAge == "unset" || $sambaMinPwdAge == 0){
776 $sambaMinPwdAge = _("disabled")." <i>("._("default").")</i>";
777 }else{
778 $sambaMinPwdAge .= " "._("seconds");
779 }
781 /* sambaLockoutDuration: Lockout duration in minutes (default: 30, -1 => forever)
782 */
783 if($sambaLockoutDuration == "unset" || $sambaLockoutDuration == 30){
784 $sambaLockoutDuration = "30 "._("minutes")." <i>("._("default").")</i>";
785 }elseif($sambaLockoutDuration == -1){
786 $sambaLockoutDuration = _("forever");
787 }else{
788 $sambaLockoutDuration .= " "._("minutes");
789 }
791 /* sambaLockoutThreshold: Lockout users after bad logon attempts (default: 0 => off
792 */
793 if($sambaLockoutThreshold == "unset" || $sambaLockoutThreshold == 0){
794 $sambaLockoutThreshold = _("disabled")." <i>("._("default").")</i>";
795 }
797 /* sambaForceLogoff: Disconnect Users outside logon hours (default: -1 => off, 0 => on
798 */
799 if($sambaForceLogoff == "unset" || $sambaForceLogoff == -1){
800 $sambaForceLogoff = _("off")." <i>("._("default").")</i>";
801 }else{
802 $sambaForceLogoff = _("on");
803 }
805 /* sambaRefuseMachinePwdChange: Allow Machine Password changes (default: 0 => off
806 */
807 if($sambaRefuseMachinePwdChange == "none" || $sambaRefuseMachinePwdChange == 0){
808 $sambaRefuseMachinePwdChange = _("off")." <i>("._("default").")</i>";
809 }else{
810 $sambaRefuseMachinePwdChange = _("on");
811 }
813 /* USER Attributes
814 */
815 /* sambaBadPasswordTime: Time of the last bad password attempt
816 */
817 if($sambaBadPasswordTime == "unset" || empty($sambaBadPasswordTime)){
818 $sambaBadPasswordTime = "<i>("._("unset").")</i>";
819 }else{
820 $sambaBadPasswordTime = date("d.m.Y H:i:s",$sambaBadPasswordTime);
821 }
823 /* sambaBadPasswordCount: Bad password attempt count
824 */
825 if($sambaBadPasswordCount == "unset" || empty($sambaBadPasswordCount)){
826 $sambaBadPasswordCount = "<i>("._("unset").")</i>";
827 }else{
828 $sambaBadPasswordCount = date("d.m.Y H:i:s",$sambaBadPasswordCount);
829 }
831 /* sambaPwdLastSet: Timestamp of the last password update
832 */
833 if($sambaPwdLastSet == "unset" || empty($sambaPwdLastSet)){
834 $sambaPwdLastSet = "<i>("._("unset").")</i>";
835 }else{
836 $sambaPwdLastSet = date("d.m.Y H:i:s",$sambaPwdLastSet);
837 }
839 /* sambaLogonTime: Timestamp of last logon
840 */
841 if($sambaLogonTime == "unset" || empty($sambaLogonTime)){
842 $sambaLogonTime = "<i>("._("unset").")</i>";
843 }else{
844 $sambaLogonTime = date("d.m.Y H:i:s",$sambaLogonTime);
845 }
847 /* sambaLogoffTime: Timestamp of last logoff
848 */
849 if($sambaLogoffTime == "unset" || empty($sambaLogoffTime)){
850 $sambaLogoffTime = "<i>("._("unset").")</i>";
851 }else{
852 $sambaLogoffTime = date("d.m.Y H:i:s",$sambaLogoffTime);
853 }
855 /* sambaKickoffTime: Timestamp of when the user will be logged off automatically
856 */
857 if($sambaKickoffTime == "unset" || empty($sambaKickoffTime)){
858 $sambaKickoffTime = "<i>("._("unset").")</i>";
859 }
861 /* sambaPwdMustChange: Timestamp of when the password will expire
862 */
863 if($sambaPwdMustChange == "unset" || empty($sambaPwdMustChange)){
864 $sambaPwdMustChange = "<i>("._("unset").")</i>";
865 }
867 /* sambaPwdCanChange: Timestamp of when the user is allowed to update the password
868 */
869 if($sambaPwdCanChange == "unset" || empty($sambaPwdCanChange)){
870 $sambaPwdCanChange = "<i>("._("unset").")</i>";
871 }elseif($sambaPwdCanChange != "unset" && time() > $sambaPwdCanChange){
872 $sambaPwdCanChange = _("immediately") ;
873 }else{
874 $days = floor((($sambaPwdCanChange - time()) / 60 / 60 / 24)) ;
875 $hours = floor((($sambaPwdCanChange - time()) / 60 / 60) % 24) ;
876 $minutes = floor((($sambaPwdCanChange - time()) / 60 ) % 60) ;
878 $sambaPwdCanChange = " ".$days." "._("days");
879 $sambaPwdCanChange.= " ".$hours." "._("hours");
880 $sambaPwdCanChange.= " ".$minutes." "._("minutes");
881 }
883 $str =
884 "\n<div style='height:200px; overflow: auto;'>".
885 "\n<table style='width:100%;'>".
886 "\n<tr><td><b>"._("Domain attributes")."</b></td></tr>".
887 "\n<tr><td>"._("Min password length").": </td><td>".$sambaMinPwdLength."</td></tr>".
888 "\n<tr><td>"._("Min password length").": </td><td>".$sambaMinPwdLength."</td></tr>".
889 "\n<tr><td>"._("Password history").": </td><td>".$sambaPwdHistoryLength."</td></tr>".
890 "\n<tr><td>"._("Force password change").": </td><td>".$sambaLogonToChgPwd."</td></tr>".
891 "\n<tr><td>"._("Maximum password age").": </td><td>".$sambaMaxPwdAge."</td></tr>".
892 "\n<tr><td>"._("Minimum password age").": </td><td>".$sambaMinPwdAge."</td></tr>".
893 "\n<tr><td>"._("Lockout duration").": </td><td>".$sambaLockoutDuration."</td></tr>".
894 "\n<tr><td>"._("Bad lockout attempt").": </td><td>".$sambaLockoutThreshold."</td></tr>".
895 "\n<tr><td>"._("Disconnect time").": </td><td>".$sambaForceLogoff."</td></tr>".
896 "\n<tr><td>"._("Refuse machine password change").":</td><td>".$sambaRefuseMachinePwdChange."</td></tr>".
897 "\n<tr><td> </td></tr>".
898 "\n<tr><td><b>"._("User attributes")."</b></td></tr>".
899 "\n<tr><td>"._("SID").": </td><td>".$sambaSID."</td></tr>".
900 "\n<tr><td>"._("Last failed login").": </td><td>".$sambaBadPasswordTime."</td></tr>".
901 "\n<tr><td>"._("Logon attempts").": </td><td>".$sambaBadPasswordCount."</td></tr>".
902 "\n<tr><td>"._("Last password update").": </td><td>".$sambaPwdLastSet."</td></tr>".
903 "\n<tr><td>"._("Last logon").": </td><td>".$sambaLogonTime."</td></tr>".
904 "\n<tr><td>"._("Last logoff").": </td><td>".$sambaLogoffTime."</td></tr>".
905 "\n<tr><td>"._("Automatic logoff").": </td><td>".$sambaKickoffTime."</td></tr>";
907 if($this->no_expiry){
908 $str .= "\n<tr><td>"._("Password expires").": </td><td>"._("No")."</td></tr>";
909 $str .= "\n<tr><td colspan='2'><font color='gray'>".
910 sprintf(_("The password would expire on %s, but the password expiry is disabled."),$sambaPwdMustChange).
911 "</font></td></tr>";
912 }else{
913 $str .= "\n<tr><td>"._("Password expires").": </td><td>".$sambaPwdMustChange."</td></tr>";
914 }
916 $str .= "\n<tr><td>"._("Password change available").": </td><td>".$sambaPwdCanChange."</td></tr>".
917 "\n</table>";
918 "\n</div>";
919 return($str);
920 }
923 function remove_from_parent()
924 {
925 /* Cancel if there's nothing to do here */
926 if (!$this->initially_was_account){
927 return;
928 }
930 /* include global link_info */
931 $ldap= $this->config->get_ldap_link();
933 plugin::remove_from_parent();
935 /* Keep uid attribute for gosaAccount */
936 unset($this->attrs['uid']);
937 unset($this->attrs['uidNumber']);
938 unset($this->attrs['gidNumber']);
940 /* Remove objectClass for sambaIdmapEntry */
941 $tmp= array();
942 for ($i= 0; $i<count($this->attrs["objectClass"]); $i++){
943 if ($this->attrs['objectClass'][$i] != 'sambaIdmapEntry'){
944 $tmp[]= $this->attrs['objectClass'][$i];
945 }
946 }
947 $this->attrs['objectClass']= $tmp;
949 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
950 $this->attributes, "Save");
951 $ldap->cd($this->dn);
952 $this->cleanup();
953 $ldap->modify ($this->attrs);
955 new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
957 if (!$ldap->success()){
958 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
959 }
961 /* Optionally execute a command after we're done */
962 $this->handle_post_events("remove", array("uid" => $this->uid));
963 }
966 /* Check for input problems */
967 function check()
968 {
969 /* Call common method to give check the hook */
970 $message= plugin::check();
972 /* sambaHomePath requires sambaHomeDrive and vice versa */
973 if(!empty($this->sambaHomePath) && empty($this->sambaHomeDrive)){
974 $message[]= msgPool::required(_("Home drive"));
975 }
976 if(!empty($this->sambaHomeDrive) && empty($this->sambaHomePath)){
977 $message[]= msgPool::required(_("Home path"));
978 }
980 /* Strings */
981 foreach (array( "sambaHomePath" => _("Home directory"),
982 "sambaProfilePath" => _("Profile path")) as $key => $val){
983 if (!$this->mungedObject->is_samba_path($this->$key)){
984 $message[]= msgPool::invalid($val);
985 }
986 }
988 /* Numeric values */
989 foreach (array( "CtxMaxConnectionTime" => _("Connection"),
990 "CtxMaxDisconnectionTime" => _("Disconnection"),
991 "CtxMaxIdleTime" => _("IDLE")) as $key => $val){
993 if (isset($this->mungedObject->ctx[$key]) && !tests::is_id($this->mungedObject->ctx[$key]) && $val != 0){
994 $message[]= msgPool::invalid($val);
995 }
996 }
998 /* Too many workstations? Windows usrmgr only supports eight */
999 if (substr_count($this->sambaUserWorkstations, ",") >= 8){
1000 $message[]= _("The windows usermanager allows eight clients at maximum!");
1001 }
1003 return ($message);
1004 }
1007 /* Save data to object */
1008 function save_object()
1009 {
1011 $SkipWrite = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
1013 /* We only care if we are on the sambaTab... */
1014 if (isset($_POST['sambaTab'])){
1015 plugin::save_object();
1017 if(isset($_POST['display_information'])){
1018 msg_dialog::display(_("Information"),
1019 $this->get_samba_information(),
1020 INFO_DIALOG);
1021 }
1023 /* Take care about access options */
1024 if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){
1025 $attrname= "sambaPwdCanChange";
1026 if (isset($_POST["allow_pwchange"]) && $_POST["allow_pwchange"] == 1){
1027 $tmp= 1;
1028 } else {
1029 $tmp= 0;
1030 }
1031 if ($this->$attrname != $tmp){
1032 $this->is_modified= TRUE;
1033 }
1034 $this->pwdCanChange= $tmp;
1035 $this->sambaPwdCanChange= $tmp;
1036 }
1037 $tmp= "U";
1039 $this->no_expiry = FALSE;
1040 if (isset($_POST["no_expiry"])){
1041 if ($_POST["no_expiry"] == 1){
1042 $tmp.= "X";
1043 $this->no_expiry = TRUE;
1044 }
1045 }
1047 $this->no_password_required = FALSE;
1048 if (isset($_POST["no_password_required"])){
1049 if ($_POST["no_password_required"] == 1){
1050 $tmp.= "N";
1051 $this->no_password_required = TRUE;
1052 }
1053 }
1054 if (isset($_POST["password_expires"])){
1055 if ($_POST["password_expires"] == 1){
1056 $this->password_expires= 1;
1057 }
1058 } else {
1059 $this->password_expires= 0;
1060 }
1061 $this->temporary_disable = FALSE;
1062 if (isset($_POST["temporary_disable"])){
1063 if ($_POST["temporary_disable"] == 1){
1064 $this->temporary_disable = TRUE;
1065 if (is_integer(strpos($this->sambaAcctFlags, "L"))) {
1066 $tmp.= "L";
1067 } else {
1068 $tmp.= "D";
1069 }
1070 }
1071 }
1072 if (isset($_POST["logon_time_set"])){
1073 if ($_POST["logon_time_set"] == 1){
1074 $this->logon_time_set= 1;
1075 }
1076 } else {
1077 $this->logon_time_set= 0;
1078 }
1079 if (isset($_POST["logoff_time_set"])){
1080 if ($_POST["logoff_time_set"] == 1){
1081 $this->logoff_time_set= 1;
1082 }
1083 } else {
1084 $this->logoff_time_set= 0;
1085 }
1086 if (isset($_POST["kickoff_time_set"])){
1087 if ($_POST["kickoff_time_set"] == 1){
1088 $this->kickoff_time_set= 1;
1089 }
1090 } else {
1091 $this->kickoff_time_set= 0;
1092 }
1094 $fill= "";
1095 for ($i= strlen($tmp); $i<12; $i++){
1096 $fill.= " ";
1097 }
1099 $tmp= "[$tmp$fill]";
1101 /* Only save if acl's are set */
1102 if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){
1103 $attrname= "sambaAcctFlags";
1104 if ($this->$attrname != $tmp){
1105 $this->is_modified= TRUE;
1106 }
1107 $this->$attrname= $tmp;
1108 }
1110 /* Save sambaDomain attribute */
1111 if ($this->acl_is_writeable("sambaDomainName",$SkipWrite) && isset ($_POST['sambaDomainName'],$SkipWrite)){
1112 $this->sambaDomainName= validate($_POST['sambaDomainName']);
1113 }
1115 /* Save CTX values */
1116 /* Save obvious values */
1117 foreach($this->ctxattributes as $val){
1118 if (isset($_POST[$val]) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){
1119 if (get_magic_quotes_gpc()) {
1120 $this->mungedObject->ctx[$val]= stripcslashes(validate($_POST[$val]));
1121 } else {
1122 $this->mungedObject->ctx[$val]= validate($_POST[$val]);
1123 }
1124 }
1125 }
1127 /* Save checkbox states. */
1128 $this->mungedObject->setTsLogin(!isset($_POST['tslogin'])
1129 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1130 // Need to do some index checking to avoid messages like "index ... not found"
1131 if(isset($_POST['brokenconn'])) {
1132 $this->mungedObject->setBrokenConn($_POST['brokenconn'] == '1'
1133 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1134 }
1135 if(isset($_POST['reconn'])) {
1136 $this->mungedObject->setReConn($_POST['reconn'] == '1'
1137 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1138 }
1139 $this->mungedObject->setInheritMode(isset($_POST['inherit'])
1140 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1141 $this->mungedObject->setCtxMaxConnectionTimeF(!isset($_POST['CtxMaxConnectionTimeF'])
1142 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1143 $this->mungedObject->setCtxMaxDisconnectionTimeF(
1144 !isset($_POST['CtxMaxDisconnectionTimeF'])
1145 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1146 $this->mungedObject->setCtxMaxIdleTimeF(!isset($_POST['CtxMaxIdleTimeF'])
1147 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1148 $this->mungedObject->setConnectClientDrives(isset($_POST['connectclientdrives'])
1149 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1150 $this->mungedObject->setConnectClientPrinters(isset($_POST['connectclientprinters'])
1151 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1152 $this->mungedObject->setDefaultPrinter(isset($_POST['defaultprinter'])
1153 && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
1155 /* Save combo boxes. Takes two values */
1156 if(isset($_POST['reconn'])) {
1157 $this->mungedObject->setShadow(isset($_POST['shadow']) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite),$_POST['shadow']);
1158 }
1160 /* Check for changes */
1161 if ($this->sambaMungedDial != $this->mungedObject->getMunged()){
1162 $this->is_modified= TRUE;
1163 }
1165 }
1166 }
1169 /* Save to LDAP */
1170 function save()
1171 {
1172 /* Load uid and gid of this 'dn' */
1173 $ldap= $this->config->get_ldap_link();
1174 $ldap->cat($this->dn, array('uidNumber', 'gidNumber'));
1175 $tmp= $ldap->fetch();
1176 $this->uidNumber= $tmp['uidNumber'][0];
1177 $this->gidNumber= $tmp['gidNumber'][0];
1179 plugin::save();
1181 /* Remove objectClass for sambaIdmapEntry */
1182 $tmp= array();
1183 for ($i= 0; $i<count($this->attrs["objectClass"]); $i++){
1184 if ($this->attrs['objectClass'][$i] != 'sambaIdmapEntry'){
1185 $tmp[]= $this->attrs['objectClass'][$i];
1186 }
1187 }
1188 $this->attrs['objectClass']= $tmp;
1190 /* Generate rid / primaryGroupId */
1191 if (!isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'])){
1192 msg_dialog::display(_("Warning"), _("Undefined Samba SID detected. Please fix this problem manually!"), WARNING_DIALOG);
1193 } else {
1194 $this->SID= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'];
1195 $this->ridBase= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE'];
1196 }
1198 /* Need to generate a new uniqe uid/gid combination? */
1199 if ($this->sambaSID == "" || $this->orig_sambaDomainName != $this->sambaDomainName){
1200 $uidNumber= $this->uidNumber;
1201 while(TRUE){
1202 $sid= $this->SID."-".($uidNumber*2 + $this->ridBase);
1203 $ldap->cd($this->config->current['BASE']);
1204 $ldap->search("(sambaSID=$sid)", array("sambaSID"));
1205 if ($ldap->count() == 0){
1206 break;
1207 }
1208 $uidNumber++;
1209 }
1210 $this->attrs['sambaSID']= $sid;
1212 /* Check for users primary group */
1213 $ldap->cd($this->config->current['BASE']);
1214 $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn"));
1215 if ($ldap->count() != 1){
1216 msg_dialog::display(_("Warning"), _("Cannot convert primary group to samba group: group cannot be identified!"), WARNING_DIALOG);
1217 } else {
1218 $attrs= $ldap->fetch();
1219 $g= new group($this->config, $ldap->getDN());
1220 if ($g->sambaSID == ""){
1221 $g->sambaDomainName= $this->sambaDomainName;
1222 $g->smbgroup= TRUE;
1223 $g->save ();
1224 }
1225 $this->attrs['sambaPrimaryGroupSID']= $g->sambaSID;
1226 }
1227 }
1229 if ($this->sambaHomeDrive == ""){
1230 $this->attrs["sambaHomeDrive"]= array();
1231 }
1233 /* Generate munged dial value */
1234 $this->attrs["sambaMungedDial"]= $this->mungedObject->getMunged();
1236 /* User wants me to fake the idMappings? This is useful for
1237 making winbind resolve the user names in a reasonable amount
1238 of time in combination with larger databases. */
1239 if ($this->config->get_cfg_value("sambaidmapping") == "true"){
1240 $this->attrs['objectClass'][]= "sambaIdmapEntry";
1241 }
1244 /* Password expiery */
1245 if ($this->password_expires == "1"){
1246 #TODO: check for date format
1247 if ($this->attrs['sambaPwdMustChange'] == ""){
1248 $this->attrs['sambaPwdMustChange']= 0;
1249 } else {
1250 list($day, $month, $year)= split('\.', $this->sambaPwdMustChange);
1251 $this->attrs['sambaPwdMustChange']= mktime(0,0,0,$month, $day, $year);
1252 }
1253 } else {
1254 $this->attrs['sambaPwdMustChange']= array();
1255 }
1256 /* Make sure not to save zero in sambaPwdLastset */
1257 if ($this->sambaPwdLastSet != "0"){
1258 $this->attrs['sambaPwdLastSet']= $this->sambaPwdLastSet;
1259 } else {
1260 $this->attrs['sambaPwdLastSet']= array();
1261 }
1262 /* Account expiery */
1263 if ($this->logon_time_set == "1"){
1264 $this->attrs['sambaLogonTime']= $this->sambaLogonTime;
1265 } else {
1266 $this->attrs['sambaLogonTime']= array();
1267 }
1268 if ($this->logoff_time_set == "1"){
1269 $this->attrs['sambaLogoffTime']= $this->sambaLogoffTime;
1270 } else {
1271 $this->attrs['sambaLogoffTime']= array();
1272 }
1273 if ($this->kickoff_time_set == "1"){
1274 /* Adapt values to be timestamps */
1275 #TODO: check for date format
1276 if ($this->attrs['sambaKickoffTime'] == ""){
1277 $this->attrs['sambaKickoffTime']= 2147483647;
1278 } else {
1279 list($day, $month, $year)= split('\.', $this->sambaKickoffTime);
1280 $this->attrs['sambaKickoffTime']= mktime(0,0,0,$month, $day, $year);
1281 }
1282 } else {
1283 $this->attrs['sambaKickoffTime']= array();
1284 }
1286 /* Write back to ldap */
1287 $ldap->cd($this->dn);
1288 $this->cleanup();
1289 $ldap->modify ($this->attrs);
1291 if($this->initially_was_account){
1292 new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1293 }else{
1294 new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1295 }
1297 if (!$ldap->success()){
1298 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
1299 }
1301 /* Optionally execute a command after we're done */
1302 if ($this->initially_was_account == $this->is_account){
1303 if ($this->is_modified){
1304 $this->handle_post_events("modify", array("uid" => $this->uid));
1305 }
1306 } else {
1307 $this->handle_post_events("add", array("uid" => $this->uid));
1308 }
1309 }
1312 /* Force password set, if this account doesn't have any samba passwords */
1313 function password_change_needed()
1314 {
1315 if(!$this->initially_was_account && $this->is_account){
1316 $ldap = $this->config->get_ldap_link();
1317 $ldap->cat($this->dn,array("sambaLMPassword","sambaNTPassword"));
1318 $attrs = $ldap->fetch();
1319 if(!isset($attrs['sambaLMPassword']) || !isset($attrs['sambaNTPassword'])){
1320 return(TRUE);
1321 }
1322 }
1323 return(FALSE);
1324 }
1327 function adapt_from_template($dn, $skip= array())
1328 {
1329 plugin::adapt_from_template($dn, $skip);
1332 $this->sambaSID= "";
1333 $this->sambaPrimaryGroupSID= "";
1335 /* Fill mungedDial field */
1336 if (isset($this->attrs['sambaMungedDial']) && !in_array('sambaMungedDial', $skip)){
1337 $this->mungedObject->load($this->sambaMungedDial);
1338 }
1340 /* Adapt munged attributes */
1341 foreach($this->ctxattributes as $attr){
1342 if(isset($this->mungedObject->ctx[$attr]))
1343 $val = $this->mungedObject->ctx[$attr];
1345 foreach (array("sn", "givenName", "uid") as $repl){
1346 if (preg_match("/%$repl/i", $val)){
1347 $val= preg_replace ("/%$repl/i", $this->parent->$repl, $val);
1348 }
1349 }
1350 $this->mungedObject->ctx[$attr] = $val;
1351 }
1353 /* Password expiery */
1354 if(isset($this->attrs['sambaPwdMustChange']) &&
1355 $this->attrs['sambaPwdMustChange'][0] != 0 && !in_array('sambaPwdMustChange', $skip)){
1356 $this->password_expires= 1;
1357 }
1359 if(isset($this->attrs['sambaLogonTime']) && ! (
1360 $this->attrs['sambaLogonTime'][0] == 0 ||
1361 $this->attrs['sambaLogonTime'][0] == 2147483647
1362 ) && !in_array('sambaLogonTime', $skip)){
1363 $this->logon_time_set= 1;
1364 }
1365 if(isset($this->attrs['sambaLogoffTime']) && ! (
1366 $this->attrs['sambaLogoffTime'][0] == 0 ||
1367 $this->attrs['sambaLogoffTime'][0] == 2147483647
1368 ) && !in_array('sambaLogonTime', $skip)){
1369 $this->logoff_time_set= 1;
1370 }
1372 /* Account expiery */
1373 if(isset($this->attrs['sambaKickoffTime']) && ! (
1374 $this->attrs['sambaKickoffTime'][0] == 0 ||
1375 $this->attrs['sambaKickoffTime'][0] == 2147483647
1376 ) && !in_array('sambaKickoffTime', $skip)){
1377 $this->kickoff_time_set= 1;
1378 }
1380 /* Get global filter config */
1381 if (!session::is_set("sambafilter")){
1382 $ui= get_userinfo();
1383 $base= get_base_from_people($ui->dn);
1384 $sambafilter= array( "depselect" => $base, "regex" => "*");
1385 session::set("sambafilter", $sambafilter);
1386 }
1387 }
1390 static function plInfo()
1391 {
1392 return (array(
1393 "plShortName" => _("Samba"),
1394 "plDescription" => _("Samba settings"),
1395 "plSelfModify" => TRUE,
1396 "plDepends" => array("user"),
1397 "plPriority" => 5,
1398 "plSection" => array("personal" => _("My account")),
1399 "plCategory" => array("users"),
1400 "plOptions" => array(),
1402 "plProvidedAcls" => array(
1404 "sambaHomePath" => _("Generic home directory") ,
1405 "sambaHomeDrive" => _("Generic samba home drive") ,
1406 "sambaDomainName" => _("Domain") ,
1407 "sambaLogonScript" => _("Generic script path") ,
1408 "sambaProfilePath" => _("Generic profile path") ,
1409 "AllowLoginOnTerminalServer" => _("Allow login on terminal server"),
1410 "InheritClientConfig" => _("Inherit client config"),
1411 "sambaPwdCanChange" => _("Allow user to change password") ,
1412 "sambaAcctFlagsN" => _("Login from windows client requires no password"),
1413 "sambaAcctFlagsX" => _("Password never expires"),
1414 "sambaAcctFlagsL" => _("Lock samba account"),
1415 "sambaKickoffTime" => _("Account expires") ,
1416 "sambaPwdMustChange" => _("Password expires") ,
1417 "sambaLogonTime" => _("Limit Logon Time") ,
1418 "sambaLogoffTime" => _("Limit Logoff Time") ,
1419 "sambaLogonHours" => _("Logon hours") ,
1420 "sambaUserWorkstations" => _("Allow connection from"))
1421 ));
1422 }
1424 function enable_multiple_support()
1425 {
1426 plugin::enable_multiple_support();
1427 $this->multiple_support_active = TRUE;
1428 }
1430 function multiple_save_object()
1431 {
1432 if (isset($_POST['sambaTab'])){
1433 $this->save_object();
1434 plugin::multiple_save_object();
1435 foreach(array("allow_pwchange","tslogin","CtxWFHomeDir","CtxWFHomeDirDrive","CtxWFProfilePath",
1436 "inherit","CtxWorkDirectory","CtxInitialProgram","CtxMaxConnectionTimeF","CtxMaxConnectionTime","CtxMaxDisconnectionTimeF",
1437 "CtxMaxDisconnectionTime","CtxMaxIdleTimeF","CtxMaxIdleTime","connectclientdrives",
1438 "onnectclientprinters","defaultprinter","shadow","brokenconn",
1439 "reconn","allow_pwchange","connectclientprinters","no_expiry","no_password_required","temporary_disable",
1440 "password_expires","logon_time_set","logoff_time_set","kickoff_time_set","SetSambaLogonHours",
1441 "workstation_list") as $attr){
1442 if(isset($_POST["use_".$attr])){
1443 $this->multi_boxes[] = $attr;
1444 }
1445 }
1446 }
1447 }
1450 function multiple_check()
1451 {
1452 $message = plugin::multiple_check();
1454 /* Strings */
1455 foreach (array( "sambaHomePath" => _("Home directory"),
1456 "sambaProfilePath" => _("Profile path")) as $key => $val){
1457 if (in_array($key,$this->multi_boxes) && !$this->mungedObject->is_samba_path($this->$key)){
1458 $message[]= msgPool::invalid($val);
1459 }
1460 }
1462 /* Numeric values */
1463 foreach (array( "CtxMaxConnectionTime" => _("Connection"),
1464 "CtxMaxDisconnectionTime" => _("Disconnection"),
1465 "CtxMaxIdleTime" => _("IDLE")) as $key => $val){
1466 if (in_array($key,$this->multi_boxes) &&
1467 isset($this->mungedObject->ctx[$key]) &&
1468 !tests::is_id($this->mungedObject->ctx[$key]) && $val != 0){
1469 $message[]=msgPool::invalid($val);
1470 }
1471 }
1473 /* Too many workstations? Windows usrmgr only supports eight */
1474 if (substr_count($this->sambaUserWorkstations, ",") >= 8){
1475 $message[]= _("The windows user manager only allows eight clients. You've specified more than eight.");
1476 }
1477 return($message);
1478 }
1481 function get_multi_init_values()
1482 {
1483 $ret = plugin::get_multi_init_values();
1485 /* Parse given sambaUserWorkstations into array
1486 * to allow "init_multiple_support()" to detect multiple used workstations.
1487 * Those workstations will be displayed in light grey.
1488 */
1489 $tmp2 = array("count" => 0);
1490 $tmp = split(",", $this->sambaUserWorkstations);
1491 foreach($tmp as $station){
1492 $station = trim($station);
1493 if(!empty($station)){
1494 $tmp2[] = $station;
1495 $tmp2['count'] ++;
1496 }
1497 }
1498 $ret['sambaUserWorkstations'] = $tmp2;
1499 return($ret);
1500 }
1504 function init_multiple_support($attrs,$all)
1505 {
1506 plugin::init_multiple_support($attrs,$all);
1508 $this->multiple_sambaUserWorkstations = array();
1509 if(isset($all['sambaUserWorkstations'])){
1510 for($i = 0 ; $i < $all['sambaUserWorkstations']['count'] ; $i++){
1511 $station = trim($all['sambaUserWorkstations'][$i]);
1512 $this->multiple_sambaUserWorkstations[$station] = array("Name" => $station, "UsedByAllUsers" => FALSE);
1513 }
1514 }
1515 if(isset($attrs['sambaUserWorkstations'])){
1516 for($i = 0 ; $i < $attrs['sambaUserWorkstations']['count'] ; $i++){
1517 $station = trim($attrs['sambaUserWorkstations'][$i]);
1518 $this->multiple_sambaUserWorkstations[$station] = array("Name" => $station, "UsedByAllUsers" => TRUE);
1519 }
1520 }
1521 }
1523 function multiple_execute()
1524 {
1525 return($this->execute());
1526 }
1528 function get_multi_edit_values()
1529 {
1530 $ret = plugin::get_multi_edit_values();
1532 /* Terminal Server */
1533 if(in_array("tslogin",$this->multi_boxes)){
1534 $ret['tslogin'] = $this->mungedObject->getTsLogin();
1535 }
1536 if(in_array("CtxWFHomeDirDrive",$this->multi_boxes)){
1537 $ret['CtxWFHomeDirDrive'] = $this->mungedObject->ctx['CtxWFHomeDirDrive'];
1538 }
1539 if(in_array("CtxWFHomeDir",$this->multi_boxes)){
1540 $ret['CtxWFHomeDir'] = $this->mungedObject->ctx['CtxWFHomeDir'];
1541 }
1542 if(in_array("CtxWFProfilePath",$this->multi_boxes)){
1543 $ret['CtxWFProfilePath'] = $this->mungedObject->ctx['CtxWFProfilePath'];
1544 }
1546 if(in_array("inherit",$this->multi_boxes)){
1547 $ret['inherit'] = $this->mungedObject->getInheritMode();
1548 }
1549 if(in_array("CtxInitialProgram",$this->multi_boxes)){
1550 $ret['CtxInitialProgram'] = $this->mungedObject->ctx['CtxInitialProgram'];
1551 }
1552 if(in_array("CtxWorkDirectory",$this->multi_boxes)){
1553 $ret['CtxWorkDirectory'] = $this->mungedObject->ctx['CtxWorkDirectory'];
1554 }
1556 /* Time Limits. Be careful here, there are some negations */
1557 if(in_array("CtxMaxConnectionTimeF",$this->multi_boxes)){
1558 $ret["CtxMaxConnectionTimeF"] = !$this->mungedObject->getCtxMaxConnectionTimeF();
1559 if(!$ret["CtxMaxConnectionTimeF"]){
1560 $ret["CtxMaxConnectionTime"] = $this->mungedObject->ctx['CtxMaxConnectionTime'];
1561 }
1562 }
1563 if(in_array("CtxMaxDisconnectionTimeF",$this->multi_boxes)){
1564 $ret["CtxMaxDisconnectionTimeF"]= !$this->mungedObject->getCtxMaxDisconnectionTimeF();
1565 if(!$ret["CtxMaxDisconnectionTimeF"]){
1566 $ret["CtxMaxDisconnectionTime"]= $this->mungedObject->ctx['CtxMaxDisconnectionTime'];
1567 }
1568 }
1569 if(in_array("CtxMaxIdleTimeF",$this->multi_boxes)){
1570 $ret["CtxMaxIdleTimeF"] = !$this->mungedObject->getCtxMaxIdleTimeF();
1571 if(!$ret["CtxMaxIdleTimeF"]){
1572 $ret["CtxMaxIdleTime"] = $this->mungedObject->ctx['CtxMaxIdleTime'];
1573 }
1574 }
1576 /* Client Devices */
1577 if(in_array("connectclientdrives",$this->multi_boxes)){
1578 $ret["connectclientdrives"] = $this->mungedObject->getConnectClientDrives();
1579 }
1580 if(in_array("connectclientprinters",$this->multi_boxes)){
1581 $ret["connectclientprinters"] = $this->mungedObject->getConnectClientPrinters();
1582 }
1583 if(in_array("defaultprinter",$this->multi_boxes)){
1584 $ret["defaultprinter"] = $this->mungedObject->getDefaultPrinter();
1585 }
1587 /* Misc */
1588 if(in_array("shadow",$this->multi_boxes)){
1589 $ret["shadow"] =$this->mungedObject->getShadow();
1590 }
1591 if(in_array("brokenconn",$this->multi_boxes)){
1592 $ret["brokenconn"]=$this->mungedObject->getBrokenConn();
1593 }
1594 if(in_array("reconn",$this->multi_boxes)){
1595 $ret["reconn"] =$this->mungedObject->getReConn();
1596 }
1598 /* Flags */
1599 if(in_array("allow_pwchange",$this->multi_boxes)){
1600 $ret['sambaPwdCanChange'] = $this->sambaPwdCanChange;
1601 $ret['pwdCanChange'] = $this->pwdCanChange;
1602 }
1604 if(in_array("password_expires",$this->multi_boxes)){
1605 $ret['password_expires'] = $this->password_expires;
1606 $ret['sambaPwdMustChange']= $this->sambaPwdMustChange;
1607 }
1608 if(in_array("logon_time_set",$this->multi_boxes)){
1609 $ret['logon_time_set'] = $this->logon_time_set;
1610 $ret['sambaLogonTime'] = $this->sambaLogonTime;
1611 }
1612 if(in_array("logoff_time_set",$this->multi_boxes)){
1613 $ret['logoff_time_set'] = $this->logoff_time_set;
1614 $ret['sambaLogoffTime'] = $this->sambaLogoffTime;
1615 }
1616 if(in_array("kickoff_time_set",$this->multi_boxes)){
1617 $ret['kickoff_time_set'] = $this->kickoff_time_set;
1618 $ret['sambaKickoffTime'] = $this->sambaKickoffTime;
1619 }
1621 if(in_array("no_password_required",$this->multi_boxes)){
1622 $ret['no_password_required'] = $this->no_password_required;
1623 }
1625 if(in_array("no_expiry",$this->multi_boxes)){
1626 $ret['no_expiry'] = $this->no_expiry;
1627 }
1629 if(in_array("temporary_disable",$this->multi_boxes)){
1630 $ret['temporary_disable'] = $this->temporary_disable;
1631 }
1633 if(in_array("SetSambaLogonHours",$this->multi_boxes)){
1634 $ret['sambaLogonHours'] = $this->sambaLogonHours;
1635 }
1637 if(in_array("workstation_list",$this->multi_boxes)){
1638 $ret['multiple_sambaUserWorkstations'] = $this->multiple_sambaUserWorkstations;
1639 }
1640 return($ret);
1641 }
1643 function set_multi_edit_values($values)
1644 {
1645 plugin::set_multi_edit_values($values);
1647 /* Prepare current workstation settings to be merged
1648 * with multiple edit settings.
1649 */
1650 if(isset($values['multiple_sambaUserWorkstations'])){
1651 $cur_ws = array();
1652 $m_ws = $values['multiple_sambaUserWorkstations'];
1654 /* Prepare current settings to be merged */
1655 if(isset($this->sambaUserWorkstations)){
1656 $ttmp = split(",",$this->sambaUserWorkstations);
1657 foreach($ttmp as $station){
1658 $station = trim($station);
1659 if(!empty($station)){
1660 $cur_ws[$station] = array("Name" => $station, "UsedByAllUsers" => TRUE);
1661 }
1662 }
1663 }
1665 /* Unset removed workstations */
1666 foreach($cur_ws as $cur_name => $cur_station){
1667 if(!isset($m_ws[$cur_name])){
1668 unset($cur_ws[$cur_name]);
1669 }
1670 }
1672 /* Add all added workstations */
1673 foreach($m_ws as $name => $station){
1674 if($station['UsedByAllUsers']){
1675 $cur_ws[$name] = $station;
1676 }
1677 }
1679 $this->sambaUserWorkstations = "";
1680 foreach($cur_ws as $name => $ws){
1681 $this->sambaUserWorkstations .= $name.",";
1682 }
1683 $this->sambaUserWorkstations=preg_replace("/,$/","",$this->sambaUserWorkstations);
1684 }
1686 /* Enable disabled terminal login, this is inverted somehow */
1687 if(isset($values['tslogin'])) $this->mungedObject->setTsLogin(!$values['tslogin']);
1689 /* Imherit client configuration */
1690 if(isset($values['inherit'])) $this->mungedObject->setInheritMode($values['inherit']);
1692 /* Get all ctx values posted */
1693 $ctx = array("CtxWFHomeDirDrive","CtxWFHomeDir","CtxWFProfilePath","CtxInitialProgram","CtxWorkDirectory",
1694 "CtxMaxConnectionTime","CtxMaxDisconnectionTime","CtxMaxIdleTime");
1695 foreach($ctx as $attr){
1696 if(isset($values[$attr])){
1697 $this->mungedObject->ctx[$attr] = $values[$attr] ;
1698 }
1699 }
1701 if(isset($values['CtxMaxConnectionTimeF'])) $this->mungedObject->setCtxMaxConnectionTimeF($values['CtxMaxConnectionTimeF']);
1702 if(isset($values['CtxMaxDisconnectionTimeF']))$this->mungedObject->setCtxMaxDisconnectionTimeF($values['CtxMaxDisconnectionTimeF']);
1703 if(isset($values['CtxMaxIdleTimeF'])) $this->mungedObject->setCtxMaxIdleTimeF($values['CtxMaxIdleTimeF']);
1705 if(isset($values['connectclientdrives'])) $this->mungedObject->setConnectClientDrives($values['connectclientdrives']);
1706 if(isset($values['connectclientprinters'])) $this->mungedObject->setConnectClientPrinters($values['connectclientprinters']);
1707 if(isset($values['defaultprinter'])) $this->mungedObject->setDefaultPrinter($values['defaultprinter']);
1709 if(isset($values['shadow'])) $this->mungedObject->setShadow($values['shadow'],$values['shadow']);
1710 if(isset($values['brokenconn'])) $this->mungedObject->setBrokenConn($values['brokenconn'],$values['brokenconn']);
1711 if(isset($values['reconn'])) $this->mungedObject->setReConn($values['reconn'],$values['reconn']);
1714 if(isset($values['sambaPwdCanChange'])) $this->sambaPwdCanChange = $values['sambaPwdCanChange'];
1715 if(isset($values['pwdCanChange'])) $this->pwdCanChange = $values['pwdCanChange'];
1720 if(isset($values['password_expires'])){
1721 $this->password_expires = $values['password_expires'];
1722 $this->sambaPwdMustChange = $values['sambaPwdMustChange'];
1723 }
1724 if(isset($values['logon_time_set'])){
1725 $this->logon_time_set = $values['logon_time_set'];
1726 $this->sambaLogonTime = $values['sambaLogonTime'];
1727 }
1728 if(isset($values['logoff_time_set'])){
1729 $this->logoff_time_set = $values['logoff_time_set'];
1730 $this->sambaLogoffTime = $values['sambaLogoffTime'];
1731 }
1732 if(isset($values['kickoff_time_set'])){
1733 $this->kickoff_time_set = $values['kickoff_time_set'];
1734 $this->sambaKickoffTime = $values['sambaKickoffTime'];
1735 }
1737 if(isset($values['no_password_required'])){
1738 if($values['no_password_required']){
1739 if(!preg_match("/N/",$this->sambaAcctFlags)) {
1740 $this->sambaAcctFlags = preg_replace("/ /","N",$this->sambaAcctFlags,1);
1741 }
1742 }else{
1743 $this->sambaAcctFlags = preg_replace("/N/"," ",$this->sambaAcctFlags,1);
1744 }
1745 }
1747 if(isset($values['no_expiry'])){
1748 if($values['no_expiry']){
1749 if(!preg_match("/N/",$this->sambaAcctFlags)) {
1750 $this->sambaAcctFlags = preg_replace("/ /","N",$this->sambaAcctFlags,1);
1751 }
1752 }else{
1753 $this->sambaAcctFlags = preg_replace("/N/"," ",$this->sambaAcctFlags,1);
1754 }
1755 }
1757 if(isset($values['temporary_disable'])){
1758 if($values['temporary_disable']){
1759 if(preg_match("/L/",$this->sambaAcctFlags)) {
1760 // Keep L
1761 }else{
1762 $this->sambaAcctFlags = preg_replace("/ /","D",$this->sambaAcctFlags,1);
1763 }
1764 }else{
1765 $this->sambaAcctFlags = preg_replace("/D/"," ",$this->sambaAcctFlags,1);
1766 }
1767 }
1768 }
1771 function PrepareForCopyPaste($source)
1772 {
1773 plugin::PrepareForCopyPaste($source);
1775 /* Set a new SID */
1776 $this->sambaSID = "";
1777 }
1779 }
1781 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1782 ?>