Code

Added set_acl_base() to all check() functions, to ensure that the checks will be...
[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()){
295         $this->base = $this->dialog->isSelected();
296         $this->dialog= false;
297       }else{
298         return($this->dialog->execute());
299       }
300     }
302     /* Want picture edit dialog? */
303     if($this->acl_is_writeable("userPicture")) {
304       if (isset($_POST['edit_picture'])){
305         /* Save values for later recovery, in case some presses
306            the cancel button. */
307         $this->old_jpegPhoto= $this->jpegPhoto;
308         $this->old_photoData= $this->photoData;
309         $this->picture_dialog= TRUE;
310         $this->dialog= TRUE;
311       }
312     }
314     /* Remove picture? */
315     if($this->acl_is_writeable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))) ){
316       if (isset($_POST['picture_remove'])){
317         $this->set_picture ();
318         $this->jpegPhoto= "*removed*";
319         $this->is_modified= TRUE;
320         return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
321       }
322     }
324     /* Save picture */
325     if (isset($_POST['picture_edit_finish'])){
327       /* Check for clean upload */
328       if ($_FILES['picture_file']['name'] != ""){
329         if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) {
330           print_red(_("The specified file has not been uploaded via HTTP POST! Aborted."));
331         }else{
332           /* Activate new picture */
333           $this->set_picture($_FILES['picture_file']['tmp_name']);
334         }
335       }
336       $this->picture_dialog= FALSE;
337       $this->dialog= FALSE;
338       $this->is_modified= TRUE;
339     }
342     /* Cancel picture */
343     if (isset($_POST['picture_edit_cancel'])){
345       /* Restore values */
346       $this->jpegPhoto= $this->old_jpegPhoto;
347       $this->photoData= $this->old_photoData;
349       /* Update picture */
350       $_SESSION['binary']= $this->photoData;
351       $_SESSION['binarytype']= "image/jpeg";
352       $this->picture_dialog= FALSE;
353       $this->dialog= FALSE;
354     }
356     /* Toggle dateOfBirth information */
357     if (isset($_POST['set_dob'])){
358       $this->use_dob= ($this->use_dob == "0")?"1":"0";
359     }
362     /* Want certificate= */
363     if ((isset($_POST['edit_cert'])) && $this->acl_is_readable("Certificate")){
365       /* Save original values for later reconstruction */
366       foreach (array("certificateSerialNumber", "userCertificate",
367             "userSMIMECertificate", "userPKCS12") as $val){
369         $oval= "old_$val";
370         $this->$oval= $this->$val;
371       }
373       $this->cert_dialog= TRUE;
374       $this->dialog= TRUE;
375     }
378     /* Cancel certificate dialog */
379     if (isset($_POST['cert_edit_cancel'])){
381       /* Restore original values in case of 'cancel' */
382       foreach (array("certificateSerialNumber", "userCertificate",
383             "userSMIMECertificate", "userPKCS12") as $val){
385         $oval= "old_$val";
386         $this->$val= $this->$oval;
387       }
388       $this->cert_dialog= FALSE;
389       $this->dialog= FALSE;
390     }
393     /* Remove certificate? */
394     if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){ 
395       foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") as $val){
396         if (isset($_POST["remove_$val"])){
398           /* Reset specified cert*/
399           $this->$val= "";
400           $this->is_modified= TRUE;
401         }
402       }
403     }
405     /* Upload new cert and close dialog? */     
406     if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){ 
407       if (isset($_POST['cert_edit_finish'])){
409         /* for all certificates do */
410         foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12")
411             as $val){
413           /* Check for clean upload */
414           if (array_key_exists($val."_file", $_FILES) &&
415               array_key_exists('name', $_FILES[$val."_file"]) &&
416               $_FILES[$val."_file"]['name'] != "" &&
417               is_uploaded_file($_FILES[$val."_file"]['tmp_name'])) {
418             $this->set_cert("$val", $_FILES[$val."_file"]['tmp_name']);
419           }
420         }
422         /* Save serial number */
423         if (isset($_POST["certificateSerialNumber"]) &&
424             $_POST["certificateSerialNumber"] != ""){
426           if (!is_id($_POST["certificateSerialNumber"])){
427             print_red (_("Please enter a valid serial number"));
429             foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
430               if ($this->$cert != ""){
431                 $smarty->assign("$cert"."_state", "true");
432               } else {
433                 $smarty->assign("$cert"."_state", "");
434               }
435             }
436             return ($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
437           }
439           $this->certificateSerialNumber= $_POST["certificateSerialNumber"];
440           $this->is_modified= TRUE;
441         }
443         $this->cert_dialog= FALSE;
444         $this->dialog= FALSE;
445       }
446     }
447     /* Display picture dialog */
448     if ($this->picture_dialog){
449       return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
450     }
452     /* Display cert dialog */
453     if ($this->cert_dialog){
454       $smarty->assign("CertificateACL",$this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
455       $smarty->assign("Certificate_readable",$this->acl_is_readable("Certificate"));
457       foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
458         if ($this->$cert != ""){
459           /* import certificate */
460           $certificate = new certificate;
461           $certificate->import($this->$cert);
462       
463           /* Read out data*/
464           $timeto   = $certificate->getvalidto_date();
465           $timefrom = $certificate->getvalidfrom_date();
466          
467           
468           /* Additional info if start end time is '0' */
469           $add_str_info = "";
470           if($timeto == 0 && $timefrom == 0){
471             $add_str_info = "<br><i>"._("(Some types of certificates are currently not supported and may be displayed as 'invalid'.)")."</i>";
472           }
474           $str = "<table summary=\"\" border=0>
475                     <tr>
476                       <td style='vertical-align:top'>CN</td>
477                       <td>".preg_replace("/ /", "&nbsp;", $certificate->getname())."</td>
478                     </tr>
479                   </table><br>".
481                   sprintf(_("Certificate is valid from %s to %s and is currently %s."),
482                         "<b>".date('d M Y',$timefrom)."</b>",
483                         "<b>".date('d M Y',$timeto)."</b>",
484                         $certificate->isvalid()?"<b><font style='color:green'>"._("valid")."</font></b>":
485                                                 "<b><font style='color:red'>"._("invalid")."</font></b>").$add_str_info;
487           $smarty->assign($cert."info",$str);
488           $smarty->assign($cert."_state","true");
489         } else {
490           $smarty->assign($cert."info", "<i>"._("No certificate installed")."</i>");
491           $smarty->assign($cert."_state","");
492         }
493       }
494       $smarty->assign("governmentmode", "false");
495       return($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
496     }
498     /* Prepare password hashes */
499     if ($this->pw_storage == ""){
500       $this->pw_storage= $this->config->current['HASH'];
501     }
503     $temp   = @passwordMethod::get_available_methods();
504     $hashes = $temp['name'];
505     
506     /* Load attributes and acl's */
507     $ui =get_userinfo();
508     foreach($this->attributes as $val){
509       $smarty->assign("$val", $this->$val);
510       $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
511     }
513     $smarty->assign("pwmode", $hashes);
514     $smarty->assign("pwmode_select", $this->pw_storage);
515     $smarty->assign("passwordStorageACL", $this->getacl("userPassword",(!is_object($this->parent) && !isset($_SESSION['edit']))));
516     $smarty->assign("base_select",      $this->base);
517     $smarty->assign("CertificatesACL",  $this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
518     $smarty->assign("userPictureACL",   $this->getacl("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
519     $smarty->assign("userPicture_is_readable",   $this->acl_is_readable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
521     /* Create base acls */
522     $baseACL = $this->getacl("base",(!is_object($this->parent) && !isset($_SESSION['edit'])));
523     if($this->dn == "new" && !$this->acl_is_createable()) {
524       $baseACL = preg_replace("/w/","",$baseACL);
525     }elseif($this->dn != "new" && !$this->acl_is_moveable()) {
526       $baseACL = preg_replace("/w/","",$baseACL);
527     }
528     $smarty->assign("baseACL",          $baseACL);
529     @$smarty->assign("bases", $this->allowedBasesToMoveTo());
531     /* Save government mode attributes */
532     if (isset($this->config->current['GOVERNMENTMODE']) &&
533         preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){
534       $smarty->assign("governmentmode", "true");
535       $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet",
536           "internet,ivbv", "internet,testa", "internet,ivbv,testa");
537       $smarty->assign("ivbbmodes", $ivbbmodes);
538       foreach ($this->govattrs as $val){
539         $smarty->assign("$val", $this->$val);
540         $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
541       }
542     } else {
543       $smarty->assign("governmentmode", "false");
544     }
546     /* Special mode for uid */
547     $uidACL= $this->getacl("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])));
548     if (isset ($this->dn)){
549       if ($this->dn != "new"){
550         $uidACL= preg_replace("/w/","",$uidACL);
551       }
552     }  else {
553       $uidACL= preg_replace("/w/","",$uidACL);
554     }
555     
556     $smarty->assign("uidACL", $uidACL);
557     $smarty->assign("is_template", $this->is_template);
558     $smarty->assign("use_dob", $this->use_dob);
560     if (isset($this->parent)){
561       if (isset($this->parent->by_object['phoneAccount']) &&
562           $this->parent->by_object['phoneAccount']->is_account){
563         $smarty->assign("has_phoneaccount", "true");
564       } else {
565         $smarty->assign("has_phoneaccount", "false");
566       }
567     } else {
568       $smarty->assign("has_phoneaccount", "false");
569     }
570     return($smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))));
571   }
574   /* remove object from parent */
575   function remove_from_parent()
576   {
577     $ldap= $this->config->get_ldap_link();
578     $ldap->rmdir ($this->dn);
579     show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/generic account with dn '%s' failed."),$this->dn));
581     /* Delete references to groups */
582     $ldap->cd ($this->config->current['BASE']);
583     $ldap->search ("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("uid"));
584     while ($ldap->fetch()){
585       $g= new group($this->config, $ldap->getDN());
586       $g->removeUser($this->uid);
587       $g->save ();
588     }
590     /* Delete references to object groups */
591     $ldap->cd ($this->config->current['BASE']);
592     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
593     while ($ldap->fetch()){
594       $og= new ogroup($this->config, $ldap->getDN());
595       unset($og->member[$this->dn]);
596       $og->save ();
597     }
599     /* Kerberos server defined? */
600     if (isset($this->config->data['SERVERS']['KERBEROS'])){
601       $cfg= $this->config->data['SERVERS']['KERBEROS'];
602     }
603     if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
605       /* Connect to the admin interface */
606       $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
607           $cfg['ADMIN'], $cfg['PASSWORD']);
609       /* Errors? */             
610       if ($handle === FALSE){
611         print_red (_("Kerberos database communication failed"));
612         return (2);
613       }
615       /* Build user principal, get list of existsing principals */
616       $principal= $this->uid."@".$cfg['REALM'];
617       $principals = kadm5_get_principals($handle);
619       /* User exists in database? */
620       if (in_array($principal, $principals)){
622         /* Ok. User exists. Remove him/her */
623           $ret= kadm5_delete_principal ( $handle, $principal);
624           if ($ret === FALSE){
625             print_red (_("Can't remove user from kerberos database."));
626           }
627       }
629       /* Free kerberos admin handle */
630       kadm5_destroy($handle);
631     }
634     /* Optionally execute a command after we're done */
635     $this->handle_post_events("remove",array("uid" => $this->uid));
636   }
639   /* Save data to object */
640   function save_object()
641   {
642     if (isset($_POST['generic'])){
644       /* Parents save function */
645       plugin::save_object ();
647       /* Save government mode attributes */
648       if ($this->config->current['GOVERNMENTMODE']){
649         foreach ($this->govattrs as $val){
650           if ($this->acl_is_writeable($val,(!is_object($this->parent) && !isset($_SESSION['edit']))) && isset($_POST["$val"])){
651             $data= stripcslashes($_POST["$val"]);
652             if ($data != $this->$val){
653               $this->is_modified= TRUE;
654             }
655             $this->$val= $data;
656           }
657         }
658       }
660       /* In template mode, the uid is autogenerated... */
661       if ($this->is_template){
662         $this->uid= strtolower($this->sn);
663         $this->givenName= $this->sn;
664       }
666       /* Save base and pw_storage, since these are no LDAP attributes */
667       if (isset($_POST['base'])){
669         $this->set_acl_base('dummy,'.$_POST['base']);
670         if($this->acl_is_moveable("base")){
672           foreach(array("base") as $val){
673             if(isset($_POST[$val])){
674               $data= validate($_POST[$val]);
675               if ($data != $this->$val){
676                 $this->is_modified= TRUE;
677               }
678               $this->$val= $data;
679             }
680           }
681         }else{
682           print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base'])));
683           $this->set_acl_base('dummy,'.$this->base);
684         }
685       }
687       /* Get pw_storage mode */
688       if (isset($_POST['pw_storage'])){
689         foreach(array("pw_storage") as $val){
690           if(isset($_POST[$val])){
691             $data= validate($_POST[$val]);
692             if ($data != $this->$val){
693               $this->is_modified= TRUE;
694             }
695             $this->$val= $data;
696           }
697         }
698       }
700       $this->set_acl_base('dummy,'.$this->base);
701     }
702   }
704   function rebind($ldap, $referral)
705   {
706     $credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']);
707     if (ldap_bind($ldap, $credentials['ADMIN'], $credentials['PASSWORD'])) {
708       $this->error = "Success";
709       $this->hascon=true;
710       $this->reconnect= true;
711       return (0);
712     } else {
713       $this->error = "Could not bind to " . $credentials['ADMIN'];
714       return NULL;
715     }
716   }
718   /* Save data to LDAP, depending on is_account we save or delete */
719   function save()
720   {
721     /* Only force save of changes .... 
722        If this attributes aren't changed, avoid saving.
723      */
724     if($this->gender=="0") $this->gender ="";
725     if($this->preferredLanguage=="0") $this->preferredLanguage ="";
726     
727  
728     /* First use parents methods to do some basic fillup in $this->attrs */
729     plugin::save ();
731     if ($this->use_dob == "1"){
732       /* 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. */
733       if(!is_array($this->attrs['dateOfBirth'])) {
734         $this->attrs['dateOfBirth'] = date("Y-m-d", $this->dateOfBirth);
735       }
736     }
738     /* Remove additional objectClasses */
739     $tmp= array();
740     foreach ($this->attrs['objectClass'] as $key => $set){
741       $found= false;
742       foreach (array("ivbbentry", "gosaUserTemplate") as $val){
743         if (preg_match ("/^$set$/i", $val)){
744           $found= true;
745           break;
746         }
747       }
748       if (!$found){
749         $tmp[]= $set;
750       }
751     }
753     /* Replace the objectClass array. This is done because of the
754        separation into government and normal mode. */
755     $this->attrs['objectClass']= $tmp;
757     /* Add objectClasss for template mode? */
758     if ($this->is_template){
759       $this->attrs['objectClass'][]= "gosaUserTemplate";
760     }
762     /* Hard coded government mode? */
763     if ($this->config->current['GOVERNMENTMODE'] != 'false'){
764       $this->attrs['objectClass'][]= "ivbbentry";
766       /* Copy standard attributes */
767       foreach ($this->govattrs as $val){
768         if ($this->$val != ""){
769           $this->attrs["$val"]= $this->$val;
770         } elseif (!$this->is_new) {
771           $this->attrs["$val"]= array();
772         }
773       }
775       /* Remove attribute if set to "nein" */
776       if ($this->publicVisible == "nein"){
777         $this->attrs['publicVisible']= array();
778         if($this->is_new){
779           unset($this->attrs['publicVisible']);
780         }else{
781           $this->attrs['publicVisible']=array();
782         }
784       }
786     }
788     /* Special handling for attribute userCertificate needed */
789     if ($this->userCertificate != ""){
790       $this->attrs["userCertificate;binary"]= $this->userCertificate;
791       $remove_userCertificate= false;
792     } else {
793       $remove_userCertificate= true;
794     }
796     /* Special handling for dateOfBirth value */
797     if ($this->use_dob != "1"){
798       if ($this->is_new) {
799         unset($this->attrs["dateOfBirth"]);
800       } else {
801         $this->attrs["dateOfBirth"]= array();
802       }
803     }
804     if (!$this->gender){
805       if ($this->is_new) {
806         unset($this->attrs["gender"]);
807       } else {
808         $this->attrs["gender"]= array();
809       }
810     }
811     if (!$this->preferredLanguage){
812       if ($this->is_new) {
813         unset($this->attrs["preferredLanguage"]);
814       } else {
815         $this->attrs["preferredLanguage"]= array();
816       }
817     }
819     /* Special handling for attribute jpegPhote needed, scale image via
820        image magick to 147x200 pixels and inject resulting data. */
821     if ($this->jpegPhoto == "*removed*"){
822     
823       /* Reset attribute to avoid writing *removed* as value */    
824       $this->attrs["jpegPhoto"] = array();
826     } else {
828       /* Fallback if there's no image magick inside PHP */
829       if (!function_exists("imagick_blob2image")){
830         /* Get temporary file name for conversation */
831         $fname = tempnam ("/tmp", "GOsa");
833         /* Open file and write out photoData */
834         $fp = fopen ($fname, "w");
835         fwrite ($fp, $this->photoData);
836         fclose ($fp);
838         /* Build conversation query. Filename is generated automatically, so
839            we do not need any special security checks. Exec command and save
840            output. For PHP safe mode, you'll need a configuration which respects
841            image magick as executable... */
842         $query= "convert -size 147x200 $fname -resize 147x200 +profile \"*\" -";
843         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
844             $query, "Execute");
846         /* Read data written by convert */
847         $output= "";
848         $sh= popen($query, 'r');
849         while (!feof($sh)){
850           $output.= fread($sh, 4096);
851         }
852         pclose($sh);
854         unlink($fname);
856         /* Save attribute */
857         $this->attrs["jpegPhoto"] = $output;
859       } else {
861         /* Load the new uploaded Photo */
862         if(!$handle  =  imagick_blob2image($this->photoData))  {
863           gosa_log("Can't Load image");
864         }
866         /* Resizing image to 147x200 and blur */
867         if(!imagick_resize($handle,147,200,IMAGICK_FILTER_GAUSSIAN,0)){
868           gosa_log("imagick_resize failed");
869         }
871         /* Converting image to JPEG */
872         if(!imagick_convert($handle,"JPEG")) {
873           gosa_log("Can't Convert to JPEG");
874         }
876         /* Creating binary Code for the Image */
877         if(!$dump = imagick_image2blob($handle)){
878           gosa_log("Can't create blob for image");
879         }
881         /* Sending Image */
882         $output=  $dump;
884         /* Save attribute */
885         $this->attrs["jpegPhoto"] = $output;
886       }
888     }
890     /* Build new dn */
891     if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
892       $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
893     } else {
894       $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base;
895     }
897     /* This only gets called when user is renaming himself */
898     $ldap= $this->config->get_ldap_link();
899     if ($this->dn != $new_dn){
901       /* Write entry on new 'dn' */
902       $this->move($this->dn, $new_dn);
904       /* Happen to use the new one */
905       change_ui_dn($this->dn, $new_dn);
906       $this->dn= $new_dn;
907     }
910     /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
911        new entries. So do a check first... */
912     $ldap->cat ($this->dn, array('dn'));
913     if ($ldap->fetch()){
914       $mode= "modify";
915     } else {
916       $mode= "add";
917       $ldap->cd($this->config->current['BASE']);
918       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
919     }
921     /* Set password to some junk stuff in case of templates */
922     if ($this->is_template){
923       $this->attrs['userPassword']= '{crypt}N0T$3T4N0W';
924     }
926     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
927         $this->attributes, "Save via $mode");
929     /* Finally write data with selected 'mode' */
930     $this->cleanup();
931     $ldap->cd ($this->dn);
932     $ldap->$mode ($this->attrs);
933     if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/generic account with dn '%s' failed."),$this->dn))){
934       return (1);
935     }
937     /* Remove cert? 
938        For some reason, the 'ldap' class doesn't want to remove binary entries, so I need
939        to work around myself. */
940     if ($remove_userCertificate == true && !$this->is_new && $this->had_userCertificate){
942       /* Reset array, assemble new, this should be reworked */
943       $this->attrs= array();
944       $this->attrs['userCertificate;binary']= array();
946       /* Prepare connection */
947       if (!($ds = ldap_connect($this->config->current['SERVER']))) {
948         die ("Could not connect to LDAP server");
949       }
950       ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
951       if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
952         ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
953         ldap_set_rebind_proc($ds, array(&$this, "rebind"));
954       }
955       if(isset($config->current['TLS']) && $config->current['TLS'] == "true"){
956         ldap_start_tls($ds);
957       }
958       if (!($res = @ldap_bind($ds, $this->config->current['ADMIN'],
959               $this->config->current['PASSWORD']))) {
960         die ("Could not bind to LDAP");
961       }
963       /* Modify using attrs */
964       ldap_mod_del($ds,$this->dn,$this->attrs);
965       ldap_close($ds);
966     }
968     /* Kerberos server defined? */
969     if (isset($this->config->data['SERVERS']['KERBEROS'])){
970       $cfg= $this->config->data['SERVERS']['KERBEROS'];
971     }
972     if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
974       /* Connect to the admin interface */
975       $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
976           $cfg['ADMIN'], $cfg['PASSWORD']);
978       /* Errors? */             
979       if ($handle === FALSE){
980         print_red (_("Kerberos database communication failed"));
981         return (2);
982       }
984       /* Build user principal, get list of existsing principals */
985       $principal= $this->uid."@".$cfg['REALM'];
986       $principals = kadm5_get_principals($handle);
988       /* User exists in database? */
989       if (in_array($principal, $principals)){
991         /* Ok. User exists. Remove him/her when pw_storage has
992            changed to be NOT kerberos. */
993         if ($this->pw_storage != $this->config->current['KRBSASL']){
994           $ret= kadm5_delete_principal ( $handle, $principal);
996           if ($ret === FALSE){
997             print_red (_("Can't remove user from kerberos database."));
998           }
999         }
1001       } else {
1003         /* User doesn't exists, create it when pw_storage is kerberos. */
1004         if ($this->pw_storage == "kerberos" || $this->pw_storage == "sasl" ){
1005           $ret= kadm5_create_principal ( $handle, $principal);
1007           if ($ret === FALSE){
1008             print_red (_("Can't add user to kerberos database."));
1009           }
1010         }
1012       }
1014       /* Free kerberos admin handle */
1015       kadm5_destroy($handle);
1016     }
1018     /* Optionally execute a command after we're done */
1019     if ($mode == "add"){
1020       $this->handle_post_events("add", array("uid" => $this->uid));
1021     } elseif ($this->is_modified){
1022       $this->handle_post_events("modify", array("uid" => $this->uid));
1023     }
1025     /* Fix tagging if needed */
1026     $this->handle_object_tagging();
1028     return (0);
1029   }
1032   /* Check formular input */
1033   function check()
1034   {
1035     /* Call common method to give check the hook */
1036     $message= plugin::check();
1038     /* Assemble cn */
1039     $this->cn= $this->givenName." ".$this->sn;
1041     /* Permissions for that base? */
1042     if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
1043       $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
1044     } else {
1045       $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base;
1046     }
1048     /* Set the new acl base */
1049     if($this->dn == "new") {
1050       $this->set_acl_base($this->base);
1051     }
1053     if ($this->dn == "new" &&  !$this->acl_is_createable()){
1054       $message[]= _("You have no permissions to create a user on this 'Base'.");
1055     } elseif ($this->dn != $new_dn && $this->dn != "new"){
1056       if (!$this->acl_is_writeable($this->dn, "user","create",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1057         $message[]= _("You have no permissions to move this user to the specified 'Base'.");
1058       }
1059     }
1061     /* must: sn, givenName, uid */
1062     if ($this->sn == "" && ($this->acl_is_writeable("sn",(!is_object($this->parent) && !isset($_SESSION['edit'])) || ($this->is_new)))){
1063       $message[]= _("The required field 'Name' is not set.");
1064     }
1066     /* UID already used? */
1067     $ldap= $this->config->get_ldap_link();
1068     $ldap->cd($this->config->current['BASE']);
1069     $ldap->search("(uid=$this->uid)", array("uid"));
1070     $ldap->fetch();
1071     if ($ldap->count() != 0 && $this->dn == 'new'){
1072       $message[]= _("There's already a person with this 'Login' in the database.");
1073     }
1075     /* In template mode, the uid and givenName are autogenerated... */
1076     if (!$this->is_template){
1077       if ($this->givenName == "" && $this->acl_is_writeable("givenName",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1078         $message[]= _("The required field 'Given name' is not set.");
1079       }
1080       if ($this->uid == "" && $this->acl_is_writeable("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1081         $message[]= _("The required field 'Login' is not set.");
1082       }
1083       if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
1084         $ldap->cd($this->config->current['BASE']);
1085         $ldap->search("(cn=".$this->cn.")", array("uid"));
1086         $ldap->fetch();
1087         if ($ldap->count() != 0 && $this->dn != $new_dn && $this->dn == 'new'){
1088           $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
1089         }
1090       }
1091     }
1093     /* Check for valid input */
1094     if ($this->is_modified && !is_uid($this->uid)){
1095       $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed.");
1096     }
1097     if (!is_url($this->labeledURI)){
1098       $message[]= _("The field 'Homepage' contains an invalid URL definition.");
1099     }
1100     if (preg_match ("/[\\\\]/", $this->sn)){
1101       $message[]= _("The field 'Name' contains invalid characters.");
1102     }
1103     if (preg_match ("/[\\\\]/", $this->givenName)){
1104       $message[]= _("The field 'Given name' contains invalid characters.");
1105     }
1107     /* Check phone numbers */
1108     if (!is_phone_nr($this->telephoneNumber)){
1109       $message[]= _("The field 'Phone' contains an invalid phone number.");
1110     }
1111     if (!is_phone_nr($this->facsimileTelephoneNumber)){
1112       $message[]= _("The field 'Fax' contains an invalid phone number.");
1113     }
1114     if (!is_phone_nr($this->mobile)){
1115       $message[]= _("The field 'Mobile' contains an invalid phone number.");
1116     }
1117     if (!is_phone_nr($this->pager)){
1118       $message[]= _("The field 'Pager' contains an invalid phone number.");
1119     }
1121     /* Check for reserved characers */
1122     if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName)){
1123       $message[]= _("The field 'Given name' contains invalid characters.");
1124     }
1125     if (preg_match ('/[,+"?\'()=<>;]/', $this->sn)){
1126       $message[]= _("The field 'Name' contains invalid characters.");
1127     }
1129   return $message;
1130   }
1133   /* Indicate whether a password change is needed or not */
1134   function password_change_needed()
1135   {
1136     return ($this->pw_storage != $this->last_pw_storage);
1137   }
1140   /* Load a jpegPhoto from LDAP, this is going to be simplified later on */
1141   function load_picture()
1142   {
1143     $ldap = $this->config->get_ldap_link();
1144     $ldap->cd ($this->dn);
1145     $data = $ldap->get_attribute($this->dn,"jpegPhoto");
1146       
1147     if((!$data) || ($data == "*removed*")){ 
1149       /* In case we don't get an entry, load a default picture */
1150       $this->set_picture ();//"./images/default.jpg");
1151       $this->jpegPhoto= "*removed*";
1152     }else{
1154       /* Set picture */
1155       $this->photoData= $data;
1156       $_SESSION['binary']= $this->photoData;
1157       $_SESSION['binarytype']= "image/jpeg";
1158       $this->jpegPhoto= "";
1159     }
1160   }
1163   /* Load a certificate from LDAP, this is going to be simplified later on */
1164   function load_cert()
1165   {
1166     $ds= ldap_connect($this->config->current['SERVER']);
1167     ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
1168     if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
1169       ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
1170       ldap_set_rebind_proc($ds, array(&$this, "rebind"));
1171     }
1172     if(isset($this->config->current['TLS']) &&
1173         $this->config->current['TLS'] == "true"){
1175       ldap_start_tls($ds);
1176     }
1178     $r= ldap_bind($ds);
1179     $sr= @ldap_read($ds, $this->dn, "userCertificate=*", array("userCertificate"));
1181     if ($sr) {
1182       $ei= @ldap_first_entry($ds, $sr);
1183       
1184       if ($ei) {
1185         if (!$info = @ldap_get_values_len($ds, $ei, "userCertificate;binary")){
1186           $this->userCertificate= "";
1187         } else {
1188           $this->userCertificate= $info[0];
1189         }
1190       }
1191     } else {
1192       $this->userCertificate= "";
1193     }
1195     ldap_unbind($ds);
1196   }
1199   /* Load picture from file to object */
1200   function set_picture($filename ="")
1201   {
1202     if (!is_file($filename) || $filename =="" ){
1203       $filename= "./images/default.jpg";
1204       $this->jpegPhoto= "*removed*";
1205     }
1207     $fd = fopen ($filename, "rb");
1208     $this->photoData= fread ($fd, filesize ($filename));
1209     $_SESSION['binary']= $this->photoData;
1210     $_SESSION['binarytype']= "image/jpeg";
1211     $this->jpegPhoto= "";
1213     fclose ($fd);
1214   }
1217   /* Load certificate from file to object */
1218   function set_cert($cert, $filename)
1219   {
1220     if(!$thsi->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))) return;
1221     $fd = fopen ($filename, "rb");
1222     if (filesize($filename)>0) {
1223       $this->$cert= fread ($fd, filesize ($filename));
1224       fclose ($fd);
1225       $this->is_modified= TRUE;
1226     } else {
1227       print_red(_("Could not open specified certificate!"));
1228     }
1229   }
1231   /* Adapt from given 'dn' */
1232   function adapt_from_template($dn)
1233   {
1234     plugin::adapt_from_template($dn);
1236     /* Get base */
1237     $this->base= preg_replace('/^[^,]+,'.get_people_ou().'/i', '', $dn);
1239     if ($this->config->current['GOVERNMENTMODE']){
1241       /* Walk through govattrs */
1242       foreach ($this->govattrs as $val){
1244         if (isset($this->attrs["$val"][0])){
1246           /* If attribute is set, replace dynamic parts: 
1247              %sn, %givenName and %uid. Fill these in our local variables. */
1248           $value= $this->attrs["$val"][0];
1250           foreach (array("sn", "givenName", "uid") as $repl){
1251             if (preg_match("/%$repl/i", $value)){
1252               $value= preg_replace ("/%$repl/i",
1253                   $this->parent->$repl, $value);
1254             }
1255           }
1256           $this->$val= $value;
1257         }
1258       }
1259     }
1261     /* Get back uid/sn/givenName */
1262     if ($this->parent != NULL){
1263       $this->uid= $this->parent->uid;
1264       $this->sn= $this->parent->sn;
1265       $this->givenName= $this->parent->givenName;
1266     }
1267   }
1269  
1270   /* This avoids that users move themselves out of their rights. 
1271    */
1272   function allowedBasesToMoveTo()
1273   {
1274     /* Get bases */
1275     $bases  = $this->get_allowed_bases();
1276     return($bases);
1277   } 
1280   function getCopyDialog()
1281   {
1282     $str = "";
1284     $_SESSION['binary'] = $this->photoData; 
1285     $_SESSION['binarytype']= "image/jpeg";
1287     /* Get random number for pictures */
1288     srand((double)microtime()*1000000); 
1289     $rand = rand(0, 10000);
1291     $smarty = get_smarty();
1293     $smarty->assign("passwordTodo","clear");
1295     if(isset($_POST['passwordTodo'])){
1296       $smarty->assign("passwordTodo",$_POST['passwordTodo']);
1297     }
1299     $smarty->assign("sn",       $this->sn);
1300     $smarty->assign("givenName",$this->givenName);
1301     $smarty->assign("uid",      $this->uid);
1302     $smarty->assign("rand",     $rand);
1303     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
1306     $ret = array();
1307     $ret['string'] = $str;
1308     $ret['status'] = "";  
1309     return($ret);
1310   }
1312   function saveCopyDialog()
1313   {
1314     /* Set_acl_base */
1315     $this->set_acl_base("cn=dummy,".get_people_ou().$this->base);
1317     if((isset($_FILES['picture_file']['tmp_name'])) && ($_FILES['picture_file']['size'] > 0)){
1318       $this->set_picture($_FILES['picture_file']['tmp_name']);
1319     }
1321     /* Remove picture? */
1322     if (isset($_POST['picture_remove'])){
1323       $this->jpegPhoto= "*removed*";
1324       $this->set_picture ("./images/default.jpg");
1325       $this->is_modified= TRUE;
1326     }
1328     $attrs = array("uid","givenName","sn");
1329     foreach($attrs as $attr){
1330       if(isset($_POST[$attr])){
1331         $this->$attr = $_POST[$attr];
1332       }
1333     } 
1334   }
1337   function PrepareForCopyPaste($source)
1338   {
1339     plugin::PrepareForCopyPaste($source);
1341     /* Reset certificate information addepted from source user
1342        to avoid setting the same user certificate for the destination user. */
1343     $this->userPKCS12= "";
1344     $this->userSMIMECertificate= "";
1345     $this->userCertificate= "";
1346     $this->certificateSerialNumber= "";
1347     $this->old_certificateSerialNumber= "";
1348     $this->old_userPKCS12= "";
1349     $this->old_userSMIMECertificate= "";
1350     $this->old_userCertificate= "";
1351   }
1354   function plInfo()
1355   {
1356   
1357     $govattrs= array(
1358         "gouvernmentOrganizationalUnit"             =>  _("Unit"), 
1359         "houseIdentifier"                           =>  _("House identifier"), 
1360         "vocation"                                  =>  _("Vocation"),
1361         "ivbbLastDeliveryCollective"                =>  _("Last delivery"), 
1362         "gouvernmentOrganizationalPersonLocality"   =>  _("Person locality"),
1363         "gouvernmentOrganizationalUnitDescription"  =>  _("Unit description"),
1364         "gouvernmentOrganizationalUnitSubjectArea"  =>  _("Subject area"),
1365         "functionalTitle"                           =>  _("Functional title"),
1366         "certificateSerialNumber"                   =>  _(""),
1367         "publicVisible"                             =>  _("Public visible"),
1368         "street"                                    =>  _("Street"),
1369         "role"                                      =>  _("Role"),
1370         "postalCode"                                =>  _("Postal code"));
1372     $ret = array(
1373         "plShortName" => _("Generic"),
1374         "plDescription" => _("Generic user settings"),
1375         "plSelfModify"  => TRUE,
1376         "plDepends"     => array(),
1377         "plPriority"    => 1,
1378         "plSection"     => array("personal" => _("My account")),
1379         "plCategory"    => array("users" => array("description" => _("Users"),
1380                                                   "objectClass" => "gosaAccount")),
1382         "plProvidedAcls" => array(
1383           "base"              => _("Base"), 
1384           "userPassword"      => _("User password"), 
1385           "sn"                => _("Surename"),
1386           "givenName"         => _("Given name"),
1387           "uid"               => _("User identification"),
1388           "personalTitle"     => _("Personal title"),
1389           "academicTitle"     => _("Academic title"),
1390           "homePostalAddress" => _("Home postal address"),
1391           "homePhone"         => _("Home phone number"),
1392           "labeledURI"        => _("Homepage"),
1393           "o"                 => _("Organization"),
1394           "ou"                => _("Department"),
1395           "dateOfBirth"       => _("Date of birth"),
1396           "gender"            => _("Gender"),
1397           "preferredLanguage" => _("Preferred language"),
1398           "departmentNumber"  => _("Department number"),
1399           "employeeNumber"    => _("Employee number"),
1400           "employeeType"      => _("Employee type"),
1401           "l"                 => _("Location"),
1402           "st"                => _("State"),
1403           "userPicture"       => _("User picture"),
1404           "roomNumber"        => _("Room number"),
1405           "telephoneNumber"   => _("Telefon number"),
1406           "mobile"            => _("Mobile number"),
1407           "pager"             => _("Pager number"),
1408           "Certificate"        => _("User certificates"),
1410           "postalAddress"                => _("Postal address"),
1411           "facsimileTelephoneNumber"     => _("Fax number"))
1412         );
1414     /* Append government attributes if required */
1415       global $config;
1416     if (isset($config->current['GOVERNMENTMODE']) &&  preg_match('/true/i', $config->current['GOVERNMENTMODE'])){
1417       foreach($govattrs as $attr => $desc){
1418         $ret["plProvidedAcls"][$attr] = $desc;
1419       }
1420     }
1422     return($ret);
1423   }
1426 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1427 ?>