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 $new_dn= "";
28 var $personalTitle= "";
29 var $academicTitle= "";
30 var $homePostalAddress= "";
31 var $homePhone= "";
32 var $labeledURI= "";
33 var $o= "";
34 var $ou= "";
35 var $departmentNumber= "";
36 var $employeeNumber= "";
37 var $employeeType= "";
38 var $roomNumber= "";
39 var $telephoneNumber= "";
40 var $facsimileTelephoneNumber= "";
41 var $mobile= "";
42 var $pager= "";
43 var $l= "";
44 var $st= "";
45 var $postalAddress= "";
46 var $dateOfBirth;
47 var $use_dob= "0";
48 var $gender="0";
49 var $preferredLanguage="0";
51 var $jpegPhoto= "*removed*";
52 var $photoData= "";
53 var $old_jpegPhoto= "";
54 var $old_photoData= "";
55 var $cert_dialog= FALSE;
56 var $picture_dialog= FALSE;
58 var $userPKCS12= "";
59 var $userSMIMECertificate= "";
60 var $userCertificate= "";
61 var $certificateSerialNumber= "";
62 var $old_certificateSerialNumber= "";
63 var $old_userPKCS12= "";
64 var $old_userSMIMECertificate= "";
65 var $old_userCertificate= "";
67 var $gouvernmentOrganizationalUnit= "";
68 var $houseIdentifier= "";
69 var $street= "";
70 var $postalCode= "";
71 var $vocation= "";
72 var $ivbbLastDeliveryCollective= "";
73 var $gouvernmentOrganizationalPersonLocality= "";
74 var $gouvernmentOrganizationalUnitDescription= "";
75 var $gouvernmentOrganizationalUnitSubjectArea= "";
76 var $functionalTitle= "";
77 var $role= "";
78 var $publicVisible= "";
80 var $dialog;
82 /* variables to trigger password changes */
83 var $pw_storage= "crypt";
84 var $last_pw_storage= "unset";
85 var $had_userCertificate= FALSE;
87 /* attribute list for save action */
88 var $attributes= array("sn", "givenName", "uid", "personalTitle", "academicTitle",
89 "homePostalAddress", "homePhone", "labeledURI", "ou", "o", "dateOfBirth", "gender","preferredLanguage",
90 "departmentNumber", "employeeNumber", "employeeType", "l", "st","jpegPhoto",
91 "roomNumber", "telephoneNumber", "mobile", "pager", "cn", "userPKCS12",
92 "postalAddress", "facsimileTelephoneNumber", "userSMIMECertificate");
94 var $objectclasses= array("top", "person", "organizationalPerson", "inetOrgPerson",
95 "gosaAccount");
97 /* attributes that are part of the government mode */
98 var $govattrs= array("gouvernmentOrganizationalUnit", "houseIdentifier", "vocation",
99 "ivbbLastDeliveryCollective", "gouvernmentOrganizationalPersonLocality",
100 "gouvernmentOrganizationalUnitDescription","gouvernmentOrganizationalUnitSubjectArea",
101 "functionalTitle", "certificateSerialNumber", "publicVisible", "street", "role",
102 "postalCode");
105 /* constructor, if 'dn' is set, the node loads the given
106 'dn' from LDAP */
107 function user ($config, $dn= NULL)
108 {
109 $this->config= $config;
110 /* Configuration is fine, allways */
111 if ($this->config->current['GOVERNMENTMODE']){
112 $this->attributes=array_merge($this->attributes,$this->govattrs);
113 }
115 /* Load base attributes */
116 plugin::plugin ($config, $dn);
118 if ($this->config->current['GOVERNMENTMODE']){
119 /* Fix public visible attribute if unset */
120 if (!isset($this->attrs['publicVisible'])){
121 $this->publicVisible == "nein";
122 }
123 }
125 /* Load government mode attributes */
126 if ($this->config->current['GOVERNMENTMODE']){
127 /* Copy all attributs */
128 foreach ($this->govattrs as $val){
129 if (isset($this->attrs["$val"][0])){
130 $this->$val= $this->attrs["$val"][0];
131 }
132 }
133 }
135 /* Create me for new accounts */
136 if ($dn == "new"){
137 $this->is_account= TRUE;
138 }
140 /* Make hash default to md5 if not set in config */
141 if (!isset($this->config->current['HASH'])){
142 $hash= "md5";
143 } else {
144 $hash= $this->config->current['HASH'];
145 }
147 /* Load data from LDAP? */
148 if ($dn != NULL){
150 /* Do base conversation */
151 if ($this->dn == "new"){
152 $ui= get_userinfo();
153 $this->base= dn2base($ui->dn);
154 } else {
155 $this->base= dn2base($dn);
156 }
158 /* get password storage type */
159 if (isset ($this->attrs['userPassword'][0])){
160 /* Initialize local array */
161 $matches= array();
162 if (preg_match ("/^{([^}]+)}(.+)/", $this->attrs['userPassword'][0], $matches)){
163 $this->pw_storage= strtolower($matches[1]);
164 } else {
165 if ($this->attrs['userPassword'][0] != ""){
166 $this->pw_storage= "clear";
167 } else {
168 $this->pw_storage= $hash;
169 }
170 }
171 } else {
172 /* Preset with vaule from configuration */
173 $this->pw_storage= $hash;
174 }
176 /* Load extra attributes: certificate and picture */
177 $this->load_cert();
178 $this->load_picture();
179 if ($this->userCertificate != ""){
180 $this->had_userCertificate= TRUE;
181 }
182 }
184 /* Reset password storage indicator, used by password_change_needed() */
185 if ($dn == "new"){
186 $this->last_pw_storage= "unset";
187 } else {
188 $this->last_pw_storage= $this->pw_storage;
189 }
191 /* Generate dateOfBirth entry */
192 if (isset ($this->attrs['dateOfBirth'])){
193 /* This entry is ISO 8601 conform */
194 list($year, $month, $day)= split("-", $this->attrs['dateOfBirth'][0], 3);
196 $this->dateOfBirth=array( 'mon'=> $month,"mday"=> $day,"year"=> $year);
197 $this->use_dob= "1";
198 } else {
199 $this->use_dob= "0";
200 }
202 /* Put gender attribute to upper case */
203 if (isset ($this->attrs['gender'])){
204 $this->gender= strtoupper($this->attrs['gender'][0]);
205 }
206 }
209 /* execute generates the html output for this node */
210 function execute()
211 {
212 /* Call parent execute */
213 plugin::execute();
215 $smarty= get_smarty();
217 /* Fill calendar */
218 if ($this->dateOfBirth == "0"){
219 $date= getdate();
220 } else {
221 if(is_array($this->dateOfBirth)){
222 $date = $this->dateOfBirth;
224 // Trigger on dates like 1985-04-01, getdate only understands timestamps
225 } else if (!empty($this->dateOfBirth) && !is_numeric($this->dateOfBirth)){
226 $date= getdate(strtotime($this->dateOfBirth));
228 } else {
229 $date = getdate($this->dateOfBirth);
230 }
231 }
233 $days= array();
234 for($d= 1; $d<32; $d++){
235 $days[$d]= $d;
236 }
237 $years= array();
239 if(($date['year']-100)<1901){
240 $start = 1901;
241 }else{
242 $start = $date['year']-100;
243 }
245 $end = $start +100;
247 for($y= $start; $y<=$end; $y++){
248 $years[]= $y;
249 }
250 $years['-']= "- ";
251 $months= array(_("January"), _("February"), _("March"), _("April"),
252 _("May"), _("June"), _("July"), _("August"), _("September"),
253 _("October"), _("November"), _("December"), '-' => '- ');
254 $smarty->assign("day", $date["mday"]);
255 $smarty->assign("days", $days);
256 $smarty->assign("months", $months);
257 $smarty->assign("month", $date["mon"]-1);
258 $smarty->assign("years", $years);
259 $smarty->assign("year", $date["year"]);
261 /* Assign sex */
262 $sex= array(0 => " ", "F" => _("female"), "M" => _("male"));
263 $smarty->assign("gender_list", $sex);
265 /* Assign prefered langage */
266 $language= array(0 => " ", "fr_FR" => ("fr_FR"), "en_EN" => ("en_EN"),
267 "de_DE" => ("de_DE"), "it_IT" => ("it_IT"),
268 "nl_NL" => ("nl_NL"), "ru_RU" => ("ru_RU"));
269 $smarty->assign("preferredLanguage_list", $language);
271 /* Get random number for pictures */
272 srand((double)microtime()*1000000);
273 $smarty->assign("rand", rand(0, 10000));
276 /* Do we represent a valid gosaAccount? */
277 if (!$this->is_account){
278 echo "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
279 _("This account has no valid GOsa extensions.")."</b>";
280 return;
281 }
283 /* Base select dialog */
284 $once = true;
285 foreach($_POST as $name => $value){
286 if(preg_match("/^chooseBase/",$name) && $once){
287 $once = false;
288 $this->dialog = new baseSelectDialog($this->config,$this,$this->allowedBasesToMoveTo());
289 $this->dialog->setCurrentBase($this->base);
290 }
291 }
293 /* Dialog handling */
294 if(is_object($this->dialog)){
295 /* Must be called before save_object */
296 $this->dialog->save_object();
298 if($this->dialog->isClosed()){
299 $this->dialog = false;
300 }elseif($this->dialog->isSelected()){
302 /* check if selected base is allowed to move to / create a new object */
303 $tmp = $this->get_allowed_bases();
304 if(isset($tmp[$this->dialog->isSelected()])){
305 $this->base = $this->dialog->isSelected();
306 }
307 $this->dialog= false;
308 }else{
309 return($this->dialog->execute());
310 }
311 }
313 /* Want picture edit dialog? */
314 if($this->acl_is_writeable("userPicture")) {
315 if (isset($_POST['edit_picture'])){
316 /* Save values for later recovery, in case some presses
317 the cancel button. */
318 $this->old_jpegPhoto= $this->jpegPhoto;
319 $this->old_photoData= $this->photoData;
320 $this->picture_dialog= TRUE;
321 $this->dialog= TRUE;
322 }
323 }
325 /* Remove picture? */
326 if($this->acl_is_writeable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))) ){
327 if (isset($_POST['picture_remove'])){
328 $this->set_picture ();
329 $this->jpegPhoto= "*removed*";
330 $this->is_modified= TRUE;
331 return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
332 }
333 }
335 /* Save picture */
336 if (isset($_POST['picture_edit_finish'])){
338 /* Check for clean upload */
339 if ($_FILES['picture_file']['name'] != ""){
340 if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) {
341 print_red(_("The specified file has not been uploaded via HTTP POST! Aborted."));
342 }else{
343 /* Activate new picture */
344 $this->set_picture($_FILES['picture_file']['tmp_name']);
345 }
346 }
347 $this->picture_dialog= FALSE;
348 $this->dialog= FALSE;
349 $this->is_modified= TRUE;
350 }
353 /* Cancel picture */
354 if (isset($_POST['picture_edit_cancel'])){
356 /* Restore values */
357 $this->jpegPhoto= $this->old_jpegPhoto;
358 $this->photoData= $this->old_photoData;
360 /* Update picture */
361 $_SESSION['binary']= $this->photoData;
362 $_SESSION['binarytype']= "image/jpeg";
363 $this->picture_dialog= FALSE;
364 $this->dialog= FALSE;
365 }
367 /* Toggle dateOfBirth information */
368 if (isset($_POST['set_dob'])){
369 $this->use_dob= ($this->use_dob == "0")?"1":"0";
370 }
373 /* Want certificate= */
374 if ((isset($_POST['edit_cert'])) && $this->acl_is_readable("Certificate")){
376 /* Save original values for later reconstruction */
377 foreach (array("certificateSerialNumber", "userCertificate",
378 "userSMIMECertificate", "userPKCS12") as $val){
380 $oval= "old_$val";
381 $this->$oval= $this->$val;
382 }
384 $this->cert_dialog= TRUE;
385 $this->dialog= TRUE;
386 }
389 /* Cancel certificate dialog */
390 if (isset($_POST['cert_edit_cancel'])){
392 /* Restore original values in case of 'cancel' */
393 foreach (array("certificateSerialNumber", "userCertificate",
394 "userSMIMECertificate", "userPKCS12") as $val){
396 $oval= "old_$val";
397 $this->$val= $this->$oval;
398 }
399 $this->cert_dialog= FALSE;
400 $this->dialog= FALSE;
401 }
404 /* Remove certificate? */
405 if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
406 foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") as $val){
407 if (isset($_POST["remove_$val"])){
409 /* Reset specified cert*/
410 $this->$val= "";
411 $this->is_modified= TRUE;
412 }
413 }
414 }
416 /* Upload new cert and close dialog? */
417 if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
418 if (isset($_POST['cert_edit_finish'])){
420 /* for all certificates do */
421 foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12")
422 as $val){
424 /* Check for clean upload */
425 if (array_key_exists($val."_file", $_FILES) &&
426 array_key_exists('name', $_FILES[$val."_file"]) &&
427 $_FILES[$val."_file"]['name'] != "" &&
428 is_uploaded_file($_FILES[$val."_file"]['tmp_name'])) {
429 $this->set_cert("$val", $_FILES[$val."_file"]['tmp_name']);
430 }
431 }
433 /* Save serial number */
434 if (isset($_POST["certificateSerialNumber"]) &&
435 $_POST["certificateSerialNumber"] != ""){
437 if (!is_id($_POST["certificateSerialNumber"])){
438 print_red (_("Please enter a valid serial number"));
440 foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
441 if ($this->$cert != ""){
442 $smarty->assign("$cert"."_state", "true");
443 } else {
444 $smarty->assign("$cert"."_state", "");
445 }
446 }
447 return ($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
448 }
450 $this->certificateSerialNumber= $_POST["certificateSerialNumber"];
451 $this->is_modified= TRUE;
452 }
454 $this->cert_dialog= FALSE;
455 $this->dialog= FALSE;
456 }
457 }
458 /* Display picture dialog */
459 if ($this->picture_dialog){
460 return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
461 }
463 /* Display cert dialog */
464 if ($this->cert_dialog){
465 $smarty->assign("CertificateACL",$this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
466 $smarty->assign("Certificate_readable",$this->acl_is_readable("Certificate"));
468 foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
469 if ($this->$cert != ""){
470 /* import certificate */
471 $certificate = new certificate;
472 $certificate->import($this->$cert);
474 /* Read out data*/
475 $timeto = $certificate->getvalidto_date();
476 $timefrom = $certificate->getvalidfrom_date();
479 /* Additional info if start end time is '0' */
480 $add_str_info = "";
481 if($timeto == 0 && $timefrom == 0){
482 $add_str_info = "<br><i>"._("(Some types of certificates are currently not supported and may be displayed as 'invalid'.)")."</i>";
483 }
485 $str = "<table summary=\"\" border=0>
486 <tr>
487 <td style='vertical-align:top'>CN</td>
488 <td>".preg_replace("/ /", " ", $certificate->getname())."</td>
489 </tr>
490 </table><br>".
492 sprintf(_("Certificate is valid from %s to %s and is currently %s."),
493 "<b>".date('d M Y',$timefrom)."</b>",
494 "<b>".date('d M Y',$timeto)."</b>",
495 $certificate->isvalid()?"<b><font style='color:green'>"._("valid")."</font></b>":
496 "<b><font style='color:red'>"._("invalid")."</font></b>").$add_str_info;
498 $smarty->assign($cert."info",$str);
499 $smarty->assign($cert."_state","true");
500 } else {
501 $smarty->assign($cert."info", "<i>"._("No certificate installed")."</i>");
502 $smarty->assign($cert."_state","");
503 }
504 }
505 $smarty->assign("governmentmode", "false");
506 return($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
507 }
509 /* Prepare password hashes */
510 if ($this->pw_storage == ""){
511 $this->pw_storage= $this->config->current['HASH'];
512 }
514 $temp = @passwordMethod::get_available_methods();
515 $hashes = $temp['name'];
517 /* Load attributes and acl's */
518 $ui =get_userinfo();
519 foreach($this->attributes as $val){
520 $smarty->assign("$val", $this->$val);
521 }
523 /* Set acls */
524 $tmp = $this->plinfo();
525 foreach($tmp['plProvidedAcls'] as $val => $translation){
526 $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
527 }
529 $smarty->assign("pwmode", $hashes);
530 $smarty->assign("pwmode_select", $this->pw_storage);
531 $smarty->assign("passwordStorageACL", $this->getacl("userPassword",(!is_object($this->parent) && !isset($_SESSION['edit']))));
532 $smarty->assign("base_select", $this->base);
533 $smarty->assign("CertificatesACL", $this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
534 $smarty->assign("userPictureACL", $this->getacl("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
535 $smarty->assign("userPicture_is_readable", $this->acl_is_readable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
537 /* Create base acls */
538 @$smarty->assign("bases", $this->allowedBasesToMoveTo());
540 /* Save government mode attributes */
541 if (isset($this->config->current['GOVERNMENTMODE']) &&
542 preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){
543 $smarty->assign("governmentmode", "true");
544 $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet",
545 "internet,ivbv", "internet,testa", "internet,ivbv,testa");
546 $smarty->assign("ivbbmodes", $ivbbmodes);
547 foreach ($this->govattrs as $val){
548 $smarty->assign("$val", $this->$val);
549 $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
550 }
551 } else {
552 $smarty->assign("governmentmode", "false");
553 }
555 /* Special mode for uid */
556 $uidACL= $this->getacl("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])));
557 if (isset ($this->dn)){
558 if ($this->dn != "new"){
559 $uidACL= preg_replace("/w/","",$uidACL);
560 }
561 } else {
562 $uidACL= preg_replace("/w/","",$uidACL);
563 }
565 $smarty->assign("uidACL", $uidACL);
566 $smarty->assign("is_template", $this->is_template);
567 $smarty->assign("use_dob", $this->use_dob);
569 if (isset($this->parent)){
570 if (isset($this->parent->by_object['phoneAccount']) &&
571 $this->parent->by_object['phoneAccount']->is_account){
572 $smarty->assign("has_phoneaccount", "true");
573 } else {
574 $smarty->assign("has_phoneaccount", "false");
575 }
576 } else {
577 $smarty->assign("has_phoneaccount", "false");
578 }
579 return($smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))));
580 }
583 /* remove object from parent */
584 function remove_from_parent()
585 {
586 $ldap= $this->config->get_ldap_link();
587 $ldap->rmdir ($this->dn);
588 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/generic account with dn '%s' failed."),$this->dn));
590 /* Delete references to groups */
591 $ldap->cd ($this->config->current['BASE']);
592 $ldap->search ("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("uid"));
593 while ($ldap->fetch()){
594 $g= new group($this->config, $ldap->getDN());
595 $g->removeUser($this->uid);
596 $g->save ();
597 }
599 /* Delete references to object groups */
600 $ldap->cd ($this->config->current['BASE']);
601 $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
602 while ($ldap->fetch()){
603 $og= new ogroup($this->config, $ldap->getDN());
604 unset($og->member[$this->dn]);
605 $og->save ();
606 }
608 /* Kerberos server defined? */
609 if (isset($this->config->data['SERVERS']['KERBEROS'])){
610 $cfg= $this->config->data['SERVERS']['KERBEROS'];
611 }
612 if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
614 /* Connect to the admin interface */
615 $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
616 $cfg['ADMIN'], $cfg['PASSWORD']);
618 /* Errors? */
619 if ($handle === FALSE){
620 print_red (_("Kerberos database communication failed"));
621 return (2);
622 }
624 /* Build user principal, get list of existsing principals */
625 $principal= $this->uid."@".$cfg['REALM'];
626 $principals = kadm5_get_principals($handle);
628 /* User exists in database? */
629 if (in_array($principal, $principals)){
631 /* Ok. User exists. Remove him/her */
632 $ret= kadm5_delete_principal ( $handle, $principal);
633 if ($ret === FALSE){
634 print_red (_("Can't remove user from kerberos database."));
635 }
636 }
638 /* Free kerberos admin handle */
639 kadm5_destroy($handle);
640 }
643 /* Optionally execute a command after we're done */
644 $this->handle_post_events("remove",array("uid" => $this->uid));
645 }
648 /* Save data to object */
649 function save_object()
650 {
651 if (isset($_POST['generic'])){
653 /* Make a backup of the current selected base */
654 $base_tmp = $this->base;
656 /* Parents save function */
657 plugin::save_object ();
659 /* Save government mode attributes */
660 if ($this->config->current['GOVERNMENTMODE']){
661 foreach ($this->govattrs as $val){
662 if ($this->acl_is_writeable($val,(!is_object($this->parent) && !isset($_SESSION['edit']))) && isset($_POST["$val"])){
663 $data= stripcslashes($_POST["$val"]);
664 if ($data != $this->$val){
665 $this->is_modified= TRUE;
666 }
667 $this->$val= $data;
668 }
669 }
670 }
672 /* In template mode, the uid is autogenerated... */
673 if ($this->is_template){
674 $this->uid= strtolower($this->sn);
675 $this->givenName= $this->sn;
676 }
678 /* Save base and pw_storage, since these are no LDAP attributes */
679 if (isset($_POST['base'])){
681 $tmp = $this->get_allowed_bases();
682 if(isset($tmp[$_POST['base']])){
683 $base= validate($_POST['base']);
684 if ($base != $this->base){
685 $this->is_modified= TRUE;
686 }
687 $this->base= $base;
688 }else{
689 $this->base = $base_tmp;
690 print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base'])));
691 $this->set_acl_base('dummy,'.$this->base);
692 }
693 }
695 /* Get pw_storage mode */
696 if (isset($_POST['pw_storage'])){
697 foreach(array("pw_storage") as $val){
698 if(isset($_POST[$val])){
699 $data= validate($_POST[$val]);
700 if ($data != $this->$val){
701 $this->is_modified= TRUE;
702 }
703 $this->$val= $data;
704 }
705 }
706 }
708 $this->set_acl_base('dummy,'.$this->base);
709 }
710 }
712 function rebind($ldap, $referral)
713 {
714 $credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']);
715 if (ldap_bind($ldap, $credentials['ADMIN'], $credentials['PASSWORD'])) {
716 $this->error = "Success";
717 $this->hascon=true;
718 $this->reconnect= true;
719 return (0);
720 } else {
721 $this->error = "Could not bind to " . $credentials['ADMIN'];
722 return NULL;
723 }
724 }
726 /* Save data to LDAP, depending on is_account we save or delete */
727 function save()
728 {
729 /* Only force save of changes ....
730 If this attributes aren't changed, avoid saving.
731 */
732 if($this->gender=="0") $this->gender ="";
733 if($this->preferredLanguage=="0") $this->preferredLanguage ="";
736 /* First use parents methods to do some basic fillup in $this->attrs */
737 plugin::save ();
739 if ($this->use_dob == "1"){
740 /* 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. */
741 if(!is_array($this->attrs['dateOfBirth'])) {
742 $this->attrs['dateOfBirth'] = date("Y-m-d", $this->dateOfBirth);
743 }
744 }
746 /* Remove additional objectClasses */
747 $tmp= array();
748 foreach ($this->attrs['objectClass'] as $key => $set){
749 $found= false;
750 foreach (array("ivbbentry", "gosaUserTemplate") as $val){
751 if (preg_match ("/^$set$/i", $val)){
752 $found= true;
753 break;
754 }
755 }
756 if (!$found){
757 $tmp[]= $set;
758 }
759 }
761 /* Replace the objectClass array. This is done because of the
762 separation into government and normal mode. */
763 $this->attrs['objectClass']= $tmp;
765 /* Add objectClasss for template mode? */
766 if ($this->is_template){
767 $this->attrs['objectClass'][]= "gosaUserTemplate";
768 }
770 /* Hard coded government mode? */
771 if ($this->config->current['GOVERNMENTMODE'] != 'false'){
772 $this->attrs['objectClass'][]= "ivbbentry";
774 /* Copy standard attributes */
775 foreach ($this->govattrs as $val){
776 if ($this->$val != ""){
777 $this->attrs["$val"]= $this->$val;
778 } elseif (!$this->is_new) {
779 $this->attrs["$val"]= array();
780 }
781 }
783 /* Remove attribute if set to "nein" */
784 if ($this->publicVisible == "nein"){
785 $this->attrs['publicVisible']= array();
786 if($this->is_new){
787 unset($this->attrs['publicVisible']);
788 }else{
789 $this->attrs['publicVisible']=array();
790 }
792 }
794 }
796 /* Special handling for attribute userCertificate needed */
797 if ($this->userCertificate != ""){
798 $this->attrs["userCertificate;binary"]= $this->userCertificate;
799 $remove_userCertificate= false;
800 } else {
801 $remove_userCertificate= true;
802 }
804 /* Special handling for dateOfBirth value */
805 if ($this->use_dob != "1"){
806 if ($this->is_new) {
807 unset($this->attrs["dateOfBirth"]);
808 } else {
809 $this->attrs["dateOfBirth"]= array();
810 }
811 }
812 if (!$this->gender){
813 if ($this->is_new) {
814 unset($this->attrs["gender"]);
815 } else {
816 $this->attrs["gender"]= array();
817 }
818 }
819 if (!$this->preferredLanguage){
820 if ($this->is_new) {
821 unset($this->attrs["preferredLanguage"]);
822 } else {
823 $this->attrs["preferredLanguage"]= array();
824 }
825 }
827 /* Special handling for attribute jpegPhote needed, scale image via
828 image magick to 147x200 pixels and inject resulting data. */
829 if ($this->jpegPhoto == "*removed*"){
831 /* Reset attribute to avoid writing *removed* as value */
832 $this->attrs["jpegPhoto"] = array();
834 } else {
836 /* Fallback if there's no image magick inside PHP */
837 if (!function_exists("imagick_blob2image")){
838 /* Get temporary file name for conversation */
839 $fname = tempnam ("/tmp", "GOsa");
841 /* Open file and write out photoData */
842 $fp = fopen ($fname, "w");
843 fwrite ($fp, $this->photoData);
844 fclose ($fp);
846 /* Build conversation query. Filename is generated automatically, so
847 we do not need any special security checks. Exec command and save
848 output. For PHP safe mode, you'll need a configuration which respects
849 image magick as executable... */
850 $query= "convert -size 147x200 $fname -resize 147x200 +profile \"*\" -";
851 @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
852 $query, "Execute");
854 /* Read data written by convert */
855 $output= "";
856 $sh= popen($query, 'r');
857 while (!feof($sh)){
858 $output.= fread($sh, 4096);
859 }
860 pclose($sh);
862 unlink($fname);
864 /* Save attribute */
865 $this->attrs["jpegPhoto"] = $output;
867 } else {
869 /* Load the new uploaded Photo */
870 if(!$handle = imagick_blob2image($this->photoData)) {
871 gosa_log("Can't Load image");
872 }
874 /* Resizing image to 147x200 and blur */
875 if(!imagick_resize($handle,147,200,IMAGICK_FILTER_GAUSSIAN,0)){
876 gosa_log("imagick_resize failed");
877 }
879 /* Converting image to JPEG */
880 if(!imagick_convert($handle,"JPEG")) {
881 gosa_log("Can't Convert to JPEG");
882 }
884 /* Creating binary Code for the Image */
885 if(!$dump = imagick_image2blob($handle)){
886 gosa_log("Can't create blob for image");
887 }
889 /* Sending Image */
890 $output= $dump;
892 /* Save attribute */
893 $this->attrs["jpegPhoto"] = $output;
894 }
896 }
898 /* This only gets called when user is renaming himself */
899 $ldap= $this->config->get_ldap_link();
900 if ($this->dn != $this->new_dn){
902 /* Write entry on new 'dn' */
903 $this->update_acls($this->dn,$this->new_dn);
904 $this->move($this->dn, $this->new_dn);
906 /* Happen to use the new one */
907 change_ui_dn($this->dn, $this->new_dn);
908 $this->dn= $this->new_dn;
909 }
912 /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
913 new entries. So do a check first... */
914 $ldap->cat ($this->dn, array('dn'));
915 if ($ldap->fetch()){
916 $mode= "modify";
917 } else {
918 $mode= "add";
919 $ldap->cd($this->config->current['BASE']);
920 $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
921 }
923 /* Set password to some junk stuff in case of templates */
924 if ($this->is_template){
925 $this->attrs['userPassword']= '{crypt}N0T$3T4N0W';
926 }
928 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
929 $this->attributes, "Save via $mode");
931 /* Finally write data with selected 'mode' */
932 $this->cleanup();
933 $ldap->cd ($this->dn);
934 $ldap->$mode ($this->attrs);
935 if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/generic account with dn '%s' failed."),$this->dn))){
936 return (1);
937 }
939 /* Remove cert?
940 For some reason, the 'ldap' class doesn't want to remove binary entries, so I need
941 to work around myself. */
942 if ($remove_userCertificate == true && !$this->is_new && $this->had_userCertificate){
944 /* Reset array, assemble new, this should be reworked */
945 $this->attrs= array();
946 $this->attrs['userCertificate;binary']= array();
948 /* Prepare connection */
949 if (!($ds = ldap_connect($this->config->current['SERVER']))) {
950 die ("Could not connect to LDAP server");
951 }
952 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
953 if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
954 ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
955 ldap_set_rebind_proc($ds, array(&$this, "rebind"));
956 }
957 if(isset($config->current['TLS']) && $config->current['TLS'] == "true"){
958 ldap_start_tls($ds);
959 }
960 if (!($res = @ldap_bind($ds, $this->config->current['ADMIN'],
961 $this->config->current['PASSWORD']))) {
962 die ("Could not bind to LDAP");
963 }
965 /* Modify using attrs */
966 ldap_mod_del($ds,$this->dn,$this->attrs);
967 ldap_close($ds);
968 }
970 /* Kerberos server defined? */
971 if (isset($this->config->data['SERVERS']['KERBEROS'])){
972 $cfg= $this->config->data['SERVERS']['KERBEROS'];
973 }
974 if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
976 /* Connect to the admin interface */
977 $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
978 $cfg['ADMIN'], $cfg['PASSWORD']);
980 /* Errors? */
981 if ($handle === FALSE){
982 print_red (_("Kerberos database communication failed"));
983 return (2);
984 }
986 /* Build user principal, get list of existsing principals */
987 $principal= $this->uid."@".$cfg['REALM'];
988 $principals = kadm5_get_principals($handle);
990 /* User exists in database? */
991 if (in_array($principal, $principals)){
993 /* Ok. User exists. Remove him/her when pw_storage has
994 changed to be NOT kerberos. */
995 if ($this->pw_storage != $this->config->current['KRBSASL']){
996 $ret= kadm5_delete_principal ( $handle, $principal);
998 if ($ret === FALSE){
999 print_red (_("Can't remove user from kerberos database."));
1000 }
1001 }
1003 } else {
1005 /* User doesn't exists, create it when pw_storage is kerberos. */
1006 if ($this->pw_storage == "kerberos" || $this->pw_storage == "sasl" ){
1007 $ret= kadm5_create_principal ( $handle, $principal);
1009 if ($ret === FALSE){
1010 print_red (_("Can't add user to kerberos database."));
1011 }
1012 }
1014 }
1016 /* Free kerberos admin handle */
1017 kadm5_destroy($handle);
1018 }
1020 /* Optionally execute a command after we're done */
1021 if ($mode == "add"){
1022 $this->handle_post_events("add", array("uid" => $this->uid));
1023 } elseif ($this->is_modified){
1024 $this->handle_post_events("modify", array("uid" => $this->uid));
1025 }
1027 /* Fix tagging if needed */
1028 $this->handle_object_tagging();
1030 return (0);
1031 }
1034 /* Check formular input */
1035 function check()
1036 {
1037 /* Call common method to give check the hook */
1038 $message= plugin::check();
1040 $pt= "";
1041 if(isset($this->config->current['INCLUDE_PERSONAL_TITLE']) && preg_match("/true/i",$this->config->current['INCLUDE_PERSONAL_TITLE'])){
1042 if(!empty($this->personalTitle)){
1043 $pt = $this->personalTitle." ";
1044 }
1045 }
1046 $this->cn= $pt.$this->givenName." ".$this->sn;
1048 /* Permissions for that base? */
1049 if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
1050 $this->new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
1051 } else {
1052 /* Don't touch dn, if cn hasn't changed */
1053 if (isset($this->saved_attributes['cn']) && $this->saved_attributes['cn'] == $this->cn){
1054 $this->new_dn= $this->dn;
1055 } else {
1056 $this->new_dn= $this->create_unique_dn('cn', get_people_ou().$this->base);
1057 }
1058 }
1060 /* Set the new acl base */
1061 if($this->dn == "new") {
1062 $this->set_acl_base($this->base);
1063 }
1065 /* must: sn, givenName, uid */
1066 if ($this->sn == "" && ($this->acl_is_writeable("sn",(!is_object($this->parent) && !isset($_SESSION['edit'])) || ($this->is_new)))){
1067 $message[]= _("The required field 'Name' is not set.");
1068 }
1070 /* UID already used? */
1071 $ldap= $this->config->get_ldap_link();
1072 $ldap->cd($this->config->current['BASE']);
1073 $ldap->search("(uid=$this->uid)", array("uid"));
1074 $ldap->fetch();
1075 if ($ldap->count() != 0 && $this->dn == 'new'){
1076 $message[]= _("There's already a person with this 'Login' in the database.");
1077 }
1079 /* In template mode, the uid and givenName are autogenerated... */
1080 if (!$this->is_template){
1081 if ($this->givenName == "" && $this->acl_is_writeable("givenName",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1082 $message[]= _("The required field 'Given name' is not set.");
1083 }
1084 if ($this->uid == "" && $this->acl_is_writeable("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1085 $message[]= _("The required field 'Login' is not set.");
1086 }
1087 if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
1088 $ldap->cat($this->new_dn);
1089 if ($ldap->count() != 0 && $this->dn != $this->new_dn && $this->dn == 'new'){
1090 $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
1091 }
1092 }
1093 }
1095 /* Check for valid input */
1096 if ($this->is_modified && !is_uid($this->uid)){
1097 $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed.");
1098 }
1099 if (!is_url($this->labeledURI)){
1100 $message[]= _("The field 'Homepage' contains an invalid URL definition.");
1101 }
1102 if (preg_match ("/[\\\\]/", $this->sn)){
1103 $message[]= _("The field 'Name' contains invalid characters.");
1104 }
1105 if (preg_match ("/[\\\\]/", $this->givenName)){
1106 $message[]= _("The field 'Given name' contains invalid characters.");
1107 }
1109 /* Check phone numbers */
1110 if (!is_phone_nr($this->telephoneNumber)){
1111 $message[]= _("The field 'Phone' contains an invalid phone number.");
1112 }
1113 if (!is_phone_nr($this->facsimileTelephoneNumber)){
1114 $message[]= _("The field 'Fax' contains an invalid phone number.");
1115 }
1116 if (!is_phone_nr($this->mobile)){
1117 $message[]= _("The field 'Mobile' contains an invalid phone number.");
1118 }
1119 if (!is_phone_nr($this->pager)){
1120 $message[]= _("The field 'Pager' contains an invalid phone number.");
1121 }
1123 /* Check for reserved characers */
1124 if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName)){
1125 $message[]= _("The field 'Given name' contains invalid characters.");
1126 }
1127 if (preg_match ('/[,+"?\'()=<>;]/', $this->sn)){
1128 $message[]= _("The field 'Name' contains invalid characters.");
1129 }
1131 return $message;
1132 }
1135 /* Indicate whether a password change is needed or not */
1136 function password_change_needed()
1137 {
1138 return ($this->pw_storage != $this->last_pw_storage);
1139 }
1142 /* Load a jpegPhoto from LDAP, this is going to be simplified later on */
1143 function load_picture()
1144 {
1145 $ldap = $this->config->get_ldap_link();
1146 $ldap->cd ($this->dn);
1147 $data = $ldap->get_attribute($this->dn,"jpegPhoto");
1149 if((!$data) || ($data == "*removed*")){
1151 /* In case we don't get an entry, load a default picture */
1152 $this->set_picture ();//"./images/default.jpg");
1153 $this->jpegPhoto= "*removed*";
1154 }else{
1156 /* Set picture */
1157 $this->photoData= $data;
1158 $_SESSION['binary']= $this->photoData;
1159 $_SESSION['binarytype']= "image/jpeg";
1160 $this->jpegPhoto= "";
1161 }
1162 }
1165 /* Load a certificate from LDAP, this is going to be simplified later on */
1166 function load_cert()
1167 {
1168 $ds= ldap_connect($this->config->current['SERVER']);
1169 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
1170 if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
1171 ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
1172 ldap_set_rebind_proc($ds, array(&$this, "rebind"));
1173 }
1174 if(isset($this->config->current['TLS']) &&
1175 $this->config->current['TLS'] == "true"){
1177 ldap_start_tls($ds);
1178 }
1180 $r= ldap_bind($ds);
1181 $sr= @ldap_read($ds, $this->dn, "userCertificate=*", array("userCertificate"));
1183 if ($sr) {
1184 $ei= @ldap_first_entry($ds, $sr);
1186 if ($ei) {
1187 if (!$info = @ldap_get_values_len($ds, $ei, "userCertificate;binary")){
1188 $this->userCertificate= "";
1189 } else {
1190 $this->userCertificate= $info[0];
1191 }
1192 }
1193 } else {
1194 $this->userCertificate= "";
1195 }
1197 ldap_unbind($ds);
1198 }
1201 /* Load picture from file to object */
1202 function set_picture($filename ="")
1203 {
1204 if (!is_file($filename) || $filename =="" ){
1205 $filename= "./images/default.jpg";
1206 $this->jpegPhoto= "*removed*";
1207 }
1209 $fd = fopen ($filename, "rb");
1210 $this->photoData= fread ($fd, filesize ($filename));
1211 $_SESSION['binary']= $this->photoData;
1212 $_SESSION['binarytype']= "image/jpeg";
1213 $this->jpegPhoto= "";
1215 fclose ($fd);
1216 }
1219 /* Load certificate from file to object */
1220 function set_cert($cert, $filename)
1221 {
1222 if(!$thsi->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))) return;
1223 $fd = fopen ($filename, "rb");
1224 if (filesize($filename)>0) {
1225 $this->$cert= fread ($fd, filesize ($filename));
1226 fclose ($fd);
1227 $this->is_modified= TRUE;
1228 } else {
1229 print_red(_("Could not open specified certificate!"));
1230 }
1231 }
1233 /* Adapt from given 'dn' */
1234 function adapt_from_template($dn)
1235 {
1236 plugin::adapt_from_template($dn);
1238 /* Get base */
1239 $this->base= preg_replace('/^[^,]+,'.get_people_ou().'/i', '', $dn);
1241 if ($this->config->current['GOVERNMENTMODE']){
1243 /* Walk through govattrs */
1244 foreach ($this->govattrs as $val){
1246 if (isset($this->attrs["$val"][0])){
1248 /* If attribute is set, replace dynamic parts:
1249 %sn, %givenName and %uid. Fill these in our local variables. */
1250 $value= $this->attrs["$val"][0];
1252 foreach (array("sn", "givenName", "uid") as $repl){
1253 if (preg_match("/%$repl/i", $value)){
1254 $value= preg_replace ("/%$repl/i",
1255 $this->parent->$repl, $value);
1256 }
1257 }
1258 $this->$val= $value;
1259 }
1260 }
1261 }
1263 /* Get back uid/sn/givenName */
1264 if ($this->parent != NULL){
1265 $this->uid= $this->parent->uid;
1266 $this->sn= $this->parent->sn;
1267 $this->givenName= $this->parent->givenName;
1268 }
1269 }
1272 /* This avoids that users move themselves out of their rights.
1273 */
1274 function allowedBasesToMoveTo()
1275 {
1276 /* Get bases */
1277 $bases = $this->get_allowed_bases();
1278 return($bases);
1279 }
1282 function getCopyDialog()
1283 {
1284 $str = "";
1286 $_SESSION['binary'] = $this->photoData;
1287 $_SESSION['binarytype']= "image/jpeg";
1289 /* Get random number for pictures */
1290 srand((double)microtime()*1000000);
1291 $rand = rand(0, 10000);
1293 $smarty = get_smarty();
1295 $smarty->assign("passwordTodo","clear");
1297 if(isset($_POST['passwordTodo'])){
1298 $smarty->assign("passwordTodo",$_POST['passwordTodo']);
1299 }
1301 $smarty->assign("sn", $this->sn);
1302 $smarty->assign("givenName",$this->givenName);
1303 $smarty->assign("uid", $this->uid);
1304 $smarty->assign("rand", $rand);
1305 $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
1308 $ret = array();
1309 $ret['string'] = $str;
1310 $ret['status'] = "";
1311 return($ret);
1312 }
1314 function saveCopyDialog()
1315 {
1316 /* Set_acl_base */
1317 $this->set_acl_base("cn=dummy,".get_people_ou().$this->base);
1319 if((isset($_FILES['picture_file']['tmp_name'])) && ($_FILES['picture_file']['size'] > 0)){
1320 $this->set_picture($_FILES['picture_file']['tmp_name']);
1321 }
1323 /* Remove picture? */
1324 if (isset($_POST['picture_remove'])){
1325 $this->jpegPhoto= "*removed*";
1326 $this->set_picture ("./images/default.jpg");
1327 $this->is_modified= TRUE;
1328 }
1330 $attrs = array("uid","givenName","sn");
1331 foreach($attrs as $attr){
1332 if(isset($_POST[$attr])){
1333 $this->$attr = $_POST[$attr];
1334 }
1335 }
1336 }
1339 function PrepareForCopyPaste($source)
1340 {
1341 plugin::PrepareForCopyPaste($source);
1343 /* Reset certificate information addepted from source user
1344 to avoid setting the same user certificate for the destination user. */
1345 $this->userPKCS12= "";
1346 $this->userSMIMECertificate= "";
1347 $this->userCertificate= "";
1348 $this->certificateSerialNumber= "";
1349 $this->old_certificateSerialNumber= "";
1350 $this->old_userPKCS12= "";
1351 $this->old_userSMIMECertificate= "";
1352 $this->old_userCertificate= "";
1353 }
1356 function plInfo()
1357 {
1359 $govattrs= array(
1360 "gouvernmentOrganizationalUnit" => _("Unit"),
1361 "houseIdentifier" => _("House identifier"),
1362 "vocation" => _("Vocation"),
1363 "ivbbLastDeliveryCollective" => _("Last delivery"),
1364 "gouvernmentOrganizationalPersonLocality" => _("Person locality"),
1365 "gouvernmentOrganizationalUnitDescription" => _("Unit description"),
1366 "gouvernmentOrganizationalUnitSubjectArea" => _("Subject area"),
1367 "functionalTitle" => _("Functional title"),
1368 "certificateSerialNumber" => _(""),
1369 "publicVisible" => _("Public visible"),
1370 "street" => _("Street"),
1371 "role" => _("Role"),
1372 "postalCode" => _("Postal code"));
1374 $ret = array(
1375 "plShortName" => _("Generic"),
1376 "plDescription" => _("Generic user settings"),
1377 "plSelfModify" => TRUE,
1378 "plDepends" => array(),
1379 "plPriority" => 1,
1380 "plSection" => array("personal" => _("My account")),
1381 "plCategory" => array("users" => array("description" => _("Users"),
1382 "objectClass" => "gosaAccount")),
1384 "plProvidedAcls" => array(
1385 "base" => _("Base"),
1386 "userPassword" => _("User password"),
1387 "sn" => _("Surename"),
1388 "givenName" => _("Given name"),
1389 "uid" => _("User identification"),
1390 "personalTitle" => _("Personal title"),
1391 "academicTitle" => _("Academic title"),
1392 "homePostalAddress" => _("Home postal address"),
1393 "homePhone" => _("Home phone number"),
1394 "labeledURI" => _("Homepage"),
1395 "o" => _("Organization"),
1396 "ou" => _("Department"),
1397 "dateOfBirth" => _("Date of birth"),
1398 "gender" => _("Gender"),
1399 "preferredLanguage" => _("Preferred language"),
1400 "departmentNumber" => _("Department number"),
1401 "employeeNumber" => _("Employee number"),
1402 "employeeType" => _("Employee type"),
1403 "l" => _("Location"),
1404 "st" => _("State"),
1405 "userPicture" => _("User picture"),
1406 "roomNumber" => _("Room number"),
1407 "telephoneNumber" => _("Telefon number"),
1408 "mobile" => _("Mobile number"),
1409 "pager" => _("Pager number"),
1410 "Certificate" => _("User certificates"),
1412 "postalAddress" => _("Postal address"),
1413 "facsimileTelephoneNumber" => _("Fax number"))
1414 );
1416 /* Append government attributes if required */
1417 global $config;
1418 if (isset($config->current['GOVERNMENTMODE']) && preg_match('/true/i', $config->current['GOVERNMENTMODE'])){
1419 foreach($govattrs as $attr => $desc){
1420 $ret["plProvidedAcls"][$attr] = $desc;
1421 }
1422 }
1424 return($ret);
1425 }
1426 }
1428 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1429 ?>