617c7eacaff81cd72b8c8fdb35d55a22670b7b03
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 $orig_dn;
82 var $dialog;
84 /* variables to trigger password changes */
85 var $pw_storage= "crypt";
86 var $last_pw_storage= "unset";
87 var $had_userCertificate= FALSE;
89 var $view_logged = FALSE;
91 /* attribute list for save action */
92 var $attributes= array("sn", "givenName", "uid", "personalTitle", "academicTitle",
93 "homePostalAddress", "homePhone", "labeledURI", "ou", "o", "dateOfBirth", "gender","preferredLanguage",
94 "departmentNumber", "employeeNumber", "employeeType", "l", "st","jpegPhoto",
95 "roomNumber", "telephoneNumber", "mobile", "pager", "cn", "userPKCS12",
96 "postalAddress", "facsimileTelephoneNumber", "userSMIMECertificate");
98 var $objectclasses= array("top", "person", "organizationalPerson", "inetOrgPerson",
99 "gosaAccount");
101 /* attributes that are part of the government mode */
102 var $govattrs= array("gouvernmentOrganizationalUnit", "houseIdentifier", "vocation",
103 "ivbbLastDeliveryCollective", "gouvernmentOrganizationalPersonLocality",
104 "gouvernmentOrganizationalUnitDescription","gouvernmentOrganizationalUnitSubjectArea",
105 "functionalTitle", "certificateSerialNumber", "publicVisible", "street", "role",
106 "postalCode");
109 /* constructor, if 'dn' is set, the node loads the given
110 'dn' from LDAP */
111 function user (&$config, $dn= NULL)
112 {
113 $this->config= $config;
114 /* Configuration is fine, allways */
115 if ($this->config->current['GOVERNMENTMODE']){
116 $this->attributes=array_merge($this->attributes,$this->govattrs);
117 }
119 /* Load base attributes */
120 plugin::plugin ($config, $dn);
122 $this->orig_dn = $this->dn;
124 if ($this->config->current['GOVERNMENTMODE']){
125 /* Fix public visible attribute if unset */
126 if (!isset($this->attrs['publicVisible'])){
127 $this->publicVisible == "nein";
128 }
129 }
131 /* Load government mode attributes */
132 if ($this->config->current['GOVERNMENTMODE']){
133 /* Copy all attributs */
134 foreach ($this->govattrs as $val){
135 if (isset($this->attrs["$val"][0])){
136 $this->$val= $this->attrs["$val"][0];
137 }
138 }
139 }
141 /* Create me for new accounts */
142 if ($dn == "new"){
143 $this->is_account= TRUE;
144 }
146 /* Make hash default to md5 if not set in config */
147 if (!isset($this->config->current['HASH'])){
148 $hash= "md5";
149 } else {
150 $hash= $this->config->current['HASH'];
151 }
153 /* Load data from LDAP? */
154 if ($dn != NULL){
156 /* Do base conversation */
157 if ($this->dn == "new"){
158 $ui= get_userinfo();
159 $this->base= dn2base($ui->dn);
160 } else {
161 $this->base= dn2base($dn);
162 }
164 /* get password storage type */
165 if (isset ($this->attrs['userPassword'][0])){
166 /* Initialize local array */
167 $matches= array();
168 if (preg_match ("/^{([^}]+)}(.+)/", $this->attrs['userPassword'][0], $matches)){
169 $this->pw_storage= strtolower($matches[1]);
170 } else {
171 if ($this->attrs['userPassword'][0] != ""){
172 $this->pw_storage= "clear";
173 } else {
174 $this->pw_storage= $hash;
175 }
176 }
177 } else {
178 /* Preset with vaule from configuration */
179 $this->pw_storage= $hash;
180 }
182 /* Load extra attributes: certificate and picture */
183 $this->load_cert();
184 $this->load_picture();
185 if ($this->userCertificate != ""){
186 $this->had_userCertificate= TRUE;
187 }
188 }
190 /* Reset password storage indicator, used by password_change_needed() */
191 if ($dn == "new"){
192 $this->last_pw_storage= "unset";
193 } else {
194 $this->last_pw_storage= $this->pw_storage;
195 }
197 /* Generate dateOfBirth entry */
198 if (isset ($this->attrs['dateOfBirth'])){
199 /* This entry is ISO 8601 conform */
200 list($year, $month, $day)= split("-", $this->attrs['dateOfBirth'][0], 3);
202 $this->dateOfBirth=array( 'mon'=> $month,"mday"=> $day,"year"=> $year);
203 $this->use_dob= "1";
204 } else {
205 $this->use_dob= "0";
206 }
208 /* Put gender attribute to upper case */
209 if (isset ($this->attrs['gender'])){
210 $this->gender= strtoupper($this->attrs['gender'][0]);
211 }
213 $this->orig_base = $this->base;
214 }
217 /* execute generates the html output for this node */
218 function execute()
219 {
220 /* Call parent execute */
221 plugin::execute();
223 /* Log view */
224 if($this->is_account && !$this->view_logged){
225 $this->view_logged = TRUE;
226 new log("view","users/".get_class($this),$this->dn);
227 }
229 $smarty= get_smarty();
231 /* Fill calendar */
232 if ($this->dateOfBirth == "0"){
233 $date= getdate();
234 } else {
235 if(is_array($this->dateOfBirth)){
236 $date = $this->dateOfBirth;
238 // Trigger on dates like 1985-04-01, getdate only understands timestamps
239 } else if (!empty($this->dateOfBirth) && !is_numeric($this->dateOfBirth)){
240 $date= getdate(strtotime($this->dateOfBirth));
242 } else {
243 $date = getdate($this->dateOfBirth);
244 }
245 }
247 $days= array();
248 for($d= 1; $d<32; $d++){
249 $days[$d]= $d;
250 }
251 $years= array();
253 if(($date['year']-100)<1901){
254 $start = 1901;
255 }else{
256 $start = $date['year']-100;
257 }
259 $end = $start +100;
261 for($y= $start; $y<=$end; $y++){
262 $years[]= $y;
263 }
264 $years['-']= "- ";
265 $months= array(_("January"), _("February"), _("March"), _("April"),
266 _("May"), _("June"), _("July"), _("August"), _("September"),
267 _("October"), _("November"), _("December"), '-' => '- ');
268 $smarty->assign("day", $date["mday"]);
269 $smarty->assign("days", $days);
270 $smarty->assign("months", $months);
271 $smarty->assign("month", $date["mon"]-1);
272 $smarty->assign("years", $years);
273 $smarty->assign("year", $date["year"]);
275 /* Assign sex */
276 $sex= array(0 => " ", "F" => _("female"), "M" => _("male"));
277 $smarty->assign("gender_list", $sex);
279 $language= array_merge(array(0 => " ") ,get_languages(TRUE));
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 new 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 }
655 /* Remove ACL dependencies too,
656 */
657 $tmp = new acl($this->config,$this->parent,$this->dn);
658 $tmp->remove_acl();
660 /* Optionally execute a command after we're done */
661 $this->handle_post_events("remove",array("uid" => $this->uid));
662 }
665 /* Save data to object */
666 function save_object()
667 {
668 if (isset($_POST['generic'])){
670 /* Make a backup of the current selected base */
671 $base_tmp = $this->base;
673 /* Parents save function */
674 plugin::save_object ();
676 /* Save government mode attributes */
677 if ($this->config->current['GOVERNMENTMODE']){
678 foreach ($this->govattrs as $val){
679 if ($this->acl_is_writeable($val,(!is_object($this->parent) && !isset($_SESSION['edit']))) && isset($_POST["$val"])){
680 $data= stripcslashes($_POST["$val"]);
681 if ($data != $this->$val){
682 $this->is_modified= TRUE;
683 }
684 $this->$val= $data;
685 }
686 }
687 }
689 /* In template mode, the uid is autogenerated... */
690 if ($this->is_template){
691 $this->uid= strtolower($this->sn);
692 $this->givenName= $this->sn;
693 }
695 /* Save base and pw_storage, since these are no LDAP attributes */
696 if (isset($_POST['base'])){
698 $tmp = $this->get_allowed_bases();
699 if(isset($tmp[$_POST['base']])){
700 $base= validate($_POST['base']);
701 if ($base != $this->base){
702 $this->is_modified= TRUE;
703 }
704 $this->base= $base;
705 }else{
706 $this->base = $base_tmp;
707 print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base'])));
708 $this->set_acl_base('dummy,'.$this->base);
709 }
710 }
712 /* Get pw_storage mode */
713 if (isset($_POST['pw_storage'])){
714 foreach(array("pw_storage") as $val){
715 if(isset($_POST[$val])){
716 $data= validate($_POST[$val]);
717 if ($data != $this->$val){
718 $this->is_modified= TRUE;
719 }
720 $this->$val= $data;
721 }
722 }
723 }
725 $this->set_acl_base('dummy,'.$this->base);
726 }
727 }
729 function rebind($ldap, $referral)
730 {
731 $credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']);
732 if (ldap_bind($ldap, $credentials['ADMIN'], $credentials['PASSWORD'])) {
733 $this->error = "Success";
734 $this->hascon=true;
735 $this->reconnect= true;
736 return (0);
737 } else {
738 $this->error = "Could not bind to " . $credentials['ADMIN'];
739 return NULL;
740 }
741 }
743 /* Save data to LDAP, depending on is_account we save or delete */
744 function save()
745 {
746 /* Only force save of changes ....
747 If this attributes aren't changed, avoid saving.
748 */
749 if($this->gender=="0") $this->gender ="";
750 if($this->preferredLanguage=="0") $this->preferredLanguage ="";
753 /* First use parents methods to do some basic fillup in $this->attrs */
754 plugin::save ();
756 if ($this->use_dob == "1"){
757 /* 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. */
758 if(!is_array($this->attrs['dateOfBirth'])) {
759 $this->attrs['dateOfBirth'] = date("Y-m-d", $this->dateOfBirth);
760 }
761 }
763 /* Remove additional objectClasses */
764 $tmp= array();
765 foreach ($this->attrs['objectClass'] as $key => $set){
766 $found= false;
767 foreach (array("ivbbentry", "gosaUserTemplate") as $val){
768 if (preg_match ("/^$set$/i", $val)){
769 $found= true;
770 break;
771 }
772 }
773 if (!$found){
774 $tmp[]= $set;
775 }
776 }
778 /* Replace the objectClass array. This is done because of the
779 separation into government and normal mode. */
780 $this->attrs['objectClass']= $tmp;
782 /* Add objectClasss for template mode? */
783 if ($this->is_template){
784 $this->attrs['objectClass'][]= "gosaUserTemplate";
785 }
787 /* Hard coded government mode? */
788 if ($this->config->current['GOVERNMENTMODE'] != 'false'){
789 $this->attrs['objectClass'][]= "ivbbentry";
791 /* Copy standard attributes */
792 foreach ($this->govattrs as $val){
793 if ($this->$val != ""){
794 $this->attrs["$val"]= $this->$val;
795 } elseif (!$this->is_new) {
796 $this->attrs["$val"]= array();
797 }
798 }
800 /* Remove attribute if set to "nein" */
801 if ($this->publicVisible == "nein"){
802 $this->attrs['publicVisible']= array();
803 if($this->is_new){
804 unset($this->attrs['publicVisible']);
805 }else{
806 $this->attrs['publicVisible']=array();
807 }
809 }
811 }
813 /* Special handling for attribute userCertificate needed */
814 if ($this->userCertificate != ""){
815 $this->attrs["userCertificate;binary"]= $this->userCertificate;
816 $remove_userCertificate= false;
817 } else {
818 $remove_userCertificate= true;
819 }
821 /* Special handling for dateOfBirth value */
822 if ($this->use_dob != "1"){
823 if ($this->is_new) {
824 unset($this->attrs["dateOfBirth"]);
825 } else {
826 $this->attrs["dateOfBirth"]= array();
827 }
828 }
829 if (!$this->gender){
830 if ($this->is_new) {
831 unset($this->attrs["gender"]);
832 } else {
833 $this->attrs["gender"]= array();
834 }
835 }
836 if (!$this->preferredLanguage){
837 if ($this->is_new) {
838 unset($this->attrs["preferredLanguage"]);
839 } else {
840 $this->attrs["preferredLanguage"]= array();
841 }
842 }
844 /* Special handling for attribute jpegPhote needed, scale image via
845 image magick to 147x200 pixels and inject resulting data. */
846 if ($this->jpegPhoto == "*removed*"){
848 /* Reset attribute to avoid writing *removed* as value */
849 $this->attrs["jpegPhoto"] = array();
851 } else {
853 /* Fallback if there's no image magick inside PHP */
854 if (!function_exists("imagick_blob2image")){
855 /* Get temporary file name for conversation */
856 $fname = tempnam ("/tmp", "GOsa");
858 /* Open file and write out photoData */
859 $fp = fopen ($fname, "w");
860 fwrite ($fp, $this->photoData);
861 fclose ($fp);
863 /* Build conversation query. Filename is generated automatically, so
864 we do not need any special security checks. Exec command and save
865 output. For PHP safe mode, you'll need a configuration which respects
866 image magick as executable... */
867 $query= "convert -size 147x200 $fname -resize 147x200 +profile \"*\" -";
868 @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
869 $query, "Execute");
871 /* Read data written by convert */
872 $output= "";
873 $sh= popen($query, 'r');
874 while (!feof($sh)){
875 $output.= fread($sh, 4096);
876 }
877 pclose($sh);
879 unlink($fname);
881 /* Save attribute */
882 $this->attrs["jpegPhoto"] = $output;
884 } else {
886 /* Load the new uploaded Photo */
887 if(!$handle = imagick_blob2image($this->photoData)) {
888 new log("debug","users/".get_class($this),"",array(),"Could not access uploaded image");
889 }
891 /* Resizing image to 147x200 and blur */
892 if(!imagick_resize($handle,147,200,IMAGICK_FILTER_GAUSSIAN,0)){
893 new log("debug","users/".get_class($this),"",array(),"Could not resize uploaded image");
894 }
896 /* Converting image to JPEG */
897 if(!imagick_convert($handle,"JPEG")) {
898 new log("debug","users/".get_class($this),"",array(),"Could not convert uploaded image to jepg");
899 }
901 /* Creating binary Code for the Image */
902 if(!$dump = imagick_image2blob($handle)){
903 new log("debug","users/".get_class($this),"",array(),"Could not create new user image");
904 }
906 /* Sending Image */
907 $output= $dump;
909 /* Save attribute */
910 $this->attrs["jpegPhoto"] = $output;
911 }
913 }
915 /* This only gets called when user is renaming himself */
916 $ldap= $this->config->get_ldap_link();
917 if ($this->dn != $this->new_dn){
919 /* Write entry on new 'dn' */
920 $this->update_acls($this->dn,$this->new_dn);
921 $this->move($this->dn, $this->new_dn);
923 /* Happen to use the new one */
924 change_ui_dn($this->dn, $this->new_dn);
925 $this->dn= $this->new_dn;
926 }
929 /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
930 new entries. So do a check first... */
931 $ldap->cat ($this->dn, array('dn'));
932 if ($ldap->fetch()){
933 $mode= "modify";
934 } else {
935 $mode= "add";
936 $ldap->cd($this->config->current['BASE']);
937 $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
938 }
940 /* Set password to some junk stuff in case of templates */
941 if ($this->is_template){
942 $this->attrs['userPassword']= '{crypt}N0T$3T4N0W';
943 }
945 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
946 $this->attributes, "Save via $mode");
948 /* Finally write data with selected 'mode' */
949 $this->cleanup();
951 if(isset($this->attrs['preferredLanguage'])){
952 $_SESSION['ui']->language = $this->preferredLanguage;
953 $_SESSION['Last_init_lang'] = "update";
954 }
956 $ldap->cd ($this->dn);
957 $ldap->$mode ($this->attrs);
958 if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/generic account with dn '%s' failed."),$this->dn))){
959 return (1);
960 }
963 /* Remove ACL dependencies too,
964 */
965 if($this->dn != $this->orig_dn && $this->orig_dn != "new"){
966 $tmp = new acl($this->config,$this->parent,$this->dn);
967 $tmp->update_acl_membership($this->orig_dn,$this->dn);
968 }
970 if($mode == "modify"){
971 new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
972 }else{
973 new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
974 }
976 /* Remove cert?
977 For some reason, the 'ldap' class doesn't want to remove binary entries, so I need
978 to work around myself. */
979 if ($remove_userCertificate == true && !$this->is_new && $this->had_userCertificate){
981 /* Reset array, assemble new, this should be reworked */
982 $this->attrs= array();
983 $this->attrs['userCertificate;binary']= array();
985 /* Prepare connection */
986 if (!($ds = ldap_connect($this->config->current['SERVER']))) {
987 die ("Could not connect to LDAP server");
988 }
989 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
990 if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
991 ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
992 ldap_set_rebind_proc($ds, array(&$this, "rebind"));
993 }
994 if(isset($config->current['TLS']) && $config->current['TLS'] == "true"){
995 ldap_start_tls($ds);
996 }
997 if (!($res = @ldap_bind($ds, $this->config->current['ADMIN'],
998 $this->config->current['PASSWORD']))) {
999 die ("Could not bind to LDAP");
1000 }
1002 /* Modify using attrs */
1003 ldap_mod_del($ds,$this->dn,$this->attrs);
1004 ldap_close($ds);
1005 }
1007 /* Kerberos server defined? */
1008 if (isset($this->config->data['SERVERS']['KERBEROS'])){
1009 $cfg= $this->config->data['SERVERS']['KERBEROS'];
1010 }
1011 if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
1013 /* Connect to the admin interface */
1014 $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
1015 $cfg['ADMIN'], $cfg['PASSWORD']);
1017 /* Errors? */
1018 if ($handle === FALSE){
1019 print_red (_("Kerberos database communication failed"));
1020 return (2);
1021 }
1023 /* Build user principal, get list of existsing principals */
1024 $principal= $this->uid."@".$cfg['REALM'];
1025 $principals = kadm5_get_principals($handle);
1027 /* User exists in database? */
1028 if (in_array($principal, $principals)){
1030 /* Ok. User exists. Remove him/her when pw_storage has
1031 changed to be NOT kerberos. */
1032 if ($this->pw_storage != $this->config->current['KRBSASL']){
1033 $ret= kadm5_delete_principal ( $handle, $principal);
1035 if ($ret === FALSE){
1036 print_red (_("Can't remove user from kerberos database."));
1037 }
1038 }
1040 } else {
1042 /* User doesn't exists, create it when pw_storage is kerberos. */
1043 if ($this->pw_storage == "kerberos" || $this->pw_storage == "sasl" ){
1044 $ret= kadm5_create_principal ( $handle, $principal);
1046 if ($ret === FALSE){
1047 print_red (_("Can't add user to kerberos database."));
1048 }
1049 }
1051 }
1053 /* Free kerberos admin handle */
1054 kadm5_destroy($handle);
1055 }
1057 /* Optionally execute a command after we're done */
1058 if ($mode == "add"){
1059 $this->handle_post_events("add", array("uid" => $this->uid));
1060 } elseif ($this->is_modified){
1061 $this->handle_post_events("modify", array("uid" => $this->uid));
1062 }
1064 /* Fix tagging if needed */
1065 $this->handle_object_tagging();
1067 return (0);
1068 }
1071 /* Check formular input */
1072 function check()
1073 {
1074 /* Call common method to give check the hook */
1075 $message= plugin::check();
1077 $pt= "";
1078 if(isset($this->config->current['INCLUDE_PERSONAL_TITLE']) && preg_match("/true/i",$this->config->current['INCLUDE_PERSONAL_TITLE'])){
1079 if(!empty($this->personalTitle)){
1080 $pt = $this->personalTitle." ";
1081 }
1082 }
1083 $this->cn= $pt.$this->givenName." ".$this->sn;
1085 /* Permissions for that base? */
1086 if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
1087 $this->new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
1088 } else {
1089 /* Don't touch dn, if cn hasn't changed */
1090 if (isset($this->saved_attributes['cn']) && $this->saved_attributes['cn'] == $this->cn &&
1091 $this->orig_base == $this->base ){
1092 $this->new_dn= $this->dn;
1093 } else {
1094 $this->new_dn= $this->create_unique_dn('cn', get_people_ou().$this->base);
1095 }
1096 }
1098 /* Set the new acl base */
1099 if($this->dn == "new") {
1100 $this->set_acl_base($this->base);
1101 }
1103 /* must: sn, givenName, uid */
1104 if ($this->sn == "" && ($this->acl_is_writeable("sn",(!is_object($this->parent) && !isset($_SESSION['edit'])) || ($this->is_new)))){
1105 $message[]= _("The required field 'Name' is not set.");
1106 }
1108 /* UID already used? */
1109 $ldap= $this->config->get_ldap_link();
1110 $ldap->cd($this->config->current['BASE']);
1111 $ldap->search("(uid=$this->uid)", array("uid"));
1112 $ldap->fetch();
1113 if ($ldap->count() != 0 && $this->dn == 'new'){
1114 $message[]= _("There's already a person with this 'Login' in the database.");
1115 }
1117 /* In template mode, the uid and givenName are autogenerated... */
1118 if (!$this->is_template){
1119 if ($this->givenName == "" && $this->acl_is_writeable("givenName",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1120 $message[]= _("The required field 'Given name' is not set.");
1121 }
1122 if ($this->uid == "" && $this->acl_is_writeable("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1123 $message[]= _("The required field 'Login' is not set.");
1124 }
1125 if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
1126 $ldap->cat($this->new_dn);
1127 if ($ldap->count() != 0 && $this->dn != $this->new_dn && $this->dn == 'new'){
1128 $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
1129 }
1130 }
1131 }
1133 /* Check for valid input */
1134 if ($this->is_modified && !is_uid($this->uid)){
1135 $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed.");
1136 }
1137 if (!is_url($this->labeledURI)){
1138 $message[]= _("The field 'Homepage' contains an invalid URL definition.");
1139 }
1140 if (preg_match ("/[\\\\]/", $this->sn)){
1141 $message[]= _("The field 'Name' contains invalid characters.");
1142 }
1143 if (preg_match ("/[\\\\]/", $this->givenName)){
1144 $message[]= _("The field 'Given name' contains invalid characters.");
1145 }
1147 /* Check phone numbers */
1148 if (!is_phone_nr($this->telephoneNumber)){
1149 $message[]= _("The field 'Phone' contains an invalid phone number.");
1150 }
1151 if (!is_phone_nr($this->facsimileTelephoneNumber)){
1152 $message[]= _("The field 'Fax' contains an invalid phone number.");
1153 }
1154 if (!is_phone_nr($this->mobile)){
1155 $message[]= _("The field 'Mobile' contains an invalid phone number.");
1156 }
1157 if (!is_phone_nr($this->pager)){
1158 $message[]= _("The field 'Pager' contains an invalid phone number.");
1159 }
1161 /* Check for reserved characers */
1162 if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName)){
1163 $message[]= _("The field 'Given name' contains invalid characters.");
1164 }
1165 if (preg_match ('/[,+"?\'()=<>;]/', $this->sn)){
1166 $message[]= _("The field 'Name' contains invalid characters.");
1167 }
1169 return $message;
1170 }
1173 /* Indicate whether a password change is needed or not */
1174 function password_change_needed()
1175 {
1176 return ($this->pw_storage != $this->last_pw_storage);
1177 }
1180 /* Load a jpegPhoto from LDAP, this is going to be simplified later on */
1181 function load_picture()
1182 {
1183 $ldap = $this->config->get_ldap_link();
1184 $ldap->cd ($this->dn);
1185 $data = $ldap->get_attribute($this->dn,"jpegPhoto");
1187 if((!$data) || ($data == "*removed*")){
1189 /* In case we don't get an entry, load a default picture */
1190 $this->set_picture ();//"./images/default.jpg");
1191 $this->jpegPhoto= "*removed*";
1192 }else{
1194 /* Set picture */
1195 $this->photoData= $data;
1196 $_SESSION['binary']= $this->photoData;
1197 $_SESSION['binarytype']= "image/jpeg";
1198 $this->jpegPhoto= "";
1199 }
1200 }
1203 /* Load a certificate from LDAP, this is going to be simplified later on */
1204 function load_cert()
1205 {
1206 $ds= ldap_connect($this->config->current['SERVER']);
1207 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
1208 if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
1209 ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
1210 ldap_set_rebind_proc($ds, array(&$this, "rebind"));
1211 }
1212 if(isset($this->config->current['TLS']) &&
1213 $this->config->current['TLS'] == "true"){
1215 ldap_start_tls($ds);
1216 }
1218 $r= ldap_bind($ds);
1219 $sr= @ldap_read($ds, $this->dn, "userCertificate=*", array("userCertificate"));
1221 if ($sr) {
1222 $ei= @ldap_first_entry($ds, $sr);
1224 if ($ei) {
1225 if (!$info = @ldap_get_values_len($ds, $ei, "userCertificate;binary")){
1226 $this->userCertificate= "";
1227 } else {
1228 $this->userCertificate= $info[0];
1229 }
1230 }
1231 } else {
1232 $this->userCertificate= "";
1233 }
1235 ldap_unbind($ds);
1236 }
1239 /* Load picture from file to object */
1240 function set_picture($filename ="")
1241 {
1242 if (!is_file($filename) || $filename =="" ){
1243 $filename= "./images/default.jpg";
1244 $this->jpegPhoto= "*removed*";
1245 }
1247 $fd = fopen ($filename, "rb");
1248 $this->photoData= fread ($fd, filesize ($filename));
1249 $_SESSION['binary']= $this->photoData;
1250 $_SESSION['binarytype']= "image/jpeg";
1251 $this->jpegPhoto= "";
1253 fclose ($fd);
1254 }
1257 /* Load certificate from file to object */
1258 function set_cert($cert, $filename)
1259 {
1260 if(!$thsi->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))) return;
1261 $fd = fopen ($filename, "rb");
1262 if (filesize($filename)>0) {
1263 $this->$cert= fread ($fd, filesize ($filename));
1264 fclose ($fd);
1265 $this->is_modified= TRUE;
1266 } else {
1267 print_red(_("Could not open specified certificate!"));
1268 }
1269 }
1271 /* Adapt from given 'dn' */
1272 function adapt_from_template($dn)
1273 {
1274 plugin::adapt_from_template($dn);
1276 /* Get base */
1277 $this->base= preg_replace('/^[^,]+,'.get_people_ou().'/i', '', $dn);
1279 if ($this->config->current['GOVERNMENTMODE']){
1281 /* Walk through govattrs */
1282 foreach ($this->govattrs as $val){
1284 if (isset($this->attrs["$val"][0])){
1286 /* If attribute is set, replace dynamic parts:
1287 %sn, %givenName and %uid. Fill these in our local variables. */
1288 $value= $this->attrs["$val"][0];
1290 foreach (array("sn", "givenName", "uid") as $repl){
1291 if (preg_match("/%$repl/i", $value)){
1292 $value= preg_replace ("/%$repl/i",
1293 $this->parent->$repl, $value);
1294 }
1295 }
1296 $this->$val= $value;
1297 }
1298 }
1299 }
1301 /* Get back uid/sn/givenName */
1302 if ($this->parent != NULL){
1303 $this->uid= $this->parent->uid;
1304 $this->sn= $this->parent->sn;
1305 $this->givenName= $this->parent->givenName;
1306 }
1307 }
1310 /* This avoids that users move themselves out of their rights.
1311 */
1312 function allowedBasesToMoveTo()
1313 {
1314 /* Get bases */
1315 $bases = $this->get_allowed_bases();
1316 return($bases);
1317 }
1320 function getCopyDialog()
1321 {
1322 $str = "";
1324 $_SESSION['binary'] = $this->photoData;
1325 $_SESSION['binarytype']= "image/jpeg";
1327 /* Get random number for pictures */
1328 srand((double)microtime()*1000000);
1329 $rand = rand(0, 10000);
1331 $smarty = get_smarty();
1333 $smarty->assign("passwordTodo","clear");
1335 if(isset($_POST['passwordTodo'])){
1336 $smarty->assign("passwordTodo",$_POST['passwordTodo']);
1337 }
1339 $smarty->assign("sn", $this->sn);
1340 $smarty->assign("givenName",$this->givenName);
1341 $smarty->assign("uid", $this->uid);
1342 $smarty->assign("rand", $rand);
1343 $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
1346 $ret = array();
1347 $ret['string'] = $str;
1348 $ret['status'] = "";
1349 return($ret);
1350 }
1352 function saveCopyDialog()
1353 {
1354 /* Set_acl_base */
1355 $this->set_acl_base("cn=dummy,".get_people_ou().$this->base);
1357 if((isset($_FILES['picture_file']['tmp_name'])) && ($_FILES['picture_file']['size'] > 0)){
1358 $this->set_picture($_FILES['picture_file']['tmp_name']);
1359 }
1361 /* Remove picture? */
1362 if (isset($_POST['picture_remove'])){
1363 $this->jpegPhoto= "*removed*";
1364 $this->set_picture ("./images/default.jpg");
1365 $this->is_modified= TRUE;
1366 }
1368 $attrs = array("uid","givenName","sn");
1369 foreach($attrs as $attr){
1370 if(isset($_POST[$attr])){
1371 $this->$attr = $_POST[$attr];
1372 }
1373 }
1374 }
1377 function PrepareForCopyPaste($source)
1378 {
1379 plugin::PrepareForCopyPaste($source);
1381 /* Reset certificate information addepted from source user
1382 to avoid setting the same user certificate for the destination user. */
1383 $this->userPKCS12= "";
1384 $this->userSMIMECertificate= "";
1385 $this->userCertificate= "";
1386 $this->certificateSerialNumber= "";
1387 $this->old_certificateSerialNumber= "";
1388 $this->old_userPKCS12= "";
1389 $this->old_userSMIMECertificate= "";
1390 $this->old_userCertificate= "";
1391 }
1394 function plInfo()
1395 {
1397 $govattrs= array(
1398 "gouvernmentOrganizationalUnit" => _("Unit"),
1399 "houseIdentifier" => _("House identifier"),
1400 "vocation" => _("Vocation"),
1401 "ivbbLastDeliveryCollective" => _("Last delivery"),
1402 "gouvernmentOrganizationalPersonLocality" => _("Person locality"),
1403 "gouvernmentOrganizationalUnitDescription" => _("Unit description"),
1404 "gouvernmentOrganizationalUnitSubjectArea" => _("Subject area"),
1405 "functionalTitle" => _("Functional title"),
1406 "certificateSerialNumber" => _("Certificate serial number"),
1407 "publicVisible" => _("Public visible"),
1408 "street" => _("Street"),
1409 "role" => _("Role"),
1410 "postalCode" => _("Postal code"));
1412 $ret = array(
1413 "plShortName" => _("Generic"),
1414 "plDescription" => _("Generic user settings"),
1415 "plSelfModify" => TRUE,
1416 "plDepends" => array(),
1417 "plPriority" => 1,
1418 "plSection" => array("personal" => _("My account")),
1419 "plCategory" => array("users" => array("description" => _("Users"),
1420 "objectClass" => "gosaAccount")),
1422 "plProvidedAcls" => array(
1423 "base" => _("Base"),
1424 "userPassword" => _("User password"),
1425 "sn" => _("Surename"),
1426 "givenName" => _("Given name"),
1427 "uid" => _("User identification"),
1428 "personalTitle" => _("Personal title"),
1429 "academicTitle" => _("Academic title"),
1430 "homePostalAddress" => _("Home postal address"),
1431 "homePhone" => _("Home phone number"),
1432 "labeledURI" => _("Homepage"),
1433 "o" => _("Organization"),
1434 "ou" => _("Department"),
1435 "dateOfBirth" => _("Date of birth"),
1436 "gender" => _("Gender"),
1437 "preferredLanguage" => _("Preferred language"),
1438 "departmentNumber" => _("Department number"),
1439 "employeeNumber" => _("Employee number"),
1440 "employeeType" => _("Employee type"),
1441 "l" => _("Location"),
1442 "st" => _("State"),
1443 "userPicture" => _("User picture"),
1444 "roomNumber" => _("Room number"),
1445 "telephoneNumber" => _("Telefon number"),
1446 "mobile" => _("Mobile number"),
1447 "pager" => _("Pager number"),
1448 "Certificate" => _("User certificates"),
1450 "postalAddress" => _("Postal address"),
1451 "facsimileTelephoneNumber" => _("Fax number"))
1452 );
1454 /* Append government attributes if required */
1455 global $config;
1456 if (isset($config->current['GOVERNMENTMODE']) && preg_match('/true/i', $config->current['GOVERNMENTMODE'])){
1457 foreach($govattrs as $attr => $desc){
1458 $ret["plProvidedAcls"][$attr] = $desc;
1459 }
1460 }
1462 return($ret);
1463 }
1464 }
1466 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1467 ?>