Code

Fixed proxy greyout and acls handling
[gosa.git] / plugins / personal / generic / class_user.inc
1 <?php
2 /*!
3   \brief   user plugin
4   \author  Cajus Pollmeier <pollmeier@gonicus.de>
5   \version 2.00
6   \date    24.07.2003
8   This class provides the functionality to read and write all attributes
9   relevant for person, organizationalPerson, inetOrgPerson and gosaAccount
10   from/to the LDAP. It does syntax checking and displays the formulars required.
11  */
13 class user extends plugin
14 {
15   /* Definitions */
16   var $plHeadline= "Generic";
17   var $plDescription= "This does something";
19   /* CLI vars */
20   var $cli_summary= "Handling of GOsa's user base object";
21   var $cli_description= "Some longer text\nfor help";
22   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
24   /* Plugin specific values */
25   var $base= "";
26   var $cn= "";
27   var $personalTitle= "";
28   var $academicTitle= "";
29   var $homePostalAddress= "";
30   var $homePhone= "";
31   var $labeledURI= "";
32   var $o= "";
33   var $ou= "";
34   var $departmentNumber= "";
35   var $employeeNumber= "";
36   var $employeeType= "";
37   var $roomNumber= "";
38   var $telephoneNumber= "";
39   var $facsimileTelephoneNumber= "";
40   var $mobile= "";
41   var $pager= "";
42   var $l= "";
43   var $st= "";
44   var $postalAddress= "";
45   var $dateOfBirth;
46   var $use_dob= "0";
47   var $gender="0";
48   var $preferredLanguage="0";
50   var $jpegPhoto= "*removed*";
51   var $photoData= "";
52   var $old_jpegPhoto= "";
53   var $old_photoData= "";
54   var $cert_dialog= FALSE;
55   var $picture_dialog= FALSE;
57   var $userPKCS12= "";
58   var $userSMIMECertificate= "";
59   var $userCertificate= "";
60   var $certificateSerialNumber= "";
61   var $old_certificateSerialNumber= "";
62   var $old_userPKCS12= "";
63   var $old_userSMIMECertificate= "";
64   var $old_userCertificate= "";
66   var $gouvernmentOrganizationalUnit= "";
67   var $houseIdentifier= "";
68   var $street= "";
69   var $postalCode= "";
70   var $vocation= "";
71   var $ivbbLastDeliveryCollective= "";
72   var $gouvernmentOrganizationalPersonLocality= "";
73   var $gouvernmentOrganizationalUnitDescription= "";
74   var $gouvernmentOrganizationalUnitSubjectArea= "";
75   var $functionalTitle= "";
76   var $role= "";
77   var $publicVisible= "";
79   var $dialog;
81   /* variables to trigger password changes */
82   var $pw_storage= "crypt";
83   var $last_pw_storage= "unset";
84   var $had_userCertificate= FALSE;
86   /* attribute list for save action */
87   var $attributes= array("sn", "givenName", "uid", "personalTitle", "academicTitle",
88       "homePostalAddress", "homePhone", "labeledURI", "o", "ou", "dateOfBirth", "gender","preferredLanguage",
89       "departmentNumber", "employeeNumber", "employeeType", "l", "st",
90       "roomNumber", "telephoneNumber", "mobile", "pager", "cn", "userPKCS12",
91       "postalAddress", "facsimileTelephoneNumber", "userSMIMECertificate");
93   var $objectclasses= array("top", "person", "organizationalPerson", "inetOrgPerson",
94       "gosaAccount");
96   /* attributes that are part of the government mode */
97   var $govattrs= array("gouvernmentOrganizationalUnit", "houseIdentifier", "vocation",
98       "ivbbLastDeliveryCollective", "gouvernmentOrganizationalPersonLocality",
99       "gouvernmentOrganizationalUnitDescription","gouvernmentOrganizationalUnitSubjectArea",
100       "functionalTitle", "certificateSerialNumber", "publicVisible", "street", "role",
101       "postalCode");
104   /* constructor, if 'dn' is set, the node loads the given
105      'dn' from LDAP */
106   function user ($config, $dn= NULL)
107   {
108     $this->config= $config;
109     /* Configuration is fine, allways */
110     if ($this->config->current['GOVERNMENTMODE']){
111       $this->attributes=array_merge($this->attributes,$this->govattrs);
112     }
114     /* Load base attributes */
115     plugin::plugin ($config, $dn);
117     if ($this->config->current['GOVERNMENTMODE']){
118       /* Fix public visible attribute if unset */
119       if (!isset($this->attrs['publicVisible'])){
120         $this->publicVisible == "nein";
121       }
122     }
124     /* Load government mode attributes */
125     if ($this->config->current['GOVERNMENTMODE']){
126       /* Copy all attributs */
127       foreach ($this->govattrs as $val){
128         if (isset($this->attrs["$val"][0])){
129           $this->$val= $this->attrs["$val"][0];
130         }
131       }
132     }
134     /* Create me for new accounts */
135     if ($dn == "new"){
136       $this->is_account= TRUE;
137     }
139     /* Make hash default to md5 if not set in config */
140     if (!isset($this->config->current['HASH'])){
141       $hash= "md5";
142     } else {
143       $hash= $this->config->current['HASH'];
144     }
146     /* Load data from LDAP? */
147     if ($dn != NULL){
149       /* Do base conversation */
150       if ($this->dn == "new"){
151         $ui= get_userinfo();
152         $this->base= dn2base($ui->dn);
153       } else {
154         $this->base= dn2base($dn);
155       }
157       /* get password storage type */
158       if (isset ($this->attrs['userPassword'][0])){
159         /* Initialize local array */
160         $matches= array();
161         if (preg_match ("/^{([^}]+)}(.+)/", $this->attrs['userPassword'][0], $matches)){
162           $this->pw_storage= strtolower($matches[1]);
163         } else {
164           if ($this->attrs['userPassword'][0] != ""){
165             $this->pw_storage= "clear";
166           } else {
167             $this->pw_storage= $hash;
168           }
169         }
170       } else {
171         /* Preset with vaule from configuration */
172         $this->pw_storage= $hash;
173       }
175       /* Load extra attributes: certificate and picture */
176       $this->load_cert();
177       if ($this->userCertificate != ""){
178         $this->had_userCertificate= TRUE;
179       }
180     }
182     /* Reset password storage indicator, used by password_change_needed() */
183     if ($dn == "new"){
184       $this->last_pw_storage= "unset";
185     } else {
186       $this->last_pw_storage= $this->pw_storage;
187     }
189     /* Generate dateOfBirth entry */
190     if (isset ($this->attrs['dateOfBirth'])){
191       /* This entry is ISO 8601 conform */
192       list($year, $month, $day)= split("-", $this->attrs['dateOfBirth'][0], 3);
193     
194       $this->dateOfBirth=array( 'mon'=> $month,"mday"=> $day,"year"=> $year);
195       $this->use_dob= "1";
196     } else {
197       $this->use_dob= "0";
198     }
200     /* Put gender attribute to upper case */
201     if (isset ($this->attrs['gender'])){
202       $this->gender= strtoupper($this->attrs['gender'][0]);
203     }
204   }
207   /* execute generates the html output for this node */
208   function execute()
209   {
210     /* Call parent execute */
211     plugin::execute();
213     $smarty= get_smarty();
215     /* Fill calendar */
216     if ($this->dateOfBirth == "0"){
217       $date= getdate();
218     } else {
219       if(is_array($this->dateOfBirth)){
220         $date = $this->dateOfBirth;
221       }else{
222         $date = getdate($this->dateOfBirth);
223       }
224     }
226     $days= array();
227     for($d= 1; $d<32; $d++){
228       $days[$d]= $d;
229     }
230     $years= array();
232     if(($date['year']-100)<1901){
233       $start = 1901;
234     }else{
235       $start = $date['year']-100;
236     }
238     $end = $start +100;
239     
240     for($y= $start; $y<=$end; $y++){
241       $years[]= $y;
242     }
243     $years['-']= "-&nbsp;";
244     $months= array(_("January"), _("February"), _("March"), _("April"),
245         _("May"), _("June"), _("July"), _("August"), _("September"),
246         _("October"), _("November"), _("December"), '-' => '-&nbsp;');
247     $smarty->assign("day", $date["mday"]);
248     $smarty->assign("days", $days);
249     $smarty->assign("months", $months);
250     $smarty->assign("month", $date["mon"]-1);
251     $smarty->assign("years", $years);
252     $smarty->assign("year", $date["year"]);
254     /* Assign sex */
255     $sex= array(0 => "&nbsp;", "F" => _("female"), "M" => _("male"));
256     $smarty->assign("gender_list", $sex);
258     /* Assign prefered langage */
259     $language= array(0 => "&nbsp;", "fr_FR" => ("fr_FR"), "en_EN" => ("en_EN"), 
260                                     "de_DE" => ("de_DE"), "it_IT" => ("it_IT"), 
261                                     "nl_NL" => ("nl_NL"), "ru_RU" => ("ru_RU"));
262     $smarty->assign("preferredLanguage_list", $language);
264     /* Get random number for pictures */
265     srand((double)microtime()*1000000); 
266     $smarty->assign("rand", rand(0, 10000));
267     $this->load_picture();
270     /* Do we represent a valid gosaAccount? */
271     if (!$this->is_account){
272       echo "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
273         _("This account has no valid GOsa extensions.")."</b>";
274       return;
275     }
277     /* Base select dialog */
278     $once = true;
279     foreach($_POST as $name => $value){
280       if(preg_match("/^chooseBase/",$name) && $once){
281         $once = false;
282         $this->dialog = new baseSelectDialog($this->config,$this,$this->allowedBasesToMoveTo());
283         $this->dialog->setCurrentBase($this->base);
284       }
285     }
287     /* Dialog handling */
288     if(is_object($this->dialog)){
289       /* Must be called before save_object */
290       $this->dialog->save_object();
291    
292       if($this->dialog->isClosed()){
293         $this->dialog = false;
294       }elseif($this->dialog->isSelected()){
295         $this->base = $this->dialog->isSelected();
296         $this->dialog= false;
297       }else{
298         return($this->dialog->execute());
299       }
300     }
302     /* Want picture edit dialog? */
303     if($this->acl_is_writeable("userPicture")) {
304       if (isset($_POST['edit_picture'])){
305         /* Save values for later recovery, in case some presses
306            the cancel button. */
307         $this->old_jpegPhoto= $this->jpegPhoto;
308         $this->old_photoData= $this->photoData;
309         $this->picture_dialog= TRUE;
310         $this->dialog= TRUE;
311       }
312     }
314     /* Remove picture? */
315     if($this->acl_is_writeable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))) ){
316       if (isset($_POST['picture_remove'])){
317         $this->jpegPhoto= "*removed*";
318         $this->set_picture ("./images/default.jpg");
319         $this->is_modified= TRUE;
321         return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
322       }
323     }
325     /* Save picture */
326     if (isset($_POST['picture_edit_finish'])){
328       /* Check for clean upload */
329       if ($_FILES['picture_file']['name'] != ""){
330         if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) {
331           print_red(_("The specified file has not been uploaded via HTTP POST! Aborted."));
332         }else{
333           /* Activate new picture */
334           $this->set_picture($_FILES['picture_file']['tmp_name']);
335         }
336       }
337       $this->picture_dialog= FALSE;
338       $this->dialog= FALSE;
339       $this->is_modified= TRUE;
340     }
343     /* Cancel picture */
344     if (isset($_POST['picture_edit_cancel'])){
346       /* Restore values */
347       $this->jpegPhoto= $this->old_jpegPhoto;
348       $this->photoData= $this->old_photoData;
350       /* Update picture */
351       $_SESSION['binary']= $this->photoData;
352       $_SESSION['binarytype']= "image/jpeg";
353       $this->picture_dialog= FALSE;
354       $this->dialog= FALSE;
355     }
357     /* Toggle dateOfBirth information */
358     if (isset($_POST['set_dob'])){
359       $this->use_dob= ($this->use_dob == "0")?"1":"0";
360     }
363     /* Want certificate= */
364     if ((isset($_POST['edit_cert'])) && $this->acl_is_readable("Certificate")){
366       /* Save original values for later reconstruction */
367       foreach (array("certificateSerialNumber", "userCertificate",
368             "userSMIMECertificate", "userPKCS12") as $val){
370         $oval= "old_$val";
371         $this->$oval= $this->$val;
372       }
374       $this->cert_dialog= TRUE;
375       $this->dialog= TRUE;
376     }
379     /* Cancel certificate dialog */
380     if (isset($_POST['cert_edit_cancel'])){
382       /* Restore original values in case of 'cancel' */
383       foreach (array("certificateSerialNumber", "userCertificate",
384             "userSMIMECertificate", "userPKCS12") as $val){
386         $oval= "old_$val";
387         $this->$val= $this->$oval;
388       }
389       $this->cert_dialog= FALSE;
390       $this->dialog= FALSE;
391     }
394     /* Remove certificate? */
395     if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){ 
396       foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") as $val){
397         if (isset($_POST["remove_$val"])){
399           /* Reset specified cert*/
400           $this->$val= "";
401           $this->is_modified= TRUE;
402         }
403       }
404     }
406     /* Upload new cert and close dialog? */     
407     if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){ 
408       if (isset($_POST['cert_edit_finish'])){
410         /* for all certificates do */
411         foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12")
412             as $val){
414           /* Check for clean upload */
415           if (array_key_exists($val."_file", $_FILES) &&
416               array_key_exists('name', $_FILES[$val."_file"]) &&
417               $_FILES[$val."_file"]['name'] != "" &&
418               is_uploaded_file($_FILES[$val."_file"]['tmp_name'])) {
419             $this->set_cert("$val", $_FILES[$val."_file"]['tmp_name']);
420           }
421         }
423         /* Save serial number */
424         if (isset($_POST["certificateSerialNumber"]) &&
425             $_POST["certificateSerialNumber"] != ""){
427           if (!is_id($_POST["certificateSerialNumber"])){
428             print_red (_("Please enter a valid serial number"));
430             foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
431               if ($this->$cert != ""){
432                 $smarty->assign("$cert"."_state", "true");
433               } else {
434                 $smarty->assign("$cert"."_state", "");
435               }
436             }
437             return ($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
438           }
440           $this->certificateSerialNumber= $_POST["certificateSerialNumber"];
441           $this->is_modified= TRUE;
442         }
444         $this->cert_dialog= FALSE;
445         $this->dialog= FALSE;
446       }
447     }
448     /* Display picture dialog */
449     if ($this->picture_dialog){
450       return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
451     }
453     /* Display cert dialog */
454     if ($this->cert_dialog){
455       $smarty->assign("CertificateACL",$this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
456       $smarty->assign("Certificate_readable",$this->acl_is_readable("Certificate"));
458       foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
459         if ($this->$cert != ""){
460           /* import certificate */
461           $certificate = new certificate;
462           $certificate->import($this->$cert);
463       
464           /* Read out data*/
465           $timeto   = $certificate->getvalidto_date();
466           $timefrom = $certificate->getvalidfrom_date();
467           $str = "<table summary=\"\" border=0><tr><td style='vertical-align:top'>CN</td><td>".preg_replace("/ /", "&nbsp;", $certificate->getname())."</td></tr></table><br>".
468                   sprintf(_("Certificate is valid from %s to %s and is currently %s."), "<b>".date('d M Y',$timefrom)."</b>","<b>".date('d M Y',$timeto)."</b>", $certificate->isvalid()?"<b><font style='color:green'>"._("valid")."</font></b>":"<b><font style='color:red'>"._("invalid")."</font></b>");
469           $smarty->assign($cert."info",$str);
470           $smarty->assign($cert."_state","true");
471         } else {
472           $smarty->assign($cert."info", "<i>"._("No certificate installed")."</i>");
473           $smarty->assign($cert."_state","");
474         }
475       }
476       $smarty->assign("governmentmode", "false");
477       return($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
478     }
480     /* Prepare password hashes */
481     if ($this->pw_storage == ""){
482       $this->pw_storage= $this->config->current['HASH'];
483     }
485     $temp   = @passwordMethod::get_available_methods();
486     $hashes = $temp['name'];
487     
488     /* Load attributes and acl's */
489     $ui =get_userinfo();
490     foreach($this->attributes as $val){
491       $smarty->assign("$val", $this->$val);
492       $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
493     }
495     $smarty->assign("pwmode", $hashes);
496     $smarty->assign("pwmode_select", $this->pw_storage);
497     $smarty->assign("passwordStorageACL", $this->getacl("userPassword",(!is_object($this->parent) && !isset($_SESSION['edit']))));
498     $smarty->assign("base_select",      $this->base);
499     $smarty->assign("CertificatesACL",  $this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
500     $smarty->assign("userPictureACL",   $this->getacl("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
501     $smarty->assign("userPicture_is_readable",   $this->acl_is_readable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
503     /* Create base acls */
504     $baseACL = $this->getacl("base",(!is_object($this->parent) && !isset($_SESSION['edit'])));
505     if(!$this->acl_is_moveable()) {
506       $baseACL = preg_replace("/w/","",$baseACL);
507     }
508     $smarty->assign("baseACL",          $baseACL);
510     /* Show us the edit screen */
511     @$smarty->assign("bases", $this->allowedBasesToMoveTo());
512    #  $smarty->assign("bases", $this->config->idepartments);
515     /* Save government mode attributes */
516     if (isset($this->config->current['GOVERNMENTMODE']) &&
517         preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){
518       $smarty->assign("governmentmode", "true");
519       $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet",
520           "internet,ivbv", "internet,testa", "internet,ivbv,testa");
521       $smarty->assign("ivbbmodes", $ivbbmodes);
522       foreach ($this->govattrs as $val){
523         $smarty->assign("$val", $this->$val);
524         $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
525       }
526     } else {
527       $smarty->assign("governmentmode", "false");
528     }
530     /* Special mode for uid */
531     $uidACL= $this->getacl("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])));
532     if (isset ($this->dn)){
533       if ($this->dn != "new"){
534         $uidACL= preg_replace("/w/","",$uidACL);
535       }
536     }  else {
537       $uidACL= preg_replace("/w/","",$uidACL);
538     }
539     
540     $smarty->assign("uidACL", $uidACL);
541     $smarty->assign("is_template", $this->is_template);
542     $smarty->assign("use_dob", $this->use_dob);
544     if (isset($this->parent)){
545       if (isset($this->parent->by_object['phoneAccount']) &&
546           $this->parent->by_object['phoneAccount']->is_account){
547         $smarty->assign("has_phoneaccount", "true");
548       } else {
549         $smarty->assign("has_phoneaccount", "false");
550       }
551     } else {
552       $smarty->assign("has_phoneaccount", "false");
553     }
554     return($smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))));
555   }
558   /* remove object from parent */
559   function remove_from_parent()
560   {
561     $ldap= $this->config->get_ldap_link();
562     $ldap->rmdir ($this->dn);
563     show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/generic account with dn '%s' failed."),$this->dn));
565     /* Delete references to groups */
566     $ldap->cd ($this->config->current['BASE']);
567     $ldap->search ("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("uid"));
568     while ($ldap->fetch()){
569       $g= new group($this->config, $ldap->getDN());
570       $g->removeUser($this->uid);
571       $g->save ();
572     }
574     /* Delete references to object groups */
575     $ldap->cd ($this->config->current['BASE']);
576     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
577     while ($ldap->fetch()){
578       $og= new ogroup($this->config, $ldap->getDN());
579       unset($og->member[$this->dn]);
580       $og->save ();
581     }
583     /* Optionally execute a command after we're done */
584     $this->handle_post_events("remove");
585   }
588   /* Save data to object */
589   function save_object()
590   {
591     if (isset($_POST['generic'])){
593       /* Parents save function */
594       plugin::save_object ();
596       /* Save government mode attributes */
597       if ($this->config->current['GOVERNMENTMODE']){
598         foreach ($this->govattrs as $val){
599           if ($this->acl_is_writeable($val,(!is_object($this->parent) && !isset($_SESSION['edit']))) && isset($_POST["$val"])){
600             $data= stripcslashes($_POST["$val"]);
601             if ($data != $this->$val){
602               $this->is_modified= TRUE;
603             }
604             $this->$val= $data;
605           }
606         }
607       }
609       /* In template mode, the uid is autogenerated... */
610       if ($this->is_template){
611         $this->uid= strtolower($this->sn);
612         $this->givenName= $this->sn;
613       }
615       /* Save base and pw_storage, since these are no LDAP attributes */
616       if (isset($_POST['base'])){
618         $this->set_acl_base('dummy,'.$_POST['base']);
619         if($this->acl_is_moveable("base")){
621           foreach(array("base") as $val){
622             if(isset($_POST[$val])){
623               $data= validate($_POST[$val]);
624               if ($data != $this->$val){
625                 $this->is_modified= TRUE;
626               }
627               $this->$val= $data;
628             }
629           }
630         }else{
631           print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base'])));
632         }
633       }
635       /* Get pw_storage mode */
636       if (isset($_POST['pw_storage'])){
637         foreach(array("pw_storage") as $val){
638           if(isset($_POST[$val])){
639             $data= validate($_POST[$val]);
640             if ($data != $this->$val){
641               $this->is_modified= TRUE;
642             }
643             $this->$val= $data;
644           }
645         }
646       }
648       $this->set_acl_base('dummy,'.$this->base);
649     }
650   }
652   function rebind($ldap, $referral)
653   {
654     $credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']);
655     if (ldap_bind($ldap, $credentials['ADMIN'], $credentials['PASSWORD'])) {
656       $this->error = "Success";
657       $this->hascon=true;
658       $this->reconnect= true;
659       return (0);
660     } else {
661       $this->error = "Could not bind to " . $credentials['ADMIN'];
662       return NULL;
663     }
664   }
666   /* Save data to LDAP, depending on is_account we save or delete */
667   function save()
668   {
669     /* Only force save of changes .... 
670        If this attributes aren't changed, avoid saving.
671      */
672     if($this->gender=="0") $this->gender ="";
673     if($this->preferredLanguage=="0") $this->preferredLanguage ="";
674     
675  
676     /* First use parents methods to do some basic fillup in $this->attrs */
677     plugin::save ();
679     if ($this->use_dob == "1"){
680       $this->attrs['dateOfBirth'] = date("Y-m-d", $this->dateOfBirth);
681     }
683     /* Remove additional objectClasses */
684     $tmp= array();
685     foreach ($this->attrs['objectClass'] as $key => $set){
686       $found= false;
687       foreach (array("ivbbentry", "gosaUserTemplate") as $val){
688         if (preg_match ("/^$set$/i", $val)){
689           $found= true;
690           break;
691         }
692       }
693       if (!$found){
694         $tmp[]= $set;
695       }
696     }
698     /* Replace the objectClass array. This is done because of the
699        separation into government and normal mode. */
700     $this->attrs['objectClass']= $tmp;
702     /* Add objectClasss for template mode? */
703     if ($this->is_template){
704       $this->attrs['objectClass'][]= "gosaUserTemplate";
705     }
707     /* Hard coded government mode? */
708     if ($this->config->current['GOVERNMENTMODE'] != 'false'){
709       $this->attrs['objectClass'][]= "ivbbentry";
711       /* Copy standard attributes */
712       foreach ($this->govattrs as $val){
713         if ($this->$val != ""){
714           $this->attrs["$val"]= $this->$val;
715         } elseif (!$this->is_new) {
716           $this->attrs["$val"]= array();
717         }
718       }
720       /* Remove attribute if set to "nein" */
721       if ($this->publicVisible == "nein"){
722         $this->attrs['publicVisible']= array();
723         if($this->is_new){
724           unset($this->attrs['publicVisible']);
725         }else{
726           $this->attrs['publicVisible']=array();
727         }
729       }
731     }
733     /* Special handling for attribute userCertificate needed */
734     if ($this->userCertificate != ""){
735       $this->attrs["userCertificate;binary"]= $this->userCertificate;
736       $remove_userCertificate= false;
737     } else {
738       $remove_userCertificate= true;
739     }
741     /* Special handling for dateOfBirth value */
742     if ($this->use_dob != "1"){
743       if ($this->is_new) {
744         unset($this->attrs["dateOfBirth"]);
745       } else {
746         $this->attrs["dateOfBirth"]= array();
747       }
748     }
749     if (!$this->gender){
750       if ($this->is_new) {
751         unset($this->attrs["gender"]);
752       } else {
753         $this->attrs["gender"]= array();
754       }
755     }
756     if (!$this->preferredLanguage){
757       if ($this->is_new) {
758         unset($this->attrs["preferredLanguage"]);
759       } else {
760         $this->attrs["preferredLanguage"]= array();
761       }
762     }
764     /* Special handling for attribute jpegPhote needed, scale image via
765        image magick to 147x200 pixels and inject resulting data. */
766     if ($this->jpegPhoto != "*removed*"){
768       /* Fallback if there's no image magick inside PHP */
769       if (!function_exists("imagick_blob2image")){
770         /* Get temporary file name for conversation */
771         $fname = tempnam ("/tmp", "GOsa");
773         /* Open file and write out photoData */
774         $fp = fopen ($fname, "w");
775         fwrite ($fp, $this->photoData);
776         fclose ($fp);
778         /* Build conversation query. Filename is generated automatically, so
779            we do not need any special security checks. Exec command and save
780            output. For PHP safe mode, you'll need a configuration which respects
781            image magick as executable... */
782         $query= "convert -size 147x200 $fname -resize 147x200 +profile \"*\" -";
783         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
784             $query, "Execute");
786         /* Read data written by convert */
787         $output= "";
788         $sh= popen($query, 'r');
789         while (!feof($sh)){
790           $output.= fread($sh, 4096);
791         }
792         pclose($sh);
794         unlink($fname);
796         /* Save attribute */
797         $this->attrs["jpegPhoto"] = $output;
799       } else {
801         /* Load the new uploaded Photo */
802         if(!$handle  =  imagick_blob2image($this->photoData))  {
803           gosa_log("Can't Load image");
804         }
806         /* Resizing image to 147x200 and blur */
807         if(!imagick_resize($handle,147,200,IMAGICK_FILTER_GAUSSIAN,0)){
808           gosa_log("imagick_resize failed");
809         }
811         /* Converting image to JPEG */
812         if(!imagick_convert($handle,"JPEG")) {
813           gosa_log("Can't Convert to JPEG");
814         }
816         /* Creating binary Code for the Image */
817         if(!$dump = imagick_image2blob($handle)){
818           gosa_log("Can't create blob for image");
819         }
821         /* Sending Image */
822         $output=  $dump;
824         /* Save attribute */
825         $this->attrs["jpegPhoto"] = $output;
826       }
828     } elseif(!$this->is_new) {
829       $this->attrs["jpegPhoto"] = array();
830     }
832     /* Build new dn */
833     if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
834       $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
835     } else {
836       $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base;
837     }
839     /* This only gets called when user is renaming himself */
840     $ldap= $this->config->get_ldap_link();
841     if ($this->dn != $new_dn){
843       /* Write entry on new 'dn' */
844       $this->move($this->dn, $new_dn);
846       /* Happen to use the new one */
847       change_ui_dn($this->dn, $new_dn);
848       $this->dn= $new_dn;
849     }
852     /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
853        new entries. So do a check first... */
854     $ldap->cat ($this->dn, array('dn'));
855     if ($ldap->fetch()){
856       $mode= "modify";
857     } else {
858       $mode= "add";
859       $ldap->cd($this->config->current['BASE']);
860       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
861     }
863     /* Set password to some junk stuff in case of templates */
864     if ($this->is_template){
865       $this->attrs['userPassword']= '{crypt}N0T$3T4N0W';
866     }
868     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
869         $this->attributes, "Save via $mode");
871     /* Finally write data with selected 'mode' */
872     $this->cleanup();
873     $ldap->cd ($this->dn);
874     $ldap->$mode ($this->attrs);
875     if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/generic account with dn '%s' failed."),$this->dn))){
876       return (1);
877     }
879     /* Remove cert? 
880        For some reason, the 'ldap' class doesn't want to remove binary entries, so I need
881        to work around myself. */
882     if ($remove_userCertificate == true && !$this->is_new && $this->had_userCertificate){
884       /* Reset array, assemble new, this should be reworked */
885       $this->attrs= array();
886       $this->attrs['userCertificate;binary']= array();
888       /* Prepare connection */
889       if (!($ds = ldap_connect($this->config->current['SERVER']))) {
890         die ("Could not connect to LDAP server");
891       }
892       ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
893       if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
894         ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
895         ldap_set_rebind_proc($ds, array(&$this, "rebind"));
896       }
897       if(isset($config->current['TLS']) && $config->current['TLS'] == "true"){
898         ldap_start_tls($ds);
899       }
900       if (!($res = @ldap_bind($ds, $this->config->current['ADMIN'],
901               $this->config->current['PASSWORD']))) {
902         die ("Could not bind to LDAP");
903       }
905       /* Modify using attrs */
906       ldap_mod_del($ds,$this->dn,$this->attrs);
907       ldap_close($ds);
908     }
910     /* Kerberos server defined? */
911     if (isset($this->config->data['SERVERS']['KERBEROS'])){
912       $cfg= $this->config->data['SERVERS']['KERBEROS'];
913     }
914     if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
916       /* Connect to the admin interface */
917       $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
918           $cfg['ADMIN'], $cfg['PASSWORD']);
920       /* Errors? */             
921       if ($handle === FALSE){
922         print_red (_("Kerberos database communication failed"));
923         return (2);
924       }
926       /* Build user principal, get list of existsing principals */
927       $principal= $this->uid."@".$cfg['REALM'];
928       $principals = kadm5_get_principals($handle);
930       /* User exists in database? */
931       if (in_array($principal, $principals)){
933         /* Ok. User exists. Remove him/her when pw_storage has
934            changed to be NOT kerberos. */
935         if ($this->pw_storage != "kerberos"){
936           $ret= kadm5_delete_principal ( $handle, $principal);
938           if ($ret === FALSE){
939             print_red (_("Can't remove user from kerberos database."));
940           }
941         }
943       } else {
945         /* User doesn't exists, create it when pw_storage is kerberos. */
946         if ($this->pw_storage == "kerberos"){
947           $ret= kadm5_create_principal ( $handle, $principal);
949           if ($ret === FALSE){
950             print_red (_("Can't add user to kerberos database."));
951           }
952         }
954       }
956       /* Free kerberos admin handle */
957       kadm5_destroy($handle);
958     }
960     /* Optionally execute a command after we're done */
961     if ($mode == "add"){
962       $this->handle_post_events("add");
963     } elseif ($this->is_modified){
964       $this->handle_post_events("modify");
965     }
967     /* Fix tagging if needed */
968     $this->handle_object_tagging();
970     return (0);
971   }
974   /* Check formular input */
975   function check()
976   {
977     /* Call common method to give check the hook */
978     $message= plugin::check();
980     /* Assemble cn */
981     $this->cn= $this->givenName." ".$this->sn;
983     /* Permissions for that base? */
984     if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
985       $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
986     } else {
987       $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base;
988     }
990     if ($this->dn == "new" &&  !$this->acl_is_createable()){
991       $message[]= _("You have no permissions to create a user on this 'Base'.");
992     } elseif ($this->dn != $new_dn && $this->dn != "new"){
993       if (!$this->acl_is_writeable($this->dn, "user","create",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
994         $message[]= _("You have no permissions to move a user from the original 'Base'.");
995       }
996     }
998     /* must: sn, givenName, uid */
999     if ($this->sn == "" && ($this->acl_is_writeable("sn",(!is_object($this->parent) && !isset($_SESSION['edit'])) || ($this->is_new)))){
1000       $message[]= _("The required field 'Name' is not set.");
1001     }
1003     /* UID already used? */
1004     $ldap= $this->config->get_ldap_link();
1005     $ldap->cd($this->config->current['BASE']);
1006     $ldap->search("(uid=$this->uid)", array("uid"));
1007     $ldap->fetch();
1008     if ($ldap->count() != 0 && $this->dn == 'new'){
1009       $message[]= _("There's already a person with this 'Login' in the database.");
1010     }
1012     /* In template mode, the uid and givenName are autogenerated... */
1013     if (!$this->is_template){
1014       if ($this->givenName == "" && $this->acl_is_writeable("givenName",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1015         $message[]= _("The required field 'Given name' is not set.");
1016       }
1017       if ($this->uid == "" && $this->acl_is_writeable("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1018         $message[]= _("The required field 'Login' is not set.");
1019       }
1020       if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
1021         $ldap->cd($this->config->current['BASE']);
1022         $ldap->search("(cn=".$this->cn.")", array("uid"));
1023         $ldap->fetch();
1024         if ($ldap->count() != 0 && $this->dn != $new_dn && $this->dn == 'new'){
1025           $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
1026         }
1027       }
1028     }
1030     /* Check for valid input */
1031     if ($this->is_modified && !is_uid($this->uid)){
1032       $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed.");
1033     }
1034     if (!is_url($this->labeledURI)){
1035       $message[]= _("The field 'Homepage' contains an invalid URL definition.");
1036     }
1037     if (preg_match ("/[\\\\]/", $this->sn)){
1038       $message[]= _("The field 'Name' contains invalid characters.");
1039     }
1040     if (preg_match ("/[\\\\]/", $this->givenName)){
1041       $message[]= _("The field 'Given name' contains invalid characters.");
1042     }
1044     /* Check phone numbers */
1045     if (!is_phone_nr($this->telephoneNumber)){
1046       $message[]= _("The field 'Phone' contains an invalid phone number.");
1047     }
1048     if (!is_phone_nr($this->facsimileTelephoneNumber)){
1049       $message[]= _("The field 'Fax' contains an invalid phone number.");
1050     }
1051     if (!is_phone_nr($this->mobile)){
1052       $message[]= _("The field 'Mobile' contains an invalid phone number.");
1053     }
1054     if (!is_phone_nr($this->pager)){
1055       $message[]= _("The field 'Pager' contains an invalid phone number.");
1056     }
1058     /* Check for reserved characers */
1059     if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName)){
1060       $message[]= _("The field 'Given name' contains invalid characters.");
1061     }
1062     if (preg_match ('/[,+"?\'()=<>;]/', $this->sn)){
1063       $message[]= _("The field 'Name' contains invalid characters.");
1064     }
1066   return $message;
1067   }
1070   /* Indicate whether a password change is needed or not */
1071   function password_change_needed()
1072   {
1073     return ($this->pw_storage != $this->last_pw_storage);
1074   }
1077   /* Load a jpegPhoto from LDAP, this is going to be simplified later on */
1078   function load_picture()
1079   {
1080     /* make connection and read jpegPhoto */
1081     $ds= ldap_connect($this->config->current['SERVER']);
1082     ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
1083     if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
1084       ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
1085       ldap_set_rebind_proc($ds, array(&$this, "rebind"));
1086     }
1088     if(isset($this->config->current['TLS']) &&
1089         $this->config->current['TLS'] == "true"){
1091       ldap_start_tls($ds);
1092     }
1094     $r= ldap_bind($ds);
1095     $sr= @ldap_read($ds, $this->dn, "jpegPhoto=*", array("jpegPhoto"));
1097     /* in case we don't get an entry, load a default picture */
1098     $this->set_picture ("./images/default.jpg");
1099     $this->jpegPhoto= "*removed*";
1101     /* fill data from LDAP */
1102     if ($sr) {
1103       $ei=ldap_first_entry($ds, $sr);
1104       if ($ei) {
1105         if ($info = ldap_get_values_len($ds, $ei, "jpegPhoto")){
1106           $this->photoData= $info[0];
1107           $_SESSION['binary']= $this->photoData;
1108           $_SESSION['binarytype']= "image/jpeg";
1109           $this->jpegPhoto= "";
1110         }
1111       }
1112     }
1114     /* close conncetion */
1115     ldap_unbind($ds);
1116   }
1119   /* Load a certificate from LDAP, this is going to be simplified later on */
1120   function load_cert()
1121   {
1122     $ds= ldap_connect($this->config->current['SERVER']);
1123     ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
1124     if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
1125       ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
1126       ldap_set_rebind_proc($ds, array(&$this, "rebind"));
1127     }
1128     if(isset($this->config->current['TLS']) &&
1129         $this->config->current['TLS'] == "true"){
1131       ldap_start_tls($ds);
1132     }
1134     $r= ldap_bind($ds);
1135     $sr= @ldap_read($ds, $this->dn, "userCertificate=*", array("userCertificate"));
1137     if ($sr) {
1138       $ei= @ldap_first_entry($ds, $sr);
1139       
1140       if ($ei) {
1141         if (!$info = @ldap_get_values_len($ds, $ei, "userCertificate;binary")){
1142           $this->userCertificate= "";
1143         } else {
1144           $this->userCertificate= $info[0];
1145         }
1146       }
1147     } else {
1148       $this->userCertificate= "";
1149     }
1151     ldap_unbind($ds);
1152   }
1155   /* Load picture from file to object */
1156   function set_picture($filename)
1157   {
1158     if($this->acl_is_writeable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1159       if (!is_file($filename)){
1160         $filename= "./images/default.jpg";
1161         $this->jpegPhoto= "*removed*";
1162       }
1164       $fd = fopen ($filename, "rb");
1165       $this->photoData= fread ($fd, filesize ($filename));
1166       $_SESSION['binary']= $this->photoData;
1167       $_SESSION['binarytype']= "image/jpeg";
1168       $this->jpegPhoto= "";
1170       fclose ($fd);
1171     }
1172   }
1175   /* Load certificate from file to object */
1176   function set_cert($cert, $filename)
1177   {
1178     if(!$thsi->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))) return;
1179     $fd = fopen ($filename, "rb");
1180     if (filesize($filename)>0) {
1181       $this->$cert= fread ($fd, filesize ($filename));
1182       fclose ($fd);
1183       $this->is_modified= TRUE;
1184     } else {
1185       print_red(_("Could not open specified certificate!"));
1186     }
1187   }
1189   /* Adapt from given 'dn' */
1190   function adapt_from_template($dn)
1191   {
1192     plugin::adapt_from_template($dn);
1194     /* Get base */
1195     $this->base= preg_replace('/^[^,]+,'.get_people_ou().'/i', '', $dn);
1197     if ($this->config->current['GOVERNMENTMODE']){
1199       /* Walk through govattrs */
1200       foreach ($this->govattrs as $val){
1202         if (isset($this->attrs["$val"][0])){
1204           /* If attribute is set, replace dynamic parts: 
1205              %sn, %givenName and %uid. Fill these in our local variables. */
1206           $value= $this->attrs["$val"][0];
1208           foreach (array("sn", "givenName", "uid") as $repl){
1209             if (preg_match("/%$repl/i", $value)){
1210               $value= preg_replace ("/%$repl/i",
1211                   $this->parent->$repl, $value);
1212             }
1213           }
1214           $this->$val= $value;
1215         }
1216       }
1217     }
1219     /* Get back uid/sn/givenName */
1220     if ($this->parent != NULL){
1221       $this->uid= $this->parent->uid;
1222       $this->sn= $this->parent->sn;
1223       $this->givenName= $this->parent->givenName;
1224     }
1225   }
1227  
1228   /* This avoids that users move themselves out of their rights. 
1229    */
1230   function allowedBasesToMoveTo()
1231   {
1232     $allowed = array();
1233     $ret_all = false;
1234     if($this->uid == $_SESSION['ui']->username){
1235       $ldap= $this->config->get_ldap_link(); 
1236       $ldap->cd($this->config->current['BASE']); 
1237       $ldap->search("(&(objectClass=posixGroup)(memberUid=".$_SESSION['ui']->username."))",array("gosaSubtreeACL"));
1238        
1239       while($attrs = $ldap->fetch()){
1240     
1241         if(isset($attrs['gosaSubtreeACL'])){
1242         
1243           foreach($attrs['gosaSubtreeACL'] as $attr){
1244             if((preg_match("/:user#/",$attr))||(preg_match("/:all/",$attr))){
1245               $s =  preg_replace("/^.*ou=groups,/","",$attrs['dn']);
1247               foreach($this->config->idepartments as $key => $dep) {
1248                 if(preg_match("/".$s."/i",$key)){
1249                   $allowed[$key] = $dep;
1250                 }
1251               }
1252             }
1253           }
1254         }
1255       }
1256       if(count($allowed) == 0){
1257         foreach($this->config->idepartments as $key => $dep) {
1258           if($this->base==$key){
1259             $allowed[$key] = $dep;
1260           }
1261         }
1262       }  
1263   
1264       return($allowed);
1265       
1266     }else{
1267       return($this->config->idepartments);
1268     }
1269   } 
1272   function getCopyDialog()
1273   {
1274     $str = "";
1276     $_SESSION['binary'] = $this->photoData; 
1277     $_SESSION['binarytype']= "image/jpeg";
1279     /* Get random number for pictures */
1280     srand((double)microtime()*1000000); 
1281     $rand = rand(0, 10000);
1283     $smarty = get_smarty();
1285     $smarty->assign("passwordTodo","clear");
1287     if(isset($_POST['passwordTodo'])){
1288       $smarty->assign("passwordTodo",$_POST['passwordTodo']);
1289     }
1291     $smarty->assign("sn",       $this->sn);
1292     $smarty->assign("givenName",$this->givenName);
1293     $smarty->assign("uid",      $this->uid);
1294     $smarty->assign("rand",     $rand);
1295     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
1298     $ret = array();
1299     $ret['string'] = $str;
1300     $ret['status'] = "";  
1301     return($ret);
1302   }
1304   function saveCopyDialog()
1305   {
1307     if((isset($_FILES['picture_file']['tmp_name'])) && ($_FILES['picture_file']['size'] > 0)){
1308       $this->set_picture($_FILES['picture_file']['tmp_name']);
1309     }
1311     /* Remove picture? */
1312     if (isset($_POST['picture_remove'])){
1313       $this->jpegPhoto= "*removed*";
1314       $this->set_picture ("./images/default.jpg");
1315       $this->is_modified= TRUE;
1316     }
1318     $attrs = array("uid","givenName","sn");
1319     foreach($attrs as $attr){
1320       if(isset($_POST[$attr])){
1321         $this->$attr = $_POST[$attr];
1322       }
1323     } 
1324   }
1327   function plInfo()
1328   {
1329   
1330     $govattrs= array(
1331         "gouvernmentOrganizationalUnit"             =>  _("Unit"), 
1332         "houseIdentifier"                           =>  _("House identifier"), 
1333         "vocation"                                  =>  _("Vocation"),
1334         "ivbbLastDeliveryCollective"                =>  _("Last delivery"), 
1335         "gouvernmentOrganizationalPersonLocality"   =>  _("Person locality"),
1336         "gouvernmentOrganizationalUnitDescription"  =>  _("Unit description"),
1337         "gouvernmentOrganizationalUnitSubjectArea"  =>  _("Subject area"),
1338         "functionalTitle"                           =>  _("Functional title"),
1339         "certificateSerialNumber"                   =>  _(""),
1340         "publicVisible"                             =>  _("Public visible"),
1341         "street"                                    =>  _("Street"),
1342         "role"                                      =>  _("Role"),
1343         "postalCode"                                =>  _("Postal code"));
1345     $ret = array(
1346         "plShortName" => _("Generic"),
1347         "plDescription" => _("Generic user settings"),
1348         "plSelfModify"  => TRUE,
1349         "plDepends"     => array(),
1350         "plPriority"    => 0,
1351         "plSection"     => array("personal" => _("My account")),
1352         "plCategory"    => array("users" => array("description" => _("Users"),
1353                                                   "objectClass" => "gosaAccount")),
1355         "plProvidedAcls" => array(
1356           "base"              => _("Base"), 
1357           "userPassword"      => _("User password"), 
1358           "sn"                => _("Surename"),
1359           "givenName"         => _("Given name"),
1360           "uid"               => _("User identification"),
1361           "personalTitle"     => _("Personal title"),
1362           "academicTitle"     => _("Academic title"),
1363           "homePostalAddress" => _("Home postal address"),
1364           "homePhone"         => _("Home phone number"),
1365           "labeledURI"        => _("Homepage"),
1366           "o"                 => _("Organization"),
1367           "ou"                => _("Department"),
1368           "dateOfBirth"       => _("Date of birth"),
1369           "gender"            => _("Gender"),
1370           "preferredLanguage" => _("Preferred language"),
1371           "departmentNumber"  => _("Department number"),
1372           "employeeNumber"    => _("Employee number"),
1373           "employeeType"      => _("Employee type"),
1374           "l"                 => _("Location"),
1375           "st"                => _("State"),
1376           "userPicture"       => _("User picture"),
1377           "roomNumber"        => _("Room number"),
1378           "telephoneNumber"   => _("Telefon number"),
1379           "mobile"            => _("Mobile number"),
1380           "pager"             => _("Pager number"),
1381           "Certificate"        => _("User certificates"),
1383           "postalAddress"                => _("Postal address"),
1384           "facsimileTelephoneNumber"     => _("Fax number"))
1385         );
1387     /* Append government attributes if required */
1388       global $config;
1389     if (isset($config->current['GOVERNMENTMODE']) &&  preg_match('/true/i', $config->current['GOVERNMENTMODE'])){
1390       foreach($govattrs as $attr => $desc){
1391         $ret["plProvidedAcls"][$attr] = $desc;
1392       }
1393     }
1395     return($ret);
1396   }
1399 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1400 ?>