75f07e360c1595922dcc0e6430c12285db0c0093
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 new 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 $language= array_merge(array(0 => " ") ,get_languages());
277 $smarty->assign("preferredLanguage_list", $language);
279 /* Get random number for pictures */
280 srand((double)microtime()*1000000);
281 $smarty->assign("rand", rand(0, 10000));
284 /* Do we represent a valid gosaAccount? */
285 if (!$this->is_account){
286 echo "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
287 _("This account has no valid GOsa extensions.")."</b>";
288 return;
289 }
291 /* Base select dialog */
292 $once = true;
293 foreach($_POST as $name => $value){
294 if(preg_match("/^chooseBase/",$name) && $once){
295 $once = false;
296 $this->dialog = new baseSelectDialog($this->config,$this,$this->allowedBasesToMoveTo());
297 $this->dialog->setCurrentBase($this->base);
298 }
299 }
301 /* Dialog handling */
302 if(is_object($this->dialog)){
303 /* Must be called before save_object */
304 $this->dialog->save_object();
306 if($this->dialog->isClosed()){
307 $this->dialog = false;
308 }elseif($this->dialog->isSelected()){
310 /* check if selected base is allowed to move to / create a new object */
311 $tmp = $this->get_allowed_bases();
312 if(isset($tmp[$this->dialog->isSelected()])){
313 $this->base = $this->dialog->isSelected();
314 }
315 $this->dialog= false;
316 }else{
317 return($this->dialog->execute());
318 }
319 }
321 /* Want picture edit dialog? */
322 if($this->acl_is_writeable("userPicture")) {
323 if (isset($_POST['edit_picture'])){
324 /* Save values for later recovery, in case some presses
325 the cancel button. */
326 $this->old_jpegPhoto= $this->jpegPhoto;
327 $this->old_photoData= $this->photoData;
328 $this->picture_dialog= TRUE;
329 $this->dialog= TRUE;
330 }
331 }
333 /* Remove picture? */
334 if($this->acl_is_writeable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))) ){
335 if (isset($_POST['picture_remove'])){
336 $this->set_picture ();
337 $this->jpegPhoto= "*removed*";
338 $this->is_modified= TRUE;
339 return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
340 }
341 }
343 /* Save picture */
344 if (isset($_POST['picture_edit_finish'])){
346 /* Check for clean upload */
347 if ($_FILES['picture_file']['name'] != ""){
348 if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) {
349 print_red(_("The specified file has not been uploaded via HTTP POST! Aborted."));
350 }else{
351 /* Activate new picture */
352 $this->set_picture($_FILES['picture_file']['tmp_name']);
353 }
354 }
355 $this->picture_dialog= FALSE;
356 $this->dialog= FALSE;
357 $this->is_modified= TRUE;
358 }
361 /* Cancel picture */
362 if (isset($_POST['picture_edit_cancel'])){
364 /* Restore values */
365 $this->jpegPhoto= $this->old_jpegPhoto;
366 $this->photoData= $this->old_photoData;
368 /* Update picture */
369 $_SESSION['binary']= $this->photoData;
370 $_SESSION['binarytype']= "image/jpeg";
371 $this->picture_dialog= FALSE;
372 $this->dialog= FALSE;
373 }
375 /* Toggle dateOfBirth information */
376 if (isset($_POST['set_dob'])){
377 $this->use_dob= ($this->use_dob == "0")?"1":"0";
378 }
381 /* Want certificate= */
382 if ((isset($_POST['edit_cert'])) && $this->acl_is_readable("Certificate")){
384 /* Save original values for later reconstruction */
385 foreach (array("certificateSerialNumber", "userCertificate",
386 "userSMIMECertificate", "userPKCS12") as $val){
388 $oval= "old_$val";
389 $this->$oval= $this->$val;
390 }
392 $this->cert_dialog= TRUE;
393 $this->dialog= TRUE;
394 }
397 /* Cancel certificate dialog */
398 if (isset($_POST['cert_edit_cancel'])){
400 /* Restore original values in case of 'cancel' */
401 foreach (array("certificateSerialNumber", "userCertificate",
402 "userSMIMECertificate", "userPKCS12") as $val){
404 $oval= "old_$val";
405 $this->$val= $this->$oval;
406 }
407 $this->cert_dialog= FALSE;
408 $this->dialog= FALSE;
409 }
412 /* Remove certificate? */
413 if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
414 foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") as $val){
415 if (isset($_POST["remove_$val"])){
417 /* Reset specified cert*/
418 $this->$val= "";
419 $this->is_modified= TRUE;
420 }
421 }
422 }
424 /* Upload new cert and close dialog? */
425 if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
426 if (isset($_POST['cert_edit_finish'])){
428 /* for all certificates do */
429 foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12")
430 as $val){
432 /* Check for clean upload */
433 if (array_key_exists($val."_file", $_FILES) &&
434 array_key_exists('name', $_FILES[$val."_file"]) &&
435 $_FILES[$val."_file"]['name'] != "" &&
436 is_uploaded_file($_FILES[$val."_file"]['tmp_name'])) {
437 $this->set_cert("$val", $_FILES[$val."_file"]['tmp_name']);
438 }
439 }
441 /* Save serial number */
442 if (isset($_POST["certificateSerialNumber"]) &&
443 $_POST["certificateSerialNumber"] != ""){
445 if (!is_id($_POST["certificateSerialNumber"])){
446 print_red (_("Please enter a valid serial number"));
448 foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
449 if ($this->$cert != ""){
450 $smarty->assign("$cert"."_state", "true");
451 } else {
452 $smarty->assign("$cert"."_state", "");
453 }
454 }
455 return ($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
456 }
458 $this->certificateSerialNumber= $_POST["certificateSerialNumber"];
459 $this->is_modified= TRUE;
460 }
462 $this->cert_dialog= FALSE;
463 $this->dialog= FALSE;
464 }
465 }
466 /* Display picture dialog */
467 if ($this->picture_dialog){
468 return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
469 }
471 /* Display cert dialog */
472 if ($this->cert_dialog){
473 $smarty->assign("CertificateACL",$this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
474 $smarty->assign("Certificate_readable",$this->acl_is_readable("Certificate"));
476 foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
477 if ($this->$cert != ""){
478 /* import certificate */
479 $certificate = new certificate;
480 $certificate->import($this->$cert);
482 /* Read out data*/
483 $timeto = $certificate->getvalidto_date();
484 $timefrom = $certificate->getvalidfrom_date();
487 /* Additional info if start end time is '0' */
488 $add_str_info = "";
489 if($timeto == 0 && $timefrom == 0){
490 $add_str_info = "<br><i>"._("(Some types of certificates are currently not supported and may be displayed as 'invalid'.)")."</i>";
491 }
493 $str = "<table summary=\"\" border=0>
494 <tr>
495 <td style='vertical-align:top'>CN</td>
496 <td>".preg_replace("/ /", " ", $certificate->getname())."</td>
497 </tr>
498 </table><br>".
500 sprintf(_("Certificate is valid from %s to %s and is currently %s."),
501 "<b>".date('d M Y',$timefrom)."</b>",
502 "<b>".date('d M Y',$timeto)."</b>",
503 $certificate->isvalid()?"<b><font style='color:green'>"._("valid")."</font></b>":
504 "<b><font style='color:red'>"._("invalid")."</font></b>").$add_str_info;
506 $smarty->assign($cert."info",$str);
507 $smarty->assign($cert."_state","true");
508 } else {
509 $smarty->assign($cert."info", "<i>"._("No certificate installed")."</i>");
510 $smarty->assign($cert."_state","");
511 }
512 }
513 $smarty->assign("governmentmode", "false");
514 return($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
515 }
517 /* Prepare password hashes */
518 if ($this->pw_storage == ""){
519 $this->pw_storage= $this->config->current['HASH'];
520 }
522 $temp = @passwordMethod::get_available_methods();
523 $hashes = $temp['name'];
525 /* Load attributes and acl's */
526 $ui =get_userinfo();
527 foreach($this->attributes as $val){
528 $smarty->assign("$val", $this->$val);
529 }
531 /* Set acls */
532 $tmp = $this->plinfo();
533 foreach($tmp['plProvidedAcls'] as $val => $translation){
534 $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
535 }
537 $smarty->assign("pwmode", $hashes);
538 $smarty->assign("pwmode_select", $this->pw_storage);
539 $smarty->assign("passwordStorageACL", $this->getacl("userPassword",(!is_object($this->parent) && !isset($_SESSION['edit']))));
540 $smarty->assign("base_select", $this->base);
541 $smarty->assign("CertificatesACL", $this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
542 $smarty->assign("userPictureACL", $this->getacl("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
543 $smarty->assign("userPicture_is_readable", $this->acl_is_readable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
545 /* Create base acls */
546 @$smarty->assign("bases", $this->allowedBasesToMoveTo());
548 /* Save government mode attributes */
549 if (isset($this->config->current['GOVERNMENTMODE']) &&
550 preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){
551 $smarty->assign("governmentmode", "true");
552 $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet",
553 "internet,ivbv", "internet,testa", "internet,ivbv,testa");
554 $smarty->assign("ivbbmodes", $ivbbmodes);
555 foreach ($this->govattrs as $val){
556 $smarty->assign("$val", $this->$val);
557 $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
558 }
559 } else {
560 $smarty->assign("governmentmode", "false");
561 }
563 /* Special mode for uid */
564 $uidACL= $this->getacl("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])));
565 if (isset ($this->dn)){
566 if ($this->dn != "new"){
567 $uidACL= preg_replace("/w/","",$uidACL);
568 }
569 } else {
570 $uidACL= preg_replace("/w/","",$uidACL);
571 }
573 $smarty->assign("uidACL", $uidACL);
574 $smarty->assign("is_template", $this->is_template);
575 $smarty->assign("use_dob", $this->use_dob);
577 if (isset($this->parent)){
578 if (isset($this->parent->by_object['phoneAccount']) &&
579 $this->parent->by_object['phoneAccount']->is_account){
580 $smarty->assign("has_phoneaccount", "true");
581 } else {
582 $smarty->assign("has_phoneaccount", "false");
583 }
584 } else {
585 $smarty->assign("has_phoneaccount", "false");
586 }
587 return($smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))));
588 }
591 /* remove object from parent */
592 function remove_from_parent()
593 {
594 $ldap= $this->config->get_ldap_link();
595 $ldap->rmdir ($this->dn);
596 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/generic account with dn '%s' failed."),$this->dn));
598 new log("remove","users/".get_class($this),$this->dn,$this->attributes,$ldap->get_error());
600 /* Delete references to groups */
601 $ldap->cd ($this->config->current['BASE']);
602 $ldap->search ("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("uid"));
603 while ($ldap->fetch()){
604 $g= new group($this->config, $ldap->getDN());
605 $g->removeUser($this->uid);
606 $g->save ();
607 }
609 /* Delete references to object groups */
610 $ldap->cd ($this->config->current['BASE']);
611 $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
612 while ($ldap->fetch()){
613 $og= new ogroup($this->config, $ldap->getDN());
614 unset($og->member[$this->dn]);
615 $og->save ();
616 }
618 /* Kerberos server defined? */
619 if (isset($this->config->data['SERVERS']['KERBEROS'])){
620 $cfg= $this->config->data['SERVERS']['KERBEROS'];
621 }
622 if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
624 /* Connect to the admin interface */
625 $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
626 $cfg['ADMIN'], $cfg['PASSWORD']);
628 /* Errors? */
629 if ($handle === FALSE){
630 print_red (_("Kerberos database communication failed"));
631 return (2);
632 }
634 /* Build user principal, get list of existsing principals */
635 $principal= $this->uid."@".$cfg['REALM'];
636 $principals = kadm5_get_principals($handle);
638 /* User exists in database? */
639 if (in_array($principal, $principals)){
641 /* Ok. User exists. Remove him/her */
642 $ret= kadm5_delete_principal ( $handle, $principal);
643 if ($ret === FALSE){
644 print_red (_("Can't remove user from kerberos database."));
645 }
646 }
648 /* Free kerberos admin handle */
649 kadm5_destroy($handle);
650 }
652 /* Remove ACL dependencies too,
653 */
654 $ldap = $this->config->get_ldap_link();
655 $ldap->cd($this->config->current['BASE']);
656 $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($this->dn)."*))",array("gosaAclEntry","dn"));
657 while($attrs = $ldap->fetch()){
658 $acl = new acl($this->config,$this->parent,$attrs['dn']);
659 foreach($acl->gosaAclEntry as $id => $entry){
660 foreach($entry['members'] as $m_id => $member){
661 if($m_id == "U:".$this->dn){
662 unset($acl->gosaAclEntry[$id]['members'][$m_id]);
663 gosa_log("modify","users/acl",$attrs['dn'],array(),sprintf("Removed acl for %s on object %s.",$this->dn,$attrs['dn']));
664 }
665 }
666 }
667 $acl -> save();
668 }
670 /* Optionally execute a command after we're done */
671 $this->handle_post_events("remove",array("uid" => $this->uid));
672 }
675 /* Save data to object */
676 function save_object()
677 {
678 if (isset($_POST['generic'])){
680 /* Make a backup of the current selected base */
681 $base_tmp = $this->base;
683 /* Parents save function */
684 plugin::save_object ();
686 /* Save government mode attributes */
687 if ($this->config->current['GOVERNMENTMODE']){
688 foreach ($this->govattrs as $val){
689 if ($this->acl_is_writeable($val,(!is_object($this->parent) && !isset($_SESSION['edit']))) && isset($_POST["$val"])){
690 $data= stripcslashes($_POST["$val"]);
691 if ($data != $this->$val){
692 $this->is_modified= TRUE;
693 }
694 $this->$val= $data;
695 }
696 }
697 }
699 /* In template mode, the uid is autogenerated... */
700 if ($this->is_template){
701 $this->uid= strtolower($this->sn);
702 $this->givenName= $this->sn;
703 }
705 /* Save base and pw_storage, since these are no LDAP attributes */
706 if (isset($_POST['base'])){
708 $tmp = $this->get_allowed_bases();
709 if(isset($tmp[$_POST['base']])){
710 $base= validate($_POST['base']);
711 if ($base != $this->base){
712 $this->is_modified= TRUE;
713 }
714 $this->base= $base;
715 }else{
716 $this->base = $base_tmp;
717 print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base'])));
718 $this->set_acl_base('dummy,'.$this->base);
719 }
720 }
722 /* Get pw_storage mode */
723 if (isset($_POST['pw_storage'])){
724 foreach(array("pw_storage") as $val){
725 if(isset($_POST[$val])){
726 $data= validate($_POST[$val]);
727 if ($data != $this->$val){
728 $this->is_modified= TRUE;
729 }
730 $this->$val= $data;
731 }
732 }
733 }
735 $this->set_acl_base('dummy,'.$this->base);
736 }
737 }
739 function rebind($ldap, $referral)
740 {
741 $credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']);
742 if (ldap_bind($ldap, $credentials['ADMIN'], $credentials['PASSWORD'])) {
743 $this->error = "Success";
744 $this->hascon=true;
745 $this->reconnect= true;
746 return (0);
747 } else {
748 $this->error = "Could not bind to " . $credentials['ADMIN'];
749 return NULL;
750 }
751 }
753 /* Save data to LDAP, depending on is_account we save or delete */
754 function save()
755 {
756 /* Only force save of changes ....
757 If this attributes aren't changed, avoid saving.
758 */
759 if($this->gender=="0") $this->gender ="";
760 if($this->preferredLanguage=="0") $this->preferredLanguage ="";
763 /* First use parents methods to do some basic fillup in $this->attrs */
764 plugin::save ();
766 if ($this->use_dob == "1"){
767 /* 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. */
768 if(!is_array($this->attrs['dateOfBirth'])) {
769 $this->attrs['dateOfBirth'] = date("Y-m-d", $this->dateOfBirth);
770 }
771 }
773 /* Remove additional objectClasses */
774 $tmp= array();
775 foreach ($this->attrs['objectClass'] as $key => $set){
776 $found= false;
777 foreach (array("ivbbentry", "gosaUserTemplate") as $val){
778 if (preg_match ("/^$set$/i", $val)){
779 $found= true;
780 break;
781 }
782 }
783 if (!$found){
784 $tmp[]= $set;
785 }
786 }
788 /* Replace the objectClass array. This is done because of the
789 separation into government and normal mode. */
790 $this->attrs['objectClass']= $tmp;
792 /* Add objectClasss for template mode? */
793 if ($this->is_template){
794 $this->attrs['objectClass'][]= "gosaUserTemplate";
795 }
797 /* Hard coded government mode? */
798 if ($this->config->current['GOVERNMENTMODE'] != 'false'){
799 $this->attrs['objectClass'][]= "ivbbentry";
801 /* Copy standard attributes */
802 foreach ($this->govattrs as $val){
803 if ($this->$val != ""){
804 $this->attrs["$val"]= $this->$val;
805 } elseif (!$this->is_new) {
806 $this->attrs["$val"]= array();
807 }
808 }
810 /* Remove attribute if set to "nein" */
811 if ($this->publicVisible == "nein"){
812 $this->attrs['publicVisible']= array();
813 if($this->is_new){
814 unset($this->attrs['publicVisible']);
815 }else{
816 $this->attrs['publicVisible']=array();
817 }
819 }
821 }
823 /* Special handling for attribute userCertificate needed */
824 if ($this->userCertificate != ""){
825 $this->attrs["userCertificate;binary"]= $this->userCertificate;
826 $remove_userCertificate= false;
827 } else {
828 $remove_userCertificate= true;
829 }
831 /* Special handling for dateOfBirth value */
832 if ($this->use_dob != "1"){
833 if ($this->is_new) {
834 unset($this->attrs["dateOfBirth"]);
835 } else {
836 $this->attrs["dateOfBirth"]= array();
837 }
838 }
839 if (!$this->gender){
840 if ($this->is_new) {
841 unset($this->attrs["gender"]);
842 } else {
843 $this->attrs["gender"]= array();
844 }
845 }
846 if (!$this->preferredLanguage){
847 if ($this->is_new) {
848 unset($this->attrs["preferredLanguage"]);
849 } else {
850 $this->attrs["preferredLanguage"]= array();
851 }
852 }
854 /* Special handling for attribute jpegPhote needed, scale image via
855 image magick to 147x200 pixels and inject resulting data. */
856 if ($this->jpegPhoto == "*removed*"){
858 /* Reset attribute to avoid writing *removed* as value */
859 $this->attrs["jpegPhoto"] = array();
861 } else {
863 /* Fallback if there's no image magick inside PHP */
864 if (!function_exists("imagick_blob2image")){
865 /* Get temporary file name for conversation */
866 $fname = tempnam ("/tmp", "GOsa");
868 /* Open file and write out photoData */
869 $fp = fopen ($fname, "w");
870 fwrite ($fp, $this->photoData);
871 fclose ($fp);
873 /* Build conversation query. Filename is generated automatically, so
874 we do not need any special security checks. Exec command and save
875 output. For PHP safe mode, you'll need a configuration which respects
876 image magick as executable... */
877 $query= "convert -size 147x200 $fname -resize 147x200 +profile \"*\" -";
878 @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
879 $query, "Execute");
881 /* Read data written by convert */
882 $output= "";
883 $sh= popen($query, 'r');
884 while (!feof($sh)){
885 $output.= fread($sh, 4096);
886 }
887 pclose($sh);
889 unlink($fname);
891 /* Save attribute */
892 $this->attrs["jpegPhoto"] = $output;
894 } else {
896 /* Load the new uploaded Photo */
897 if(!$handle = imagick_blob2image($this->photoData)) {
898 new log("debug","users/".get_class($this),"",array(),"Could not access uploaded image");
899 }
901 /* Resizing image to 147x200 and blur */
902 if(!imagick_resize($handle,147,200,IMAGICK_FILTER_GAUSSIAN,0)){
903 new log("debug","users/".get_class($this),"",array(),"Could not resize uploaded image");
904 }
906 /* Converting image to JPEG */
907 if(!imagick_convert($handle,"JPEG")) {
908 new log("debug","users/".get_class($this),"",array(),"Could not convert uploaded image to jepg");
909 }
911 /* Creating binary Code for the Image */
912 if(!$dump = imagick_image2blob($handle)){
913 new log("debug","users/".get_class($this),"",array(),"Could not create new user image");
914 }
916 /* Sending Image */
917 $output= $dump;
919 /* Save attribute */
920 $this->attrs["jpegPhoto"] = $output;
921 }
923 }
925 /* This only gets called when user is renaming himself */
926 $ldap= $this->config->get_ldap_link();
927 if ($this->dn != $this->new_dn){
929 /* Write entry on new 'dn' */
930 $this->update_acls($this->dn,$this->new_dn);
931 $this->move($this->dn, $this->new_dn);
933 /* Happen to use the new one */
934 change_ui_dn($this->dn, $this->new_dn);
935 $this->dn= $this->new_dn;
936 }
939 /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
940 new entries. So do a check first... */
941 $ldap->cat ($this->dn, array('dn'));
942 if ($ldap->fetch()){
943 $mode= "modify";
944 } else {
945 $mode= "add";
946 $ldap->cd($this->config->current['BASE']);
947 $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
948 }
950 /* Set password to some junk stuff in case of templates */
951 if ($this->is_template){
952 $this->attrs['userPassword']= '{crypt}N0T$3T4N0W';
953 }
955 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
956 $this->attributes, "Save via $mode");
958 /* Finally write data with selected 'mode' */
959 $this->cleanup();
961 if(isset($this->attrs['preferredLanguage'])){
962 $_SESSION['ui']->language = $this->preferredLanguage;
963 $_SESSION['Last_init_lang'] = "update";
964 }
966 $ldap->cd ($this->dn);
967 $ldap->$mode ($this->attrs);
968 if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/generic account with dn '%s' failed."),$this->dn))){
969 return (1);
970 }
972 if($mode == "modify"){
973 new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
974 }else{
975 new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
976 }
978 /* Remove cert?
979 For some reason, the 'ldap' class doesn't want to remove binary entries, so I need
980 to work around myself. */
981 if ($remove_userCertificate == true && !$this->is_new && $this->had_userCertificate){
983 /* Reset array, assemble new, this should be reworked */
984 $this->attrs= array();
985 $this->attrs['userCertificate;binary']= array();
987 /* Prepare connection */
988 if (!($ds = ldap_connect($this->config->current['SERVER']))) {
989 die ("Could not connect to LDAP server");
990 }
991 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
992 if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
993 ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
994 ldap_set_rebind_proc($ds, array(&$this, "rebind"));
995 }
996 if(isset($config->current['TLS']) && $config->current['TLS'] == "true"){
997 ldap_start_tls($ds);
998 }
999 if (!($res = @ldap_bind($ds, $this->config->current['ADMIN'],
1000 $this->config->current['PASSWORD']))) {
1001 die ("Could not bind to LDAP");
1002 }
1004 /* Modify using attrs */
1005 ldap_mod_del($ds,$this->dn,$this->attrs);
1006 ldap_close($ds);
1007 }
1009 /* Kerberos server defined? */
1010 if (isset($this->config->data['SERVERS']['KERBEROS'])){
1011 $cfg= $this->config->data['SERVERS']['KERBEROS'];
1012 }
1013 if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
1015 /* Connect to the admin interface */
1016 $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
1017 $cfg['ADMIN'], $cfg['PASSWORD']);
1019 /* Errors? */
1020 if ($handle === FALSE){
1021 print_red (_("Kerberos database communication failed"));
1022 return (2);
1023 }
1025 /* Build user principal, get list of existsing principals */
1026 $principal= $this->uid."@".$cfg['REALM'];
1027 $principals = kadm5_get_principals($handle);
1029 /* User exists in database? */
1030 if (in_array($principal, $principals)){
1032 /* Ok. User exists. Remove him/her when pw_storage has
1033 changed to be NOT kerberos. */
1034 if ($this->pw_storage != $this->config->current['KRBSASL']){
1035 $ret= kadm5_delete_principal ( $handle, $principal);
1037 if ($ret === FALSE){
1038 print_red (_("Can't remove user from kerberos database."));
1039 }
1040 }
1042 } else {
1044 /* User doesn't exists, create it when pw_storage is kerberos. */
1045 if ($this->pw_storage == "kerberos" || $this->pw_storage == "sasl" ){
1046 $ret= kadm5_create_principal ( $handle, $principal);
1048 if ($ret === FALSE){
1049 print_red (_("Can't add user to kerberos database."));
1050 }
1051 }
1053 }
1055 /* Free kerberos admin handle */
1056 kadm5_destroy($handle);
1057 }
1059 /* Optionally execute a command after we're done */
1060 if ($mode == "add"){
1061 $this->handle_post_events("add", array("uid" => $this->uid));
1062 } elseif ($this->is_modified){
1063 $this->handle_post_events("modify", array("uid" => $this->uid));
1064 }
1066 /* Fix tagging if needed */
1067 $this->handle_object_tagging();
1069 return (0);
1070 }
1073 /* Check formular input */
1074 function check()
1075 {
1076 /* Call common method to give check the hook */
1077 $message= plugin::check();
1079 $pt= "";
1080 if(isset($this->config->current['INCLUDE_PERSONAL_TITLE']) && preg_match("/true/i",$this->config->current['INCLUDE_PERSONAL_TITLE'])){
1081 if(!empty($this->personalTitle)){
1082 $pt = $this->personalTitle." ";
1083 }
1084 }
1085 $this->cn= $pt.$this->givenName." ".$this->sn;
1087 /* Permissions for that base? */
1088 if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
1089 $this->new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
1090 } else {
1091 /* Don't touch dn, if cn hasn't changed */
1092 if (isset($this->saved_attributes['cn']) && $this->saved_attributes['cn'] == $this->cn &&
1093 $this->orig_base == $this->base ){
1094 $this->new_dn= $this->dn;
1095 } else {
1096 $this->new_dn= $this->create_unique_dn('cn', get_people_ou().$this->base);
1097 }
1098 }
1100 /* Set the new acl base */
1101 if($this->dn == "new") {
1102 $this->set_acl_base($this->base);
1103 }
1105 /* must: sn, givenName, uid */
1106 if ($this->sn == "" && ($this->acl_is_writeable("sn",(!is_object($this->parent) && !isset($_SESSION['edit'])) || ($this->is_new)))){
1107 $message[]= _("The required field 'Name' is not set.");
1108 }
1110 /* UID already used? */
1111 $ldap= $this->config->get_ldap_link();
1112 $ldap->cd($this->config->current['BASE']);
1113 $ldap->search("(uid=$this->uid)", array("uid"));
1114 $ldap->fetch();
1115 if ($ldap->count() != 0 && $this->dn == 'new'){
1116 $message[]= _("There's already a person with this 'Login' in the database.");
1117 }
1119 /* In template mode, the uid and givenName are autogenerated... */
1120 if (!$this->is_template){
1121 if ($this->givenName == "" && $this->acl_is_writeable("givenName",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1122 $message[]= _("The required field 'Given name' is not set.");
1123 }
1124 if ($this->uid == "" && $this->acl_is_writeable("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1125 $message[]= _("The required field 'Login' is not set.");
1126 }
1127 if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
1128 $ldap->cat($this->new_dn);
1129 if ($ldap->count() != 0 && $this->dn != $this->new_dn && $this->dn == 'new'){
1130 $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
1131 }
1132 }
1133 }
1135 /* Check for valid input */
1136 if ($this->is_modified && !is_uid($this->uid)){
1137 $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed.");
1138 }
1139 if (!is_url($this->labeledURI)){
1140 $message[]= _("The field 'Homepage' contains an invalid URL definition.");
1141 }
1142 if (preg_match ("/[\\\\]/", $this->sn)){
1143 $message[]= _("The field 'Name' contains invalid characters.");
1144 }
1145 if (preg_match ("/[\\\\]/", $this->givenName)){
1146 $message[]= _("The field 'Given name' contains invalid characters.");
1147 }
1149 /* Check phone numbers */
1150 if (!is_phone_nr($this->telephoneNumber)){
1151 $message[]= _("The field 'Phone' contains an invalid phone number.");
1152 }
1153 if (!is_phone_nr($this->facsimileTelephoneNumber)){
1154 $message[]= _("The field 'Fax' contains an invalid phone number.");
1155 }
1156 if (!is_phone_nr($this->mobile)){
1157 $message[]= _("The field 'Mobile' contains an invalid phone number.");
1158 }
1159 if (!is_phone_nr($this->pager)){
1160 $message[]= _("The field 'Pager' contains an invalid phone number.");
1161 }
1163 /* Check for reserved characers */
1164 if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName)){
1165 $message[]= _("The field 'Given name' contains invalid characters.");
1166 }
1167 if (preg_match ('/[,+"?\'()=<>;]/', $this->sn)){
1168 $message[]= _("The field 'Name' contains invalid characters.");
1169 }
1171 return $message;
1172 }
1175 /* Indicate whether a password change is needed or not */
1176 function password_change_needed()
1177 {
1178 return ($this->pw_storage != $this->last_pw_storage);
1179 }
1182 /* Load a jpegPhoto from LDAP, this is going to be simplified later on */
1183 function load_picture()
1184 {
1185 $ldap = $this->config->get_ldap_link();
1186 $ldap->cd ($this->dn);
1187 $data = $ldap->get_attribute($this->dn,"jpegPhoto");
1189 if((!$data) || ($data == "*removed*")){
1191 /* In case we don't get an entry, load a default picture */
1192 $this->set_picture ();//"./images/default.jpg");
1193 $this->jpegPhoto= "*removed*";
1194 }else{
1196 /* Set picture */
1197 $this->photoData= $data;
1198 $_SESSION['binary']= $this->photoData;
1199 $_SESSION['binarytype']= "image/jpeg";
1200 $this->jpegPhoto= "";
1201 }
1202 }
1205 /* Load a certificate from LDAP, this is going to be simplified later on */
1206 function load_cert()
1207 {
1208 $ds= ldap_connect($this->config->current['SERVER']);
1209 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
1210 if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
1211 ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
1212 ldap_set_rebind_proc($ds, array(&$this, "rebind"));
1213 }
1214 if(isset($this->config->current['TLS']) &&
1215 $this->config->current['TLS'] == "true"){
1217 ldap_start_tls($ds);
1218 }
1220 $r= ldap_bind($ds);
1221 $sr= @ldap_read($ds, $this->dn, "userCertificate=*", array("userCertificate"));
1223 if ($sr) {
1224 $ei= @ldap_first_entry($ds, $sr);
1226 if ($ei) {
1227 if (!$info = @ldap_get_values_len($ds, $ei, "userCertificate;binary")){
1228 $this->userCertificate= "";
1229 } else {
1230 $this->userCertificate= $info[0];
1231 }
1232 }
1233 } else {
1234 $this->userCertificate= "";
1235 }
1237 ldap_unbind($ds);
1238 }
1241 /* Load picture from file to object */
1242 function set_picture($filename ="")
1243 {
1244 if (!is_file($filename) || $filename =="" ){
1245 $filename= "./images/default.jpg";
1246 $this->jpegPhoto= "*removed*";
1247 }
1249 $fd = fopen ($filename, "rb");
1250 $this->photoData= fread ($fd, filesize ($filename));
1251 $_SESSION['binary']= $this->photoData;
1252 $_SESSION['binarytype']= "image/jpeg";
1253 $this->jpegPhoto= "";
1255 fclose ($fd);
1256 }
1259 /* Load certificate from file to object */
1260 function set_cert($cert, $filename)
1261 {
1262 if(!$thsi->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))) return;
1263 $fd = fopen ($filename, "rb");
1264 if (filesize($filename)>0) {
1265 $this->$cert= fread ($fd, filesize ($filename));
1266 fclose ($fd);
1267 $this->is_modified= TRUE;
1268 } else {
1269 print_red(_("Could not open specified certificate!"));
1270 }
1271 }
1273 /* Adapt from given 'dn' */
1274 function adapt_from_template($dn)
1275 {
1276 plugin::adapt_from_template($dn);
1278 /* Get base */
1279 $this->base= preg_replace('/^[^,]+,'.get_people_ou().'/i', '', $dn);
1281 if ($this->config->current['GOVERNMENTMODE']){
1283 /* Walk through govattrs */
1284 foreach ($this->govattrs as $val){
1286 if (isset($this->attrs["$val"][0])){
1288 /* If attribute is set, replace dynamic parts:
1289 %sn, %givenName and %uid. Fill these in our local variables. */
1290 $value= $this->attrs["$val"][0];
1292 foreach (array("sn", "givenName", "uid") as $repl){
1293 if (preg_match("/%$repl/i", $value)){
1294 $value= preg_replace ("/%$repl/i",
1295 $this->parent->$repl, $value);
1296 }
1297 }
1298 $this->$val= $value;
1299 }
1300 }
1301 }
1303 /* Get back uid/sn/givenName */
1304 if ($this->parent != NULL){
1305 $this->uid= $this->parent->uid;
1306 $this->sn= $this->parent->sn;
1307 $this->givenName= $this->parent->givenName;
1308 }
1309 }
1312 /* This avoids that users move themselves out of their rights.
1313 */
1314 function allowedBasesToMoveTo()
1315 {
1316 /* Get bases */
1317 $bases = $this->get_allowed_bases();
1318 return($bases);
1319 }
1322 function getCopyDialog()
1323 {
1324 $str = "";
1326 $_SESSION['binary'] = $this->photoData;
1327 $_SESSION['binarytype']= "image/jpeg";
1329 /* Get random number for pictures */
1330 srand((double)microtime()*1000000);
1331 $rand = rand(0, 10000);
1333 $smarty = get_smarty();
1335 $smarty->assign("passwordTodo","clear");
1337 if(isset($_POST['passwordTodo'])){
1338 $smarty->assign("passwordTodo",$_POST['passwordTodo']);
1339 }
1341 $smarty->assign("sn", $this->sn);
1342 $smarty->assign("givenName",$this->givenName);
1343 $smarty->assign("uid", $this->uid);
1344 $smarty->assign("rand", $rand);
1345 $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
1348 $ret = array();
1349 $ret['string'] = $str;
1350 $ret['status'] = "";
1351 return($ret);
1352 }
1354 function saveCopyDialog()
1355 {
1356 /* Set_acl_base */
1357 $this->set_acl_base("cn=dummy,".get_people_ou().$this->base);
1359 if((isset($_FILES['picture_file']['tmp_name'])) && ($_FILES['picture_file']['size'] > 0)){
1360 $this->set_picture($_FILES['picture_file']['tmp_name']);
1361 }
1363 /* Remove picture? */
1364 if (isset($_POST['picture_remove'])){
1365 $this->jpegPhoto= "*removed*";
1366 $this->set_picture ("./images/default.jpg");
1367 $this->is_modified= TRUE;
1368 }
1370 $attrs = array("uid","givenName","sn");
1371 foreach($attrs as $attr){
1372 if(isset($_POST[$attr])){
1373 $this->$attr = $_POST[$attr];
1374 }
1375 }
1376 }
1379 function PrepareForCopyPaste($source)
1380 {
1381 plugin::PrepareForCopyPaste($source);
1383 /* Reset certificate information addepted from source user
1384 to avoid setting the same user certificate for the destination user. */
1385 $this->userPKCS12= "";
1386 $this->userSMIMECertificate= "";
1387 $this->userCertificate= "";
1388 $this->certificateSerialNumber= "";
1389 $this->old_certificateSerialNumber= "";
1390 $this->old_userPKCS12= "";
1391 $this->old_userSMIMECertificate= "";
1392 $this->old_userCertificate= "";
1393 }
1396 function plInfo()
1397 {
1399 $govattrs= array(
1400 "gouvernmentOrganizationalUnit" => _("Unit"),
1401 "houseIdentifier" => _("House identifier"),
1402 "vocation" => _("Vocation"),
1403 "ivbbLastDeliveryCollective" => _("Last delivery"),
1404 "gouvernmentOrganizationalPersonLocality" => _("Person locality"),
1405 "gouvernmentOrganizationalUnitDescription" => _("Unit description"),
1406 "gouvernmentOrganizationalUnitSubjectArea" => _("Subject area"),
1407 "functionalTitle" => _("Functional title"),
1408 "certificateSerialNumber" => _("Certificate serial number"),
1409 "publicVisible" => _("Public visible"),
1410 "street" => _("Street"),
1411 "role" => _("Role"),
1412 "postalCode" => _("Postal code"));
1414 $ret = array(
1415 "plShortName" => _("Generic"),
1416 "plDescription" => _("Generic user settings"),
1417 "plSelfModify" => TRUE,
1418 "plDepends" => array(),
1419 "plPriority" => 1,
1420 "plSection" => array("personal" => _("My account")),
1421 "plCategory" => array("users" => array("description" => _("Users"),
1422 "objectClass" => "gosaAccount")),
1424 "plProvidedAcls" => array(
1425 "base" => _("Base"),
1426 "userPassword" => _("User password"),
1427 "sn" => _("Surename"),
1428 "givenName" => _("Given name"),
1429 "uid" => _("User identification"),
1430 "personalTitle" => _("Personal title"),
1431 "academicTitle" => _("Academic title"),
1432 "homePostalAddress" => _("Home postal address"),
1433 "homePhone" => _("Home phone number"),
1434 "labeledURI" => _("Homepage"),
1435 "o" => _("Organization"),
1436 "ou" => _("Department"),
1437 "dateOfBirth" => _("Date of birth"),
1438 "gender" => _("Gender"),
1439 "preferredLanguage" => _("Preferred language"),
1440 "departmentNumber" => _("Department number"),
1441 "employeeNumber" => _("Employee number"),
1442 "employeeType" => _("Employee type"),
1443 "l" => _("Location"),
1444 "st" => _("State"),
1445 "userPicture" => _("User picture"),
1446 "roomNumber" => _("Room number"),
1447 "telephoneNumber" => _("Telefon number"),
1448 "mobile" => _("Mobile number"),
1449 "pager" => _("Pager number"),
1450 "Certificate" => _("User certificates"),
1452 "postalAddress" => _("Postal address"),
1453 "facsimileTelephoneNumber" => _("Fax number"))
1454 );
1456 /* Append government attributes if required */
1457 global $config;
1458 if (isset($config->current['GOVERNMENTMODE']) && preg_match('/true/i', $config->current['GOVERNMENTMODE'])){
1459 foreach($govattrs as $attr => $desc){
1460 $ret["plProvidedAcls"][$attr] = $desc;
1461 }
1462 }
1464 return($ret);
1465 }
1466 }
1468 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1469 ?>