Code

Renamed blocklist management posts.
[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","jpegPhoto",
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       $this->load_picture();
178       if ($this->userCertificate != ""){
179         $this->had_userCertificate= TRUE;
180       }
181     }
183     /* Reset password storage indicator, used by password_change_needed() */
184     if ($dn == "new"){
185       $this->last_pw_storage= "unset";
186     } else {
187       $this->last_pw_storage= $this->pw_storage;
188     }
190     /* Generate dateOfBirth entry */
191     if (isset ($this->attrs['dateOfBirth'])){
192       /* This entry is ISO 8601 conform */
193       list($year, $month, $day)= split("-", $this->attrs['dateOfBirth'][0], 3);
194     
195       $this->dateOfBirth=array( 'mon'=> $month,"mday"=> $day,"year"=> $year);
196       $this->use_dob= "1";
197     } else {
198       $this->use_dob= "0";
199     }
201     /* Put gender attribute to upper case */
202     if (isset ($this->attrs['gender'])){
203       $this->gender= strtoupper($this->attrs['gender'][0]);
204     }
205   }
208   /* execute generates the html output for this node */
209   function execute()
210   {
211     /* Call parent execute */
212     plugin::execute();
214     $smarty= get_smarty();
216     /* Fill calendar */
217     if ($this->dateOfBirth == "0"){
218       $date= getdate();
219     } else {
220       if(is_array($this->dateOfBirth)){
221         $date = $this->dateOfBirth;
222       }else{
223         $date = getdate($this->dateOfBirth);
224       }
225     }
227     $days= array();
228     for($d= 1; $d<32; $d++){
229       $days[$d]= $d;
230     }
231     $years= array();
233     if(($date['year']-100)<1901){
234       $start = 1901;
235     }else{
236       $start = $date['year']-100;
237     }
239     $end = $start +100;
240     
241     for($y= $start; $y<=$end; $y++){
242       $years[]= $y;
243     }
244     $years['-']= "-&nbsp;";
245     $months= array(_("January"), _("February"), _("March"), _("April"),
246         _("May"), _("June"), _("July"), _("August"), _("September"),
247         _("October"), _("November"), _("December"), '-' => '-&nbsp;');
248     $smarty->assign("day", $date["mday"]);
249     $smarty->assign("days", $days);
250     $smarty->assign("months", $months);
251     $smarty->assign("month", $date["mon"]-1);
252     $smarty->assign("years", $years);
253     $smarty->assign("year", $date["year"]);
255     /* Assign sex */
256     $sex= array(0 => "&nbsp;", "F" => _("female"), "M" => _("male"));
257     $smarty->assign("gender_list", $sex);
259     /* Assign prefered langage */
260     $language= array(0 => "&nbsp;", "fr_FR" => ("fr_FR"), "en_EN" => ("en_EN"), 
261                                     "de_DE" => ("de_DE"), "it_IT" => ("it_IT"), 
262                                     "nl_NL" => ("nl_NL"), "ru_RU" => ("ru_RU"));
263     $smarty->assign("preferredLanguage_list", $language);
265     /* Get random number for pictures */
266     srand((double)microtime()*1000000); 
267     $smarty->assign("rand", rand(0, 10000));
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()){
296         /* check if selected base is allowed to move to / create a new object */
297         $tmp = $this->get_allowed_bases();
298         if(isset($tmp[$this->dialog->isSelected()])){
299           $this->base = $this->dialog->isSelected();
300         }
301         $this->dialog= false;
302       }else{
303         return($this->dialog->execute());
304       }
305     }
307     /* Want picture edit dialog? */
308     if($this->acl_is_writeable("userPicture")) {
309       if (isset($_POST['edit_picture'])){
310         /* Save values for later recovery, in case some presses
311            the cancel button. */
312         $this->old_jpegPhoto= $this->jpegPhoto;
313         $this->old_photoData= $this->photoData;
314         $this->picture_dialog= TRUE;
315         $this->dialog= TRUE;
316       }
317     }
319     /* Remove picture? */
320     if($this->acl_is_writeable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))) ){
321       if (isset($_POST['picture_remove'])){
322         $this->set_picture ();
323         $this->jpegPhoto= "*removed*";
324         $this->is_modified= TRUE;
325         return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
326       }
327     }
329     /* Save picture */
330     if (isset($_POST['picture_edit_finish'])){
332       /* Check for clean upload */
333       if ($_FILES['picture_file']['name'] != ""){
334         if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) {
335           print_red(_("The specified file has not been uploaded via HTTP POST! Aborted."));
336         }else{
337           /* Activate new picture */
338           $this->set_picture($_FILES['picture_file']['tmp_name']);
339         }
340       }
341       $this->picture_dialog= FALSE;
342       $this->dialog= FALSE;
343       $this->is_modified= TRUE;
344     }
347     /* Cancel picture */
348     if (isset($_POST['picture_edit_cancel'])){
350       /* Restore values */
351       $this->jpegPhoto= $this->old_jpegPhoto;
352       $this->photoData= $this->old_photoData;
354       /* Update picture */
355       $_SESSION['binary']= $this->photoData;
356       $_SESSION['binarytype']= "image/jpeg";
357       $this->picture_dialog= FALSE;
358       $this->dialog= FALSE;
359     }
361     /* Toggle dateOfBirth information */
362     if (isset($_POST['set_dob'])){
363       $this->use_dob= ($this->use_dob == "0")?"1":"0";
364     }
367     /* Want certificate= */
368     if ((isset($_POST['edit_cert'])) && $this->acl_is_readable("Certificate")){
370       /* Save original values for later reconstruction */
371       foreach (array("certificateSerialNumber", "userCertificate",
372             "userSMIMECertificate", "userPKCS12") as $val){
374         $oval= "old_$val";
375         $this->$oval= $this->$val;
376       }
378       $this->cert_dialog= TRUE;
379       $this->dialog= TRUE;
380     }
383     /* Cancel certificate dialog */
384     if (isset($_POST['cert_edit_cancel'])){
386       /* Restore original values in case of 'cancel' */
387       foreach (array("certificateSerialNumber", "userCertificate",
388             "userSMIMECertificate", "userPKCS12") as $val){
390         $oval= "old_$val";
391         $this->$val= $this->$oval;
392       }
393       $this->cert_dialog= FALSE;
394       $this->dialog= FALSE;
395     }
398     /* Remove certificate? */
399     if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){ 
400       foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") as $val){
401         if (isset($_POST["remove_$val"])){
403           /* Reset specified cert*/
404           $this->$val= "";
405           $this->is_modified= TRUE;
406         }
407       }
408     }
410     /* Upload new cert and close dialog? */     
411     if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){ 
412       if (isset($_POST['cert_edit_finish'])){
414         /* for all certificates do */
415         foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12")
416             as $val){
418           /* Check for clean upload */
419           if (array_key_exists($val."_file", $_FILES) &&
420               array_key_exists('name', $_FILES[$val."_file"]) &&
421               $_FILES[$val."_file"]['name'] != "" &&
422               is_uploaded_file($_FILES[$val."_file"]['tmp_name'])) {
423             $this->set_cert("$val", $_FILES[$val."_file"]['tmp_name']);
424           }
425         }
427         /* Save serial number */
428         if (isset($_POST["certificateSerialNumber"]) &&
429             $_POST["certificateSerialNumber"] != ""){
431           if (!is_id($_POST["certificateSerialNumber"])){
432             print_red (_("Please enter a valid serial number"));
434             foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
435               if ($this->$cert != ""){
436                 $smarty->assign("$cert"."_state", "true");
437               } else {
438                 $smarty->assign("$cert"."_state", "");
439               }
440             }
441             return ($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
442           }
444           $this->certificateSerialNumber= $_POST["certificateSerialNumber"];
445           $this->is_modified= TRUE;
446         }
448         $this->cert_dialog= FALSE;
449         $this->dialog= FALSE;
450       }
451     }
452     /* Display picture dialog */
453     if ($this->picture_dialog){
454       return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
455     }
457     /* Display cert dialog */
458     if ($this->cert_dialog){
459       $smarty->assign("CertificateACL",$this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
460       $smarty->assign("Certificate_readable",$this->acl_is_readable("Certificate"));
462       foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
463         if ($this->$cert != ""){
464           /* import certificate */
465           $certificate = new certificate;
466           $certificate->import($this->$cert);
467       
468           /* Read out data*/
469           $timeto   = $certificate->getvalidto_date();
470           $timefrom = $certificate->getvalidfrom_date();
471          
472           
473           /* Additional info if start end time is '0' */
474           $add_str_info = "";
475           if($timeto == 0 && $timefrom == 0){
476             $add_str_info = "<br><i>"._("(Some types of certificates are currently not supported and may be displayed as 'invalid'.)")."</i>";
477           }
479           $str = "<table summary=\"\" border=0>
480                     <tr>
481                       <td style='vertical-align:top'>CN</td>
482                       <td>".preg_replace("/ /", "&nbsp;", $certificate->getname())."</td>
483                     </tr>
484                   </table><br>".
486                   sprintf(_("Certificate is valid from %s to %s and is currently %s."),
487                         "<b>".date('d M Y',$timefrom)."</b>",
488                         "<b>".date('d M Y',$timeto)."</b>",
489                         $certificate->isvalid()?"<b><font style='color:green'>"._("valid")."</font></b>":
490                                                 "<b><font style='color:red'>"._("invalid")."</font></b>").$add_str_info;
492           $smarty->assign($cert."info",$str);
493           $smarty->assign($cert."_state","true");
494         } else {
495           $smarty->assign($cert."info", "<i>"._("No certificate installed")."</i>");
496           $smarty->assign($cert."_state","");
497         }
498       }
499       $smarty->assign("governmentmode", "false");
500       return($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
501     }
503     /* Prepare password hashes */
504     if ($this->pw_storage == ""){
505       $this->pw_storage= $this->config->current['HASH'];
506     }
508     $temp   = @passwordMethod::get_available_methods();
509     $hashes = $temp['name'];
510     
511     /* Load attributes and acl's */
512     $ui =get_userinfo();
513     foreach($this->attributes as $val){
514       $smarty->assign("$val", $this->$val);
515     }
517     /* Set acls */
518     $tmp = $this->plinfo();
519     foreach($tmp['plProvidedAcls'] as $val => $translation){
520       $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
521     }
523     $smarty->assign("pwmode", $hashes);
524     $smarty->assign("pwmode_select", $this->pw_storage);
525     $smarty->assign("passwordStorageACL", $this->getacl("userPassword",(!is_object($this->parent) && !isset($_SESSION['edit']))));
526     $smarty->assign("base_select",      $this->base);
527     $smarty->assign("CertificatesACL",  $this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
528     $smarty->assign("userPictureACL",   $this->getacl("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
529     $smarty->assign("userPicture_is_readable",   $this->acl_is_readable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
531     /* Create base acls */
532     @$smarty->assign("bases", $this->allowedBasesToMoveTo());
534     /* Save government mode attributes */
535     if (isset($this->config->current['GOVERNMENTMODE']) &&
536         preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){
537       $smarty->assign("governmentmode", "true");
538       $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet",
539           "internet,ivbv", "internet,testa", "internet,ivbv,testa");
540       $smarty->assign("ivbbmodes", $ivbbmodes);
541       foreach ($this->govattrs as $val){
542         $smarty->assign("$val", $this->$val);
543         $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
544       }
545     } else {
546       $smarty->assign("governmentmode", "false");
547     }
549     /* Special mode for uid */
550     $uidACL= $this->getacl("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])));
551     if (isset ($this->dn)){
552       if ($this->dn != "new"){
553         $uidACL= preg_replace("/w/","",$uidACL);
554       }
555     }  else {
556       $uidACL= preg_replace("/w/","",$uidACL);
557     }
558     
559     $smarty->assign("uidACL", $uidACL);
560     $smarty->assign("is_template", $this->is_template);
561     $smarty->assign("use_dob", $this->use_dob);
563     if (isset($this->parent)){
564       if (isset($this->parent->by_object['phoneAccount']) &&
565           $this->parent->by_object['phoneAccount']->is_account){
566         $smarty->assign("has_phoneaccount", "true");
567       } else {
568         $smarty->assign("has_phoneaccount", "false");
569       }
570     } else {
571       $smarty->assign("has_phoneaccount", "false");
572     }
573     return($smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))));
574   }
577   /* remove object from parent */
578   function remove_from_parent()
579   {
580     $ldap= $this->config->get_ldap_link();
581     $ldap->rmdir ($this->dn);
582     show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/generic account with dn '%s' failed."),$this->dn));
584     /* Delete references to groups */
585     $ldap->cd ($this->config->current['BASE']);
586     $ldap->search ("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("uid"));
587     while ($ldap->fetch()){
588       $g= new group($this->config, $ldap->getDN());
589       $g->removeUser($this->uid);
590       $g->save ();
591     }
593     /* Delete references to object groups */
594     $ldap->cd ($this->config->current['BASE']);
595     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
596     while ($ldap->fetch()){
597       $og= new ogroup($this->config, $ldap->getDN());
598       unset($og->member[$this->dn]);
599       $og->save ();
600     }
602     /* Kerberos server defined? */
603     if (isset($this->config->data['SERVERS']['KERBEROS'])){
604       $cfg= $this->config->data['SERVERS']['KERBEROS'];
605     }
606     if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
608       /* Connect to the admin interface */
609       $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
610           $cfg['ADMIN'], $cfg['PASSWORD']);
612       /* Errors? */             
613       if ($handle === FALSE){
614         print_red (_("Kerberos database communication failed"));
615         return (2);
616       }
618       /* Build user principal, get list of existsing principals */
619       $principal= $this->uid."@".$cfg['REALM'];
620       $principals = kadm5_get_principals($handle);
622       /* User exists in database? */
623       if (in_array($principal, $principals)){
625         /* Ok. User exists. Remove him/her */
626           $ret= kadm5_delete_principal ( $handle, $principal);
627           if ($ret === FALSE){
628             print_red (_("Can't remove user from kerberos database."));
629           }
630       }
632       /* Free kerberos admin handle */
633       kadm5_destroy($handle);
634     }
637     /* Optionally execute a command after we're done */
638     $this->handle_post_events("remove",array("uid" => $this->uid));
639   }
642   /* Save data to object */
643   function save_object()
644   {
645     if (isset($_POST['generic'])){
647       /* Make a backup of the current selected base */
648       $base_tmp = $this->base;
650       /* Parents save function */
651       plugin::save_object ();
653       /* Save government mode attributes */
654       if ($this->config->current['GOVERNMENTMODE']){
655         foreach ($this->govattrs as $val){
656           if ($this->acl_is_writeable($val,(!is_object($this->parent) && !isset($_SESSION['edit']))) && isset($_POST["$val"])){
657             $data= stripcslashes($_POST["$val"]);
658             if ($data != $this->$val){
659               $this->is_modified= TRUE;
660             }
661             $this->$val= $data;
662           }
663         }
664       }
666       /* In template mode, the uid is autogenerated... */
667       if ($this->is_template){
668         $this->uid= strtolower($this->sn);
669         $this->givenName= $this->sn;
670       }
672       /* Save base and pw_storage, since these are no LDAP attributes */
673       if (isset($_POST['base'])){
675         $tmp = $this->get_allowed_bases();
676         if(isset($tmp[$_POST['base']])){
677           $base= validate($_POST['base']);
678           if ($base != $this->base){
679             $this->is_modified= TRUE;
680           }
681           $this->base= $base;
682         }else{
683           $this->base = $base_tmp;
684           print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base'])));
685           $this->set_acl_base('dummy,'.$this->base);
686         }
687       }
689       /* Get pw_storage mode */
690       if (isset($_POST['pw_storage'])){
691         foreach(array("pw_storage") as $val){
692           if(isset($_POST[$val])){
693             $data= validate($_POST[$val]);
694             if ($data != $this->$val){
695               $this->is_modified= TRUE;
696             }
697             $this->$val= $data;
698           }
699         }
700       }
702       $this->set_acl_base('dummy,'.$this->base);
703     }
704   }
706   function rebind($ldap, $referral)
707   {
708     $credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']);
709     if (ldap_bind($ldap, $credentials['ADMIN'], $credentials['PASSWORD'])) {
710       $this->error = "Success";
711       $this->hascon=true;
712       $this->reconnect= true;
713       return (0);
714     } else {
715       $this->error = "Could not bind to " . $credentials['ADMIN'];
716       return NULL;
717     }
718   }
720   /* Save data to LDAP, depending on is_account we save or delete */
721   function save()
722   {
723     /* Only force save of changes .... 
724        If this attributes aren't changed, avoid saving.
725      */
726     if($this->gender=="0") $this->gender ="";
727     if($this->preferredLanguage=="0") $this->preferredLanguage ="";
728     
729  
730     /* First use parents methods to do some basic fillup in $this->attrs */
731     plugin::save ();
733     if ($this->use_dob == "1"){
734       /* If it is an array, the generic page has never been loaded - so there's no difference. Using an array would cause an error btw. */
735       if(!is_array($this->attrs['dateOfBirth'])) {
736         $this->attrs['dateOfBirth'] = date("Y-m-d", $this->dateOfBirth);
737       }
738     }
740     /* Remove additional objectClasses */
741     $tmp= array();
742     foreach ($this->attrs['objectClass'] as $key => $set){
743       $found= false;
744       foreach (array("ivbbentry", "gosaUserTemplate") as $val){
745         if (preg_match ("/^$set$/i", $val)){
746           $found= true;
747           break;
748         }
749       }
750       if (!$found){
751         $tmp[]= $set;
752       }
753     }
755     /* Replace the objectClass array. This is done because of the
756        separation into government and normal mode. */
757     $this->attrs['objectClass']= $tmp;
759     /* Add objectClasss for template mode? */
760     if ($this->is_template){
761       $this->attrs['objectClass'][]= "gosaUserTemplate";
762     }
764     /* Hard coded government mode? */
765     if ($this->config->current['GOVERNMENTMODE'] != 'false'){
766       $this->attrs['objectClass'][]= "ivbbentry";
768       /* Copy standard attributes */
769       foreach ($this->govattrs as $val){
770         if ($this->$val != ""){
771           $this->attrs["$val"]= $this->$val;
772         } elseif (!$this->is_new) {
773           $this->attrs["$val"]= array();
774         }
775       }
777       /* Remove attribute if set to "nein" */
778       if ($this->publicVisible == "nein"){
779         $this->attrs['publicVisible']= array();
780         if($this->is_new){
781           unset($this->attrs['publicVisible']);
782         }else{
783           $this->attrs['publicVisible']=array();
784         }
786       }
788     }
790     /* Special handling for attribute userCertificate needed */
791     if ($this->userCertificate != ""){
792       $this->attrs["userCertificate;binary"]= $this->userCertificate;
793       $remove_userCertificate= false;
794     } else {
795       $remove_userCertificate= true;
796     }
798     /* Special handling for dateOfBirth value */
799     if ($this->use_dob != "1"){
800       if ($this->is_new) {
801         unset($this->attrs["dateOfBirth"]);
802       } else {
803         $this->attrs["dateOfBirth"]= array();
804       }
805     }
806     if (!$this->gender){
807       if ($this->is_new) {
808         unset($this->attrs["gender"]);
809       } else {
810         $this->attrs["gender"]= array();
811       }
812     }
813     if (!$this->preferredLanguage){
814       if ($this->is_new) {
815         unset($this->attrs["preferredLanguage"]);
816       } else {
817         $this->attrs["preferredLanguage"]= array();
818       }
819     }
821     /* Special handling for attribute jpegPhote needed, scale image via
822        image magick to 147x200 pixels and inject resulting data. */
823     if ($this->jpegPhoto == "*removed*"){
824     
825       /* Reset attribute to avoid writing *removed* as value */    
826       $this->attrs["jpegPhoto"] = array();
828     } else {
830       /* Fallback if there's no image magick inside PHP */
831       if (!function_exists("imagick_blob2image")){
832         /* Get temporary file name for conversation */
833         $fname = tempnam ("/tmp", "GOsa");
835         /* Open file and write out photoData */
836         $fp = fopen ($fname, "w");
837         fwrite ($fp, $this->photoData);
838         fclose ($fp);
840         /* Build conversation query. Filename is generated automatically, so
841            we do not need any special security checks. Exec command and save
842            output. For PHP safe mode, you'll need a configuration which respects
843            image magick as executable... */
844         $query= "convert -size 147x200 $fname -resize 147x200 +profile \"*\" -";
845         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
846             $query, "Execute");
848         /* Read data written by convert */
849         $output= "";
850         $sh= popen($query, 'r');
851         while (!feof($sh)){
852           $output.= fread($sh, 4096);
853         }
854         pclose($sh);
856         unlink($fname);
858         /* Save attribute */
859         $this->attrs["jpegPhoto"] = $output;
861       } else {
863         /* Load the new uploaded Photo */
864         if(!$handle  =  imagick_blob2image($this->photoData))  {
865           gosa_log("Can't Load image");
866         }
868         /* Resizing image to 147x200 and blur */
869         if(!imagick_resize($handle,147,200,IMAGICK_FILTER_GAUSSIAN,0)){
870           gosa_log("imagick_resize failed");
871         }
873         /* Converting image to JPEG */
874         if(!imagick_convert($handle,"JPEG")) {
875           gosa_log("Can't Convert to JPEG");
876         }
878         /* Creating binary Code for the Image */
879         if(!$dump = imagick_image2blob($handle)){
880           gosa_log("Can't create blob for image");
881         }
883         /* Sending Image */
884         $output=  $dump;
886         /* Save attribute */
887         $this->attrs["jpegPhoto"] = $output;
888       }
890     }
892     /* Build new dn */
893     if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
894       $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
895     } else {
896       $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base;
897     }
899     /* This only gets called when user is renaming himself */
900     $ldap= $this->config->get_ldap_link();
901     if ($this->dn != $new_dn){
903       /* Write entry on new 'dn' */
904       $this->move($this->dn, $new_dn);
906       /* Happen to use the new one */
907       change_ui_dn($this->dn, $new_dn);
908       $this->dn= $new_dn;
909     }
912     /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
913        new entries. So do a check first... */
914     $ldap->cat ($this->dn, array('dn'));
915     if ($ldap->fetch()){
916       $mode= "modify";
917     } else {
918       $mode= "add";
919       $ldap->cd($this->config->current['BASE']);
920       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
921     }
923     /* Set password to some junk stuff in case of templates */
924     if ($this->is_template){
925       $this->attrs['userPassword']= '{crypt}N0T$3T4N0W';
926     }
928     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
929         $this->attributes, "Save via $mode");
931     /* Finally write data with selected 'mode' */
932     $this->cleanup();
933     $ldap->cd ($this->dn);
934     $ldap->$mode ($this->attrs);
935     if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/generic account with dn '%s' failed."),$this->dn))){
936       return (1);
937     }
939     /* Remove cert? 
940        For some reason, the 'ldap' class doesn't want to remove binary entries, so I need
941        to work around myself. */
942     if ($remove_userCertificate == true && !$this->is_new && $this->had_userCertificate){
944       /* Reset array, assemble new, this should be reworked */
945       $this->attrs= array();
946       $this->attrs['userCertificate;binary']= array();
948       /* Prepare connection */
949       if (!($ds = ldap_connect($this->config->current['SERVER']))) {
950         die ("Could not connect to LDAP server");
951       }
952       ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
953       if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
954         ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
955         ldap_set_rebind_proc($ds, array(&$this, "rebind"));
956       }
957       if(isset($config->current['TLS']) && $config->current['TLS'] == "true"){
958         ldap_start_tls($ds);
959       }
960       if (!($res = @ldap_bind($ds, $this->config->current['ADMIN'],
961               $this->config->current['PASSWORD']))) {
962         die ("Could not bind to LDAP");
963       }
965       /* Modify using attrs */
966       ldap_mod_del($ds,$this->dn,$this->attrs);
967       ldap_close($ds);
968     }
970     /* Kerberos server defined? */
971     if (isset($this->config->data['SERVERS']['KERBEROS'])){
972       $cfg= $this->config->data['SERVERS']['KERBEROS'];
973     }
974     if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
976       /* Connect to the admin interface */
977       $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
978           $cfg['ADMIN'], $cfg['PASSWORD']);
980       /* Errors? */             
981       if ($handle === FALSE){
982         print_red (_("Kerberos database communication failed"));
983         return (2);
984       }
986       /* Build user principal, get list of existsing principals */
987       $principal= $this->uid."@".$cfg['REALM'];
988       $principals = kadm5_get_principals($handle);
990       /* User exists in database? */
991       if (in_array($principal, $principals)){
993         /* Ok. User exists. Remove him/her when pw_storage has
994            changed to be NOT kerberos. */
995         if ($this->pw_storage != $this->config->current['KRBSASL']){
996           $ret= kadm5_delete_principal ( $handle, $principal);
998           if ($ret === FALSE){
999             print_red (_("Can't remove user from kerberos database."));
1000           }
1001         }
1003       } else {
1005         /* User doesn't exists, create it when pw_storage is kerberos. */
1006         if ($this->pw_storage == "kerberos" || $this->pw_storage == "sasl" ){
1007           $ret= kadm5_create_principal ( $handle, $principal);
1009           if ($ret === FALSE){
1010             print_red (_("Can't add user to kerberos database."));
1011           }
1012         }
1014       }
1016       /* Free kerberos admin handle */
1017       kadm5_destroy($handle);
1018     }
1020     /* Optionally execute a command after we're done */
1021     if ($mode == "add"){
1022       $this->handle_post_events("add", array("uid" => $this->uid));
1023     } elseif ($this->is_modified){
1024       $this->handle_post_events("modify", array("uid" => $this->uid));
1025     }
1027     /* Fix tagging if needed */
1028     $this->handle_object_tagging();
1030     return (0);
1031   }
1034   /* Check formular input */
1035   function check()
1036   {
1037     /* Call common method to give check the hook */
1038     $message= plugin::check();
1040     /* Assemble cn */
1041     $this->cn= $this->givenName." ".$this->sn;
1043     /* Permissions for that base? */
1044     if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
1045       $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
1046     } else {
1047       $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base;
1048     }
1050     /* Set the new acl base */
1051     if($this->dn == "new") {
1052       $this->set_acl_base($this->base);
1053     }
1055     /* must: sn, givenName, uid */
1056     if ($this->sn == "" && ($this->acl_is_writeable("sn",(!is_object($this->parent) && !isset($_SESSION['edit'])) || ($this->is_new)))){
1057       $message[]= _("The required field 'Name' is not set.");
1058     }
1060     /* UID already used? */
1061     $ldap= $this->config->get_ldap_link();
1062     $ldap->cd($this->config->current['BASE']);
1063     $ldap->search("(uid=$this->uid)", array("uid"));
1064     $ldap->fetch();
1065     if ($ldap->count() != 0 && $this->dn == 'new'){
1066       $message[]= _("There's already a person with this 'Login' in the database.");
1067     }
1069     /* In template mode, the uid and givenName are autogenerated... */
1070     if (!$this->is_template){
1071       if ($this->givenName == "" && $this->acl_is_writeable("givenName",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1072         $message[]= _("The required field 'Given name' is not set.");
1073       }
1074       if ($this->uid == "" && $this->acl_is_writeable("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1075         $message[]= _("The required field 'Login' is not set.");
1076       }
1077       if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
1078         $ldap->cd($this->config->current['BASE']);
1079         $ldap->search("(cn=".$this->cn.")", array("uid"));
1080         $ldap->fetch();
1081         if ($ldap->count() != 0 && $this->dn != $new_dn && $this->dn == 'new'){
1082           $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
1083         }
1084       }
1085     }
1087     /* Check for valid input */
1088     if ($this->is_modified && !is_uid($this->uid)){
1089       $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed.");
1090     }
1091     if (!is_url($this->labeledURI)){
1092       $message[]= _("The field 'Homepage' contains an invalid URL definition.");
1093     }
1094     if (preg_match ("/[\\\\]/", $this->sn)){
1095       $message[]= _("The field 'Name' contains invalid characters.");
1096     }
1097     if (preg_match ("/[\\\\]/", $this->givenName)){
1098       $message[]= _("The field 'Given name' contains invalid characters.");
1099     }
1101     /* Check phone numbers */
1102     if (!is_phone_nr($this->telephoneNumber)){
1103       $message[]= _("The field 'Phone' contains an invalid phone number.");
1104     }
1105     if (!is_phone_nr($this->facsimileTelephoneNumber)){
1106       $message[]= _("The field 'Fax' contains an invalid phone number.");
1107     }
1108     if (!is_phone_nr($this->mobile)){
1109       $message[]= _("The field 'Mobile' contains an invalid phone number.");
1110     }
1111     if (!is_phone_nr($this->pager)){
1112       $message[]= _("The field 'Pager' contains an invalid phone number.");
1113     }
1115     /* Check for reserved characers */
1116     if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName)){
1117       $message[]= _("The field 'Given name' contains invalid characters.");
1118     }
1119     if (preg_match ('/[,+"?\'()=<>;]/', $this->sn)){
1120       $message[]= _("The field 'Name' contains invalid characters.");
1121     }
1123   return $message;
1124   }
1127   /* Indicate whether a password change is needed or not */
1128   function password_change_needed()
1129   {
1130     return ($this->pw_storage != $this->last_pw_storage);
1131   }
1134   /* Load a jpegPhoto from LDAP, this is going to be simplified later on */
1135   function load_picture()
1136   {
1137     $ldap = $this->config->get_ldap_link();
1138     $ldap->cd ($this->dn);
1139     $data = $ldap->get_attribute($this->dn,"jpegPhoto");
1140       
1141     if((!$data) || ($data == "*removed*")){ 
1143       /* In case we don't get an entry, load a default picture */
1144       $this->set_picture ();//"./images/default.jpg");
1145       $this->jpegPhoto= "*removed*";
1146     }else{
1148       /* Set picture */
1149       $this->photoData= $data;
1150       $_SESSION['binary']= $this->photoData;
1151       $_SESSION['binarytype']= "image/jpeg";
1152       $this->jpegPhoto= "";
1153     }
1154   }
1157   /* Load a certificate from LDAP, this is going to be simplified later on */
1158   function load_cert()
1159   {
1160     $ds= ldap_connect($this->config->current['SERVER']);
1161     ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
1162     if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
1163       ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
1164       ldap_set_rebind_proc($ds, array(&$this, "rebind"));
1165     }
1166     if(isset($this->config->current['TLS']) &&
1167         $this->config->current['TLS'] == "true"){
1169       ldap_start_tls($ds);
1170     }
1172     $r= ldap_bind($ds);
1173     $sr= @ldap_read($ds, $this->dn, "userCertificate=*", array("userCertificate"));
1175     if ($sr) {
1176       $ei= @ldap_first_entry($ds, $sr);
1177       
1178       if ($ei) {
1179         if (!$info = @ldap_get_values_len($ds, $ei, "userCertificate;binary")){
1180           $this->userCertificate= "";
1181         } else {
1182           $this->userCertificate= $info[0];
1183         }
1184       }
1185     } else {
1186       $this->userCertificate= "";
1187     }
1189     ldap_unbind($ds);
1190   }
1193   /* Load picture from file to object */
1194   function set_picture($filename ="")
1195   {
1196     if (!is_file($filename) || $filename =="" ){
1197       $filename= "./images/default.jpg";
1198       $this->jpegPhoto= "*removed*";
1199     }
1201     $fd = fopen ($filename, "rb");
1202     $this->photoData= fread ($fd, filesize ($filename));
1203     $_SESSION['binary']= $this->photoData;
1204     $_SESSION['binarytype']= "image/jpeg";
1205     $this->jpegPhoto= "";
1207     fclose ($fd);
1208   }
1211   /* Load certificate from file to object */
1212   function set_cert($cert, $filename)
1213   {
1214     if(!$thsi->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))) return;
1215     $fd = fopen ($filename, "rb");
1216     if (filesize($filename)>0) {
1217       $this->$cert= fread ($fd, filesize ($filename));
1218       fclose ($fd);
1219       $this->is_modified= TRUE;
1220     } else {
1221       print_red(_("Could not open specified certificate!"));
1222     }
1223   }
1225   /* Adapt from given 'dn' */
1226   function adapt_from_template($dn)
1227   {
1228     plugin::adapt_from_template($dn);
1230     /* Get base */
1231     $this->base= preg_replace('/^[^,]+,'.get_people_ou().'/i', '', $dn);
1233     if ($this->config->current['GOVERNMENTMODE']){
1235       /* Walk through govattrs */
1236       foreach ($this->govattrs as $val){
1238         if (isset($this->attrs["$val"][0])){
1240           /* If attribute is set, replace dynamic parts: 
1241              %sn, %givenName and %uid. Fill these in our local variables. */
1242           $value= $this->attrs["$val"][0];
1244           foreach (array("sn", "givenName", "uid") as $repl){
1245             if (preg_match("/%$repl/i", $value)){
1246               $value= preg_replace ("/%$repl/i",
1247                   $this->parent->$repl, $value);
1248             }
1249           }
1250           $this->$val= $value;
1251         }
1252       }
1253     }
1255     /* Get back uid/sn/givenName */
1256     if ($this->parent != NULL){
1257       $this->uid= $this->parent->uid;
1258       $this->sn= $this->parent->sn;
1259       $this->givenName= $this->parent->givenName;
1260     }
1261   }
1263  
1264   /* This avoids that users move themselves out of their rights. 
1265    */
1266   function allowedBasesToMoveTo()
1267   {
1268     /* Get bases */
1269     $bases  = $this->get_allowed_bases();
1270     return($bases);
1271   } 
1274   function getCopyDialog()
1275   {
1276     $str = "";
1278     $_SESSION['binary'] = $this->photoData; 
1279     $_SESSION['binarytype']= "image/jpeg";
1281     /* Get random number for pictures */
1282     srand((double)microtime()*1000000); 
1283     $rand = rand(0, 10000);
1285     $smarty = get_smarty();
1287     $smarty->assign("passwordTodo","clear");
1289     if(isset($_POST['passwordTodo'])){
1290       $smarty->assign("passwordTodo",$_POST['passwordTodo']);
1291     }
1293     $smarty->assign("sn",       $this->sn);
1294     $smarty->assign("givenName",$this->givenName);
1295     $smarty->assign("uid",      $this->uid);
1296     $smarty->assign("rand",     $rand);
1297     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
1300     $ret = array();
1301     $ret['string'] = $str;
1302     $ret['status'] = "";  
1303     return($ret);
1304   }
1306   function saveCopyDialog()
1307   {
1308     /* Set_acl_base */
1309     $this->set_acl_base("cn=dummy,".get_people_ou().$this->base);
1311     if((isset($_FILES['picture_file']['tmp_name'])) && ($_FILES['picture_file']['size'] > 0)){
1312       $this->set_picture($_FILES['picture_file']['tmp_name']);
1313     }
1315     /* Remove picture? */
1316     if (isset($_POST['picture_remove'])){
1317       $this->jpegPhoto= "*removed*";
1318       $this->set_picture ("./images/default.jpg");
1319       $this->is_modified= TRUE;
1320     }
1322     $attrs = array("uid","givenName","sn");
1323     foreach($attrs as $attr){
1324       if(isset($_POST[$attr])){
1325         $this->$attr = $_POST[$attr];
1326       }
1327     } 
1328   }
1331   function PrepareForCopyPaste($source)
1332   {
1333     plugin::PrepareForCopyPaste($source);
1335     /* Reset certificate information addepted from source user
1336        to avoid setting the same user certificate for the destination user. */
1337     $this->userPKCS12= "";
1338     $this->userSMIMECertificate= "";
1339     $this->userCertificate= "";
1340     $this->certificateSerialNumber= "";
1341     $this->old_certificateSerialNumber= "";
1342     $this->old_userPKCS12= "";
1343     $this->old_userSMIMECertificate= "";
1344     $this->old_userCertificate= "";
1345   }
1348   function plInfo()
1349   {
1350   
1351     $govattrs= array(
1352         "gouvernmentOrganizationalUnit"             =>  _("Unit"), 
1353         "houseIdentifier"                           =>  _("House identifier"), 
1354         "vocation"                                  =>  _("Vocation"),
1355         "ivbbLastDeliveryCollective"                =>  _("Last delivery"), 
1356         "gouvernmentOrganizationalPersonLocality"   =>  _("Person locality"),
1357         "gouvernmentOrganizationalUnitDescription"  =>  _("Unit description"),
1358         "gouvernmentOrganizationalUnitSubjectArea"  =>  _("Subject area"),
1359         "functionalTitle"                           =>  _("Functional title"),
1360         "certificateSerialNumber"                   =>  _(""),
1361         "publicVisible"                             =>  _("Public visible"),
1362         "street"                                    =>  _("Street"),
1363         "role"                                      =>  _("Role"),
1364         "postalCode"                                =>  _("Postal code"));
1366     $ret = array(
1367         "plShortName" => _("Generic"),
1368         "plDescription" => _("Generic user settings"),
1369         "plSelfModify"  => TRUE,
1370         "plDepends"     => array(),
1371         "plPriority"    => 1,
1372         "plSection"     => array("personal" => _("My account")),
1373         "plCategory"    => array("users" => array("description" => _("Users"),
1374                                                   "objectClass" => "gosaAccount")),
1376         "plProvidedAcls" => array(
1377           "base"              => _("Base"), 
1378           "userPassword"      => _("User password"), 
1379           "sn"                => _("Surename"),
1380           "givenName"         => _("Given name"),
1381           "uid"               => _("User identification"),
1382           "personalTitle"     => _("Personal title"),
1383           "academicTitle"     => _("Academic title"),
1384           "homePostalAddress" => _("Home postal address"),
1385           "homePhone"         => _("Home phone number"),
1386           "labeledURI"        => _("Homepage"),
1387           "o"                 => _("Organization"),
1388           "ou"                => _("Department"),
1389           "dateOfBirth"       => _("Date of birth"),
1390           "gender"            => _("Gender"),
1391           "preferredLanguage" => _("Preferred language"),
1392           "departmentNumber"  => _("Department number"),
1393           "employeeNumber"    => _("Employee number"),
1394           "employeeType"      => _("Employee type"),
1395           "l"                 => _("Location"),
1396           "st"                => _("State"),
1397           "userPicture"       => _("User picture"),
1398           "roomNumber"        => _("Room number"),
1399           "telephoneNumber"   => _("Telefon number"),
1400           "mobile"            => _("Mobile number"),
1401           "pager"             => _("Pager number"),
1402           "Certificate"        => _("User certificates"),
1404           "postalAddress"                => _("Postal address"),
1405           "facsimileTelephoneNumber"     => _("Fax number"))
1406         );
1408     /* Append government attributes if required */
1409       global $config;
1410     if (isset($config->current['GOVERNMENTMODE']) &&  preg_match('/true/i', $config->current['GOVERNMENTMODE'])){
1411       foreach($govattrs as $attr => $desc){
1412         $ret["plProvidedAcls"][$attr] = $desc;
1413       }
1414     }
1416     return($ret);
1417   }
1420 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1421 ?>