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