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