Code

ACL: Skip listing system snapshot that we are not able to restore.
[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       $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
516     }
518     $smarty->assign("pwmode", $hashes);
519     $smarty->assign("pwmode_select", $this->pw_storage);
520     $smarty->assign("passwordStorageACL", $this->getacl("userPassword",(!is_object($this->parent) && !isset($_SESSION['edit']))));
521     $smarty->assign("base_select",      $this->base);
522     $smarty->assign("CertificatesACL",  $this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
523     $smarty->assign("userPictureACL",   $this->getacl("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
524     $smarty->assign("userPicture_is_readable",   $this->acl_is_readable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
526     /* Create base acls */
527     $smarty->assign("baseACL",$this->getacl("base",(!is_object($this->parent) && !isset($_SESSION['edit']))));
528     @$smarty->assign("bases", $this->allowedBasesToMoveTo());
530     /* Save government mode attributes */
531     if (isset($this->config->current['GOVERNMENTMODE']) &&
532         preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){
533       $smarty->assign("governmentmode", "true");
534       $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet",
535           "internet,ivbv", "internet,testa", "internet,ivbv,testa");
536       $smarty->assign("ivbbmodes", $ivbbmodes);
537       foreach ($this->govattrs as $val){
538         $smarty->assign("$val", $this->$val);
539         $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
540       }
541     } else {
542       $smarty->assign("governmentmode", "false");
543     }
545     /* Special mode for uid */
546     $uidACL= $this->getacl("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])));
547     if (isset ($this->dn)){
548       if ($this->dn != "new"){
549         $uidACL= preg_replace("/w/","",$uidACL);
550       }
551     }  else {
552       $uidACL= preg_replace("/w/","",$uidACL);
553     }
554     
555     $smarty->assign("uidACL", $uidACL);
556     $smarty->assign("is_template", $this->is_template);
557     $smarty->assign("use_dob", $this->use_dob);
559     if (isset($this->parent)){
560       if (isset($this->parent->by_object['phoneAccount']) &&
561           $this->parent->by_object['phoneAccount']->is_account){
562         $smarty->assign("has_phoneaccount", "true");
563       } else {
564         $smarty->assign("has_phoneaccount", "false");
565       }
566     } else {
567       $smarty->assign("has_phoneaccount", "false");
568     }
569     return($smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))));
570   }
573   /* remove object from parent */
574   function remove_from_parent()
575   {
576     $ldap= $this->config->get_ldap_link();
577     $ldap->rmdir ($this->dn);
578     show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/generic account with dn '%s' failed."),$this->dn));
580     /* Delete references to groups */
581     $ldap->cd ($this->config->current['BASE']);
582     $ldap->search ("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("uid"));
583     while ($ldap->fetch()){
584       $g= new group($this->config, $ldap->getDN());
585       $g->removeUser($this->uid);
586       $g->save ();
587     }
589     /* Delete references to object groups */
590     $ldap->cd ($this->config->current['BASE']);
591     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
592     while ($ldap->fetch()){
593       $og= new ogroup($this->config, $ldap->getDN());
594       unset($og->member[$this->dn]);
595       $og->save ();
596     }
598     /* Kerberos server defined? */
599     if (isset($this->config->data['SERVERS']['KERBEROS'])){
600       $cfg= $this->config->data['SERVERS']['KERBEROS'];
601     }
602     if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
604       /* Connect to the admin interface */
605       $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
606           $cfg['ADMIN'], $cfg['PASSWORD']);
608       /* Errors? */             
609       if ($handle === FALSE){
610         print_red (_("Kerberos database communication failed"));
611         return (2);
612       }
614       /* Build user principal, get list of existsing principals */
615       $principal= $this->uid."@".$cfg['REALM'];
616       $principals = kadm5_get_principals($handle);
618       /* User exists in database? */
619       if (in_array($principal, $principals)){
621         /* Ok. User exists. Remove him/her */
622           $ret= kadm5_delete_principal ( $handle, $principal);
623           if ($ret === FALSE){
624             print_red (_("Can't remove user from kerberos database."));
625           }
626       }
628       /* Free kerberos admin handle */
629       kadm5_destroy($handle);
630     }
633     /* Optionally execute a command after we're done */
634     $this->handle_post_events("remove",array("uid" => $this->uid));
635   }
638   /* Save data to object */
639   function save_object()
640   {
641     if (isset($_POST['generic'])){
643       /* Make a backup of the current selected base */
644       $base_tmp = $this->base;
646       /* Parents save function */
647       plugin::save_object ();
649       /* Save government mode attributes */
650       if ($this->config->current['GOVERNMENTMODE']){
651         foreach ($this->govattrs as $val){
652           if ($this->acl_is_writeable($val,(!is_object($this->parent) && !isset($_SESSION['edit']))) && isset($_POST["$val"])){
653             $data= stripcslashes($_POST["$val"]);
654             if ($data != $this->$val){
655               $this->is_modified= TRUE;
656             }
657             $this->$val= $data;
658           }
659         }
660       }
662       /* In template mode, the uid is autogenerated... */
663       if ($this->is_template){
664         $this->uid= strtolower($this->sn);
665         $this->givenName= $this->sn;
666       }
668       /* Save base and pw_storage, since these are no LDAP attributes */
669       if (isset($_POST['base'])){
671         $tmp = $this->get_allowed_bases();
672         if(isset($tmp[$_POST['base']])){
673           $base= validate($_POST['base']);
674           if ($base != $this->base){
675             $this->is_modified= TRUE;
676           }
677           $this->base= $base;
678         }else{
679           $this->base = $base_tmp;
680           print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base'])));
681           $this->set_acl_base('dummy,'.$this->base);
682         }
683       }
685       /* Get pw_storage mode */
686       if (isset($_POST['pw_storage'])){
687         foreach(array("pw_storage") as $val){
688           if(isset($_POST[$val])){
689             $data= validate($_POST[$val]);
690             if ($data != $this->$val){
691               $this->is_modified= TRUE;
692             }
693             $this->$val= $data;
694           }
695         }
696       }
698       $this->set_acl_base('dummy,'.$this->base);
699     }
700   }
702   function rebind($ldap, $referral)
703   {
704     $credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']);
705     if (ldap_bind($ldap, $credentials['ADMIN'], $credentials['PASSWORD'])) {
706       $this->error = "Success";
707       $this->hascon=true;
708       $this->reconnect= true;
709       return (0);
710     } else {
711       $this->error = "Could not bind to " . $credentials['ADMIN'];
712       return NULL;
713     }
714   }
716   /* Save data to LDAP, depending on is_account we save or delete */
717   function save()
718   {
719     /* Only force save of changes .... 
720        If this attributes aren't changed, avoid saving.
721      */
722     if($this->gender=="0") $this->gender ="";
723     if($this->preferredLanguage=="0") $this->preferredLanguage ="";
724     
725  
726     /* First use parents methods to do some basic fillup in $this->attrs */
727     plugin::save ();
729     if ($this->use_dob == "1"){
730       /* 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. */
731       if(!is_array($this->attrs['dateOfBirth'])) {
732         $this->attrs['dateOfBirth'] = date("Y-m-d", $this->dateOfBirth);
733       }
734     }
736     /* Remove additional objectClasses */
737     $tmp= array();
738     foreach ($this->attrs['objectClass'] as $key => $set){
739       $found= false;
740       foreach (array("ivbbentry", "gosaUserTemplate") as $val){
741         if (preg_match ("/^$set$/i", $val)){
742           $found= true;
743           break;
744         }
745       }
746       if (!$found){
747         $tmp[]= $set;
748       }
749     }
751     /* Replace the objectClass array. This is done because of the
752        separation into government and normal mode. */
753     $this->attrs['objectClass']= $tmp;
755     /* Add objectClasss for template mode? */
756     if ($this->is_template){
757       $this->attrs['objectClass'][]= "gosaUserTemplate";
758     }
760     /* Hard coded government mode? */
761     if ($this->config->current['GOVERNMENTMODE'] != 'false'){
762       $this->attrs['objectClass'][]= "ivbbentry";
764       /* Copy standard attributes */
765       foreach ($this->govattrs as $val){
766         if ($this->$val != ""){
767           $this->attrs["$val"]= $this->$val;
768         } elseif (!$this->is_new) {
769           $this->attrs["$val"]= array();
770         }
771       }
773       /* Remove attribute if set to "nein" */
774       if ($this->publicVisible == "nein"){
775         $this->attrs['publicVisible']= array();
776         if($this->is_new){
777           unset($this->attrs['publicVisible']);
778         }else{
779           $this->attrs['publicVisible']=array();
780         }
782       }
784     }
786     /* Special handling for attribute userCertificate needed */
787     if ($this->userCertificate != ""){
788       $this->attrs["userCertificate;binary"]= $this->userCertificate;
789       $remove_userCertificate= false;
790     } else {
791       $remove_userCertificate= true;
792     }
794     /* Special handling for dateOfBirth value */
795     if ($this->use_dob != "1"){
796       if ($this->is_new) {
797         unset($this->attrs["dateOfBirth"]);
798       } else {
799         $this->attrs["dateOfBirth"]= array();
800       }
801     }
802     if (!$this->gender){
803       if ($this->is_new) {
804         unset($this->attrs["gender"]);
805       } else {
806         $this->attrs["gender"]= array();
807       }
808     }
809     if (!$this->preferredLanguage){
810       if ($this->is_new) {
811         unset($this->attrs["preferredLanguage"]);
812       } else {
813         $this->attrs["preferredLanguage"]= array();
814       }
815     }
817     /* Special handling for attribute jpegPhote needed, scale image via
818        image magick to 147x200 pixels and inject resulting data. */
819     if ($this->jpegPhoto == "*removed*"){
820     
821       /* Reset attribute to avoid writing *removed* as value */    
822       $this->attrs["jpegPhoto"] = array();
824     } else {
826       /* Fallback if there's no image magick inside PHP */
827       if (!function_exists("imagick_blob2image")){
828         /* Get temporary file name for conversation */
829         $fname = tempnam ("/tmp", "GOsa");
831         /* Open file and write out photoData */
832         $fp = fopen ($fname, "w");
833         fwrite ($fp, $this->photoData);
834         fclose ($fp);
836         /* Build conversation query. Filename is generated automatically, so
837            we do not need any special security checks. Exec command and save
838            output. For PHP safe mode, you'll need a configuration which respects
839            image magick as executable... */
840         $query= "convert -size 147x200 $fname -resize 147x200 +profile \"*\" -";
841         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
842             $query, "Execute");
844         /* Read data written by convert */
845         $output= "";
846         $sh= popen($query, 'r');
847         while (!feof($sh)){
848           $output.= fread($sh, 4096);
849         }
850         pclose($sh);
852         unlink($fname);
854         /* Save attribute */
855         $this->attrs["jpegPhoto"] = $output;
857       } else {
859         /* Load the new uploaded Photo */
860         if(!$handle  =  imagick_blob2image($this->photoData))  {
861           gosa_log("Can't Load image");
862         }
864         /* Resizing image to 147x200 and blur */
865         if(!imagick_resize($handle,147,200,IMAGICK_FILTER_GAUSSIAN,0)){
866           gosa_log("imagick_resize failed");
867         }
869         /* Converting image to JPEG */
870         if(!imagick_convert($handle,"JPEG")) {
871           gosa_log("Can't Convert to JPEG");
872         }
874         /* Creating binary Code for the Image */
875         if(!$dump = imagick_image2blob($handle)){
876           gosa_log("Can't create blob for image");
877         }
879         /* Sending Image */
880         $output=  $dump;
882         /* Save attribute */
883         $this->attrs["jpegPhoto"] = $output;
884       }
886     }
888     /* Build new dn */
889     if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
890       $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
891     } else {
892       $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base;
893     }
895     /* This only gets called when user is renaming himself */
896     $ldap= $this->config->get_ldap_link();
897     if ($this->dn != $new_dn){
899       /* Write entry on new 'dn' */
900       $this->move($this->dn, $new_dn);
902       /* Happen to use the new one */
903       change_ui_dn($this->dn, $new_dn);
904       $this->dn= $new_dn;
905     }
908     /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
909        new entries. So do a check first... */
910     $ldap->cat ($this->dn, array('dn'));
911     if ($ldap->fetch()){
912       $mode= "modify";
913     } else {
914       $mode= "add";
915       $ldap->cd($this->config->current['BASE']);
916       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
917     }
919     /* Set password to some junk stuff in case of templates */
920     if ($this->is_template){
921       $this->attrs['userPassword']= '{crypt}N0T$3T4N0W';
922     }
924     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
925         $this->attributes, "Save via $mode");
927     /* Finally write data with selected 'mode' */
928     $this->cleanup();
929     $ldap->cd ($this->dn);
930     $ldap->$mode ($this->attrs);
931     if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/generic account with dn '%s' failed."),$this->dn))){
932       return (1);
933     }
935     /* Remove cert? 
936        For some reason, the 'ldap' class doesn't want to remove binary entries, so I need
937        to work around myself. */
938     if ($remove_userCertificate == true && !$this->is_new && $this->had_userCertificate){
940       /* Reset array, assemble new, this should be reworked */
941       $this->attrs= array();
942       $this->attrs['userCertificate;binary']= array();
944       /* Prepare connection */
945       if (!($ds = ldap_connect($this->config->current['SERVER']))) {
946         die ("Could not connect to LDAP server");
947       }
948       ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
949       if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
950         ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
951         ldap_set_rebind_proc($ds, array(&$this, "rebind"));
952       }
953       if(isset($config->current['TLS']) && $config->current['TLS'] == "true"){
954         ldap_start_tls($ds);
955       }
956       if (!($res = @ldap_bind($ds, $this->config->current['ADMIN'],
957               $this->config->current['PASSWORD']))) {
958         die ("Could not bind to LDAP");
959       }
961       /* Modify using attrs */
962       ldap_mod_del($ds,$this->dn,$this->attrs);
963       ldap_close($ds);
964     }
966     /* Kerberos server defined? */
967     if (isset($this->config->data['SERVERS']['KERBEROS'])){
968       $cfg= $this->config->data['SERVERS']['KERBEROS'];
969     }
970     if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
972       /* Connect to the admin interface */
973       $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
974           $cfg['ADMIN'], $cfg['PASSWORD']);
976       /* Errors? */             
977       if ($handle === FALSE){
978         print_red (_("Kerberos database communication failed"));
979         return (2);
980       }
982       /* Build user principal, get list of existsing principals */
983       $principal= $this->uid."@".$cfg['REALM'];
984       $principals = kadm5_get_principals($handle);
986       /* User exists in database? */
987       if (in_array($principal, $principals)){
989         /* Ok. User exists. Remove him/her when pw_storage has
990            changed to be NOT kerberos. */
991         if ($this->pw_storage != $this->config->current['KRBSASL']){
992           $ret= kadm5_delete_principal ( $handle, $principal);
994           if ($ret === FALSE){
995             print_red (_("Can't remove user from kerberos database."));
996           }
997         }
999       } else {
1001         /* User doesn't exists, create it when pw_storage is kerberos. */
1002         if ($this->pw_storage == "kerberos" || $this->pw_storage == "sasl" ){
1003           $ret= kadm5_create_principal ( $handle, $principal);
1005           if ($ret === FALSE){
1006             print_red (_("Can't add user to kerberos database."));
1007           }
1008         }
1010       }
1012       /* Free kerberos admin handle */
1013       kadm5_destroy($handle);
1014     }
1016     /* Optionally execute a command after we're done */
1017     if ($mode == "add"){
1018       $this->handle_post_events("add", array("uid" => $this->uid));
1019     } elseif ($this->is_modified){
1020       $this->handle_post_events("modify", array("uid" => $this->uid));
1021     }
1023     /* Fix tagging if needed */
1024     $this->handle_object_tagging();
1026     return (0);
1027   }
1030   /* Check formular input */
1031   function check()
1032   {
1033     /* Call common method to give check the hook */
1034     $message= plugin::check();
1036     /* Assemble cn */
1037     $this->cn= $this->givenName." ".$this->sn;
1039     /* Permissions for that base? */
1040     if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
1041       $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
1042     } else {
1043       $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base;
1044     }
1046     /* Set the new acl base */
1047     if($this->dn == "new") {
1048       $this->set_acl_base($this->base);
1049     }
1051     if ($this->dn == "new" &&  !$this->acl_is_createable()){
1052       $message[]= _("You have no permissions to create a user on this 'Base'.");
1053     } elseif ($this->dn != $new_dn && $this->dn != "new"){
1054       if (!$this->acl_is_writeable($this->dn, "user","create",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1055         $message[]= _("You have no permissions to move this user to the specified 'Base'.");
1056       }
1057     }
1059     /* must: sn, givenName, uid */
1060     if ($this->sn == "" && ($this->acl_is_writeable("sn",(!is_object($this->parent) && !isset($_SESSION['edit'])) || ($this->is_new)))){
1061       $message[]= _("The required field 'Name' is not set.");
1062     }
1064     /* UID already used? */
1065     $ldap= $this->config->get_ldap_link();
1066     $ldap->cd($this->config->current['BASE']);
1067     $ldap->search("(uid=$this->uid)", array("uid"));
1068     $ldap->fetch();
1069     if ($ldap->count() != 0 && $this->dn == 'new'){
1070       $message[]= _("There's already a person with this 'Login' in the database.");
1071     }
1073     /* In template mode, the uid and givenName are autogenerated... */
1074     if (!$this->is_template){
1075       if ($this->givenName == "" && $this->acl_is_writeable("givenName",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1076         $message[]= _("The required field 'Given name' is not set.");
1077       }
1078       if ($this->uid == "" && $this->acl_is_writeable("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1079         $message[]= _("The required field 'Login' is not set.");
1080       }
1081       if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
1082         $ldap->cd($this->config->current['BASE']);
1083         $ldap->search("(cn=".$this->cn.")", array("uid"));
1084         $ldap->fetch();
1085         if ($ldap->count() != 0 && $this->dn != $new_dn && $this->dn == 'new'){
1086           $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
1087         }
1088       }
1089     }
1091     /* Check for valid input */
1092     if ($this->is_modified && !is_uid($this->uid)){
1093       $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed.");
1094     }
1095     if (!is_url($this->labeledURI)){
1096       $message[]= _("The field 'Homepage' contains an invalid URL definition.");
1097     }
1098     if (preg_match ("/[\\\\]/", $this->sn)){
1099       $message[]= _("The field 'Name' contains invalid characters.");
1100     }
1101     if (preg_match ("/[\\\\]/", $this->givenName)){
1102       $message[]= _("The field 'Given name' contains invalid characters.");
1103     }
1105     /* Check phone numbers */
1106     if (!is_phone_nr($this->telephoneNumber)){
1107       $message[]= _("The field 'Phone' contains an invalid phone number.");
1108     }
1109     if (!is_phone_nr($this->facsimileTelephoneNumber)){
1110       $message[]= _("The field 'Fax' contains an invalid phone number.");
1111     }
1112     if (!is_phone_nr($this->mobile)){
1113       $message[]= _("The field 'Mobile' contains an invalid phone number.");
1114     }
1115     if (!is_phone_nr($this->pager)){
1116       $message[]= _("The field 'Pager' contains an invalid phone number.");
1117     }
1119     /* Check for reserved characers */
1120     if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName)){
1121       $message[]= _("The field 'Given name' contains invalid characters.");
1122     }
1123     if (preg_match ('/[,+"?\'()=<>;]/', $this->sn)){
1124       $message[]= _("The field 'Name' contains invalid characters.");
1125     }
1127   return $message;
1128   }
1131   /* Indicate whether a password change is needed or not */
1132   function password_change_needed()
1133   {
1134     return ($this->pw_storage != $this->last_pw_storage);
1135   }
1138   /* Load a jpegPhoto from LDAP, this is going to be simplified later on */
1139   function load_picture()
1140   {
1141     $ldap = $this->config->get_ldap_link();
1142     $ldap->cd ($this->dn);
1143     $data = $ldap->get_attribute($this->dn,"jpegPhoto");
1144       
1145     if((!$data) || ($data == "*removed*")){ 
1147       /* In case we don't get an entry, load a default picture */
1148       $this->set_picture ();//"./images/default.jpg");
1149       $this->jpegPhoto= "*removed*";
1150     }else{
1152       /* Set picture */
1153       $this->photoData= $data;
1154       $_SESSION['binary']= $this->photoData;
1155       $_SESSION['binarytype']= "image/jpeg";
1156       $this->jpegPhoto= "";
1157     }
1158   }
1161   /* Load a certificate from LDAP, this is going to be simplified later on */
1162   function load_cert()
1163   {
1164     $ds= ldap_connect($this->config->current['SERVER']);
1165     ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
1166     if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
1167       ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
1168       ldap_set_rebind_proc($ds, array(&$this, "rebind"));
1169     }
1170     if(isset($this->config->current['TLS']) &&
1171         $this->config->current['TLS'] == "true"){
1173       ldap_start_tls($ds);
1174     }
1176     $r= ldap_bind($ds);
1177     $sr= @ldap_read($ds, $this->dn, "userCertificate=*", array("userCertificate"));
1179     if ($sr) {
1180       $ei= @ldap_first_entry($ds, $sr);
1181       
1182       if ($ei) {
1183         if (!$info = @ldap_get_values_len($ds, $ei, "userCertificate;binary")){
1184           $this->userCertificate= "";
1185         } else {
1186           $this->userCertificate= $info[0];
1187         }
1188       }
1189     } else {
1190       $this->userCertificate= "";
1191     }
1193     ldap_unbind($ds);
1194   }
1197   /* Load picture from file to object */
1198   function set_picture($filename ="")
1199   {
1200     if (!is_file($filename) || $filename =="" ){
1201       $filename= "./images/default.jpg";
1202       $this->jpegPhoto= "*removed*";
1203     }
1205     $fd = fopen ($filename, "rb");
1206     $this->photoData= fread ($fd, filesize ($filename));
1207     $_SESSION['binary']= $this->photoData;
1208     $_SESSION['binarytype']= "image/jpeg";
1209     $this->jpegPhoto= "";
1211     fclose ($fd);
1212   }
1215   /* Load certificate from file to object */
1216   function set_cert($cert, $filename)
1217   {
1218     if(!$thsi->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))) return;
1219     $fd = fopen ($filename, "rb");
1220     if (filesize($filename)>0) {
1221       $this->$cert= fread ($fd, filesize ($filename));
1222       fclose ($fd);
1223       $this->is_modified= TRUE;
1224     } else {
1225       print_red(_("Could not open specified certificate!"));
1226     }
1227   }
1229   /* Adapt from given 'dn' */
1230   function adapt_from_template($dn)
1231   {
1232     plugin::adapt_from_template($dn);
1234     /* Get base */
1235     $this->base= preg_replace('/^[^,]+,'.get_people_ou().'/i', '', $dn);
1237     if ($this->config->current['GOVERNMENTMODE']){
1239       /* Walk through govattrs */
1240       foreach ($this->govattrs as $val){
1242         if (isset($this->attrs["$val"][0])){
1244           /* If attribute is set, replace dynamic parts: 
1245              %sn, %givenName and %uid. Fill these in our local variables. */
1246           $value= $this->attrs["$val"][0];
1248           foreach (array("sn", "givenName", "uid") as $repl){
1249             if (preg_match("/%$repl/i", $value)){
1250               $value= preg_replace ("/%$repl/i",
1251                   $this->parent->$repl, $value);
1252             }
1253           }
1254           $this->$val= $value;
1255         }
1256       }
1257     }
1259     /* Get back uid/sn/givenName */
1260     if ($this->parent != NULL){
1261       $this->uid= $this->parent->uid;
1262       $this->sn= $this->parent->sn;
1263       $this->givenName= $this->parent->givenName;
1264     }
1265   }
1267  
1268   /* This avoids that users move themselves out of their rights. 
1269    */
1270   function allowedBasesToMoveTo()
1271   {
1272     /* Get bases */
1273     $bases  = $this->get_allowed_bases();
1274     return($bases);
1275   } 
1278   function getCopyDialog()
1279   {
1280     $str = "";
1282     $_SESSION['binary'] = $this->photoData; 
1283     $_SESSION['binarytype']= "image/jpeg";
1285     /* Get random number for pictures */
1286     srand((double)microtime()*1000000); 
1287     $rand = rand(0, 10000);
1289     $smarty = get_smarty();
1291     $smarty->assign("passwordTodo","clear");
1293     if(isset($_POST['passwordTodo'])){
1294       $smarty->assign("passwordTodo",$_POST['passwordTodo']);
1295     }
1297     $smarty->assign("sn",       $this->sn);
1298     $smarty->assign("givenName",$this->givenName);
1299     $smarty->assign("uid",      $this->uid);
1300     $smarty->assign("rand",     $rand);
1301     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
1304     $ret = array();
1305     $ret['string'] = $str;
1306     $ret['status'] = "";  
1307     return($ret);
1308   }
1310   function saveCopyDialog()
1311   {
1312     /* Set_acl_base */
1313     $this->set_acl_base("cn=dummy,".get_people_ou().$this->base);
1315     if((isset($_FILES['picture_file']['tmp_name'])) && ($_FILES['picture_file']['size'] > 0)){
1316       $this->set_picture($_FILES['picture_file']['tmp_name']);
1317     }
1319     /* Remove picture? */
1320     if (isset($_POST['picture_remove'])){
1321       $this->jpegPhoto= "*removed*";
1322       $this->set_picture ("./images/default.jpg");
1323       $this->is_modified= TRUE;
1324     }
1326     $attrs = array("uid","givenName","sn");
1327     foreach($attrs as $attr){
1328       if(isset($_POST[$attr])){
1329         $this->$attr = $_POST[$attr];
1330       }
1331     } 
1332   }
1335   function PrepareForCopyPaste($source)
1336   {
1337     plugin::PrepareForCopyPaste($source);
1339     /* Reset certificate information addepted from source user
1340        to avoid setting the same user certificate for the destination user. */
1341     $this->userPKCS12= "";
1342     $this->userSMIMECertificate= "";
1343     $this->userCertificate= "";
1344     $this->certificateSerialNumber= "";
1345     $this->old_certificateSerialNumber= "";
1346     $this->old_userPKCS12= "";
1347     $this->old_userSMIMECertificate= "";
1348     $this->old_userCertificate= "";
1349   }
1352   function plInfo()
1353   {
1354   
1355     $govattrs= array(
1356         "gouvernmentOrganizationalUnit"             =>  _("Unit"), 
1357         "houseIdentifier"                           =>  _("House identifier"), 
1358         "vocation"                                  =>  _("Vocation"),
1359         "ivbbLastDeliveryCollective"                =>  _("Last delivery"), 
1360         "gouvernmentOrganizationalPersonLocality"   =>  _("Person locality"),
1361         "gouvernmentOrganizationalUnitDescription"  =>  _("Unit description"),
1362         "gouvernmentOrganizationalUnitSubjectArea"  =>  _("Subject area"),
1363         "functionalTitle"                           =>  _("Functional title"),
1364         "certificateSerialNumber"                   =>  _(""),
1365         "publicVisible"                             =>  _("Public visible"),
1366         "street"                                    =>  _("Street"),
1367         "role"                                      =>  _("Role"),
1368         "postalCode"                                =>  _("Postal code"));
1370     $ret = array(
1371         "plShortName" => _("Generic"),
1372         "plDescription" => _("Generic user settings"),
1373         "plSelfModify"  => TRUE,
1374         "plDepends"     => array(),
1375         "plPriority"    => 1,
1376         "plSection"     => array("personal" => _("My account")),
1377         "plCategory"    => array("users" => array("description" => _("Users"),
1378                                                   "objectClass" => "gosaAccount")),
1380         "plProvidedAcls" => array(
1381           "base"              => _("Base"), 
1382           "userPassword"      => _("User password"), 
1383           "sn"                => _("Surename"),
1384           "givenName"         => _("Given name"),
1385           "uid"               => _("User identification"),
1386           "personalTitle"     => _("Personal title"),
1387           "academicTitle"     => _("Academic title"),
1388           "homePostalAddress" => _("Home postal address"),
1389           "homePhone"         => _("Home phone number"),
1390           "labeledURI"        => _("Homepage"),
1391           "o"                 => _("Organization"),
1392           "ou"                => _("Department"),
1393           "dateOfBirth"       => _("Date of birth"),
1394           "gender"            => _("Gender"),
1395           "preferredLanguage" => _("Preferred language"),
1396           "departmentNumber"  => _("Department number"),
1397           "employeeNumber"    => _("Employee number"),
1398           "employeeType"      => _("Employee type"),
1399           "l"                 => _("Location"),
1400           "st"                => _("State"),
1401           "userPicture"       => _("User picture"),
1402           "roomNumber"        => _("Room number"),
1403           "telephoneNumber"   => _("Telefon number"),
1404           "mobile"            => _("Mobile number"),
1405           "pager"             => _("Pager number"),
1406           "Certificate"        => _("User certificates"),
1408           "postalAddress"                => _("Postal address"),
1409           "facsimileTelephoneNumber"     => _("Fax number"))
1410         );
1412     /* Append government attributes if required */
1413       global $config;
1414     if (isset($config->current['GOVERNMENTMODE']) &&  preg_match('/true/i', $config->current['GOVERNMENTMODE'])){
1415       foreach($govattrs as $attr => $desc){
1416         $ret["plProvidedAcls"][$attr] = $desc;
1417       }
1418     }
1420     return($ret);
1421   }
1424 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1425 ?>