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