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;
123 $this->new_dn = $this->dn;
125 $this->new_dn = $dn;
127 if ($this->config->current['GOVERNMENTMODE']){
128 /* Fix public visible attribute if unset */
129 if (!isset($this->attrs['publicVisible'])){
130 $this->publicVisible == "nein";
131 }
132 }
134 /* Load government mode attributes */
135 if ($this->config->current['GOVERNMENTMODE']){
136 /* Copy all attributs */
137 foreach ($this->govattrs as $val){
138 if (isset($this->attrs["$val"][0])){
139 $this->$val= $this->attrs["$val"][0];
140 }
141 }
142 }
144 /* Create me for new accounts */
145 if ($dn == "new"){
146 $this->is_account= TRUE;
147 }
149 /* Make hash default to md5 if not set in config */
150 if (!isset($this->config->current['HASH'])){
151 $hash= "md5";
152 } else {
153 $hash= $this->config->current['HASH'];
154 }
156 /* Load data from LDAP? */
157 if ($dn !== NULL){
159 /* Do base conversation */
160 if ($this->dn == "new"){
161 $ui= get_userinfo();
162 $this->base= dn2base($ui->dn);
163 } else {
164 $this->base= dn2base($dn);
165 }
167 /* get password storage type */
168 if (isset ($this->attrs['userPassword'][0])){
169 /* Initialize local array */
170 $matches= array();
171 if (preg_match ("/^{([^}]+)}(.+)/", $this->attrs['userPassword'][0], $matches)){
172 $this->pw_storage= strtolower($matches[1]);
173 } else {
174 if ($this->attrs['userPassword'][0] != ""){
175 $this->pw_storage= "clear";
176 } else {
177 $this->pw_storage= $hash;
178 }
179 }
180 } else {
181 /* Preset with vaule from configuration */
182 $this->pw_storage= $hash;
183 }
185 /* Load extra attributes: certificate and picture */
186 $this->load_cert();
187 $this->load_picture();
188 if ($this->userCertificate != ""){
189 $this->had_userCertificate= TRUE;
190 }
191 }
193 /* Reset password storage indicator, used by password_change_needed() */
194 if ($dn == "new"){
195 $this->last_pw_storage= "unset";
196 } else {
197 $this->last_pw_storage= $this->pw_storage;
198 }
200 /* Generate dateOfBirth entry */
201 if (isset ($this->attrs['dateOfBirth'])){
202 /* This entry is ISO 8601 conform */
203 list($year, $month, $day)= split("-", $this->attrs['dateOfBirth'][0], 3);
205 $this->dateOfBirth=array( 'mon'=> $month,"mday"=> $day,"year"=> $year);
206 $this->use_dob= "1";
207 } else {
208 $this->use_dob= "0";
209 }
211 /* Put gender attribute to upper case */
212 if (isset ($this->attrs['gender'])){
213 $this->gender= strtoupper($this->attrs['gender'][0]);
214 }
216 $this->orig_base = $this->base;
217 }
220 /* execute generates the html output for this node */
221 function execute()
222 {
223 /* Call parent execute */
224 plugin::execute();
226 /* Log view */
227 if($this->is_account && !$this->view_logged){
228 $this->view_logged = TRUE;
229 new log("view","users/".get_class($this),$this->dn);
230 }
232 $smarty= get_smarty();
234 /* Fill calendar */
235 if ($this->dateOfBirth == "0"){
236 $date= getdate();
237 } else {
238 if(is_array($this->dateOfBirth)){
239 $date = $this->dateOfBirth;
241 // Trigger on dates like 1985-04-01, getdate only understands timestamps
242 } else if (!empty($this->dateOfBirth) && !is_numeric($this->dateOfBirth)){
243 $date= getdate(strtotime($this->dateOfBirth));
245 } else {
246 $date = getdate($this->dateOfBirth);
247 }
248 }
250 $days= array();
251 for($d= 1; $d<32; $d++){
252 $days[$d]= $d;
253 }
254 $years= array();
256 if(($date['year']-100)<1901){
257 $start = 1901;
258 }else{
259 $start = $date['year']-100;
260 }
262 $end = $start +100;
264 for($y= $start; $y<=$end; $y++){
265 $years[]= $y;
266 }
267 $years['-']= "- ";
268 $months= array(_("January"), _("February"), _("March"), _("April"),
269 _("May"), _("June"), _("July"), _("August"), _("September"),
270 _("October"), _("November"), _("December"), '-' => '- ');
271 $smarty->assign("day", $date["mday"]);
272 $smarty->assign("days", $days);
273 $smarty->assign("months", $months);
274 $smarty->assign("month", $date["mon"]-1);
275 $smarty->assign("years", $years);
276 $smarty->assign("year", $date["year"]);
278 /* Assign sex */
279 $sex= array(0 => " ", "F" => _("female"), "M" => _("male"));
280 $smarty->assign("gender_list", $sex);
282 $language= array_merge(array(0 => " ") ,get_languages(TRUE));
283 $smarty->assign("preferredLanguage_list", $language);
285 /* Get random number for pictures */
286 srand((double)microtime()*1000000);
287 $smarty->assign("rand", rand(0, 10000));
290 /* Do we represent a valid gosaAccount? */
291 if (!$this->is_account){
292 echo "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
293 _("This account has no valid GOsa extensions.")."</b>";
294 return;
295 }
297 /* Base select dialog */
298 $once = true;
299 foreach($_POST as $name => $value){
300 if(preg_match("/^chooseBase/",$name) && $once){
301 $once = false;
302 $this->dialog = new baseSelectDialog($this->config,$this,$this->allowedBasesToMoveTo());
303 $this->dialog->setCurrentBase($this->base);
304 }
305 }
307 /* Dialog handling */
308 if(is_object($this->dialog)){
309 /* Must be called before save_object */
310 $this->dialog->save_object();
312 if($this->dialog->isClosed()){
313 $this->dialog = false;
314 }elseif($this->dialog->isSelected()){
316 /* check if selected base is allowed to move to / create a new object */
317 $tmp = $this->get_allowed_bases();
318 if(isset($tmp[$this->dialog->isSelected()])){
319 $this->base = $this->dialog->isSelected();
320 }
321 $this->dialog= false;
322 }else{
323 return($this->dialog->execute());
324 }
325 }
327 /* Want picture edit dialog? */
328 if($this->acl_is_writeable("userPicture")) {
329 if (isset($_POST['edit_picture'])){
330 /* Save values for later recovery, in case some presses
331 the cancel button. */
332 $this->old_jpegPhoto= $this->jpegPhoto;
333 $this->old_photoData= $this->photoData;
334 $this->picture_dialog= TRUE;
335 $this->dialog= TRUE;
336 }
337 }
339 /* Remove picture? */
340 if($this->acl_is_writeable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))) ){
341 if (isset($_POST['picture_remove'])){
342 $this->set_picture ();
343 $this->jpegPhoto= "*removed*";
344 $this->is_modified= TRUE;
345 return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
346 }
347 }
349 /* Save picture */
350 if (isset($_POST['picture_edit_finish'])){
352 /* Check for clean upload */
353 if ($_FILES['picture_file']['name'] != ""){
354 if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) {
355 print_red(_("The specified file has not been uploaded via HTTP POST! Aborted."));
356 }else{
357 /* Activate new picture */
358 $this->set_picture($_FILES['picture_file']['tmp_name']);
359 }
360 }
361 $this->picture_dialog= FALSE;
362 $this->dialog= FALSE;
363 $this->is_modified= TRUE;
364 }
367 /* Cancel picture */
368 if (isset($_POST['picture_edit_cancel'])){
370 /* Restore values */
371 $this->jpegPhoto= $this->old_jpegPhoto;
372 $this->photoData= $this->old_photoData;
374 /* Update picture */
375 $_SESSION['binary']= $this->photoData;
376 $_SESSION['binarytype']= "image/jpeg";
377 $this->picture_dialog= FALSE;
378 $this->dialog= FALSE;
379 }
381 /* Toggle dateOfBirth information */
382 if (isset($_POST['set_dob'])){
383 $this->use_dob= ($this->use_dob == "0")?"1":"0";
384 }
387 /* Want certificate= */
388 if ((isset($_POST['edit_cert'])) && $this->acl_is_readable("Certificate")){
390 /* Save original values for later reconstruction */
391 foreach (array("certificateSerialNumber", "userCertificate",
392 "userSMIMECertificate", "userPKCS12") as $val){
394 $oval= "old_$val";
395 $this->$oval= $this->$val;
396 }
398 $this->cert_dialog= TRUE;
399 $this->dialog= TRUE;
400 }
403 /* Cancel certificate dialog */
404 if (isset($_POST['cert_edit_cancel'])){
406 /* Restore original values in case of 'cancel' */
407 foreach (array("certificateSerialNumber", "userCertificate",
408 "userSMIMECertificate", "userPKCS12") as $val){
410 $oval= "old_$val";
411 $this->$val= $this->$oval;
412 }
413 $this->cert_dialog= FALSE;
414 $this->dialog= FALSE;
415 }
418 /* Remove certificate? */
419 if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
420 foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") as $val){
421 if (isset($_POST["remove_$val"])){
423 /* Reset specified cert*/
424 $this->$val= "";
425 $this->is_modified= TRUE;
426 }
427 }
428 }
430 /* Upload new cert and close dialog? */
431 if($this->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
432 if (isset($_POST['cert_edit_finish'])){
434 /* for all certificates do */
435 foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12")
436 as $val){
438 /* Check for clean upload */
439 if (array_key_exists($val."_file", $_FILES) &&
440 array_key_exists('name', $_FILES[$val."_file"]) &&
441 $_FILES[$val."_file"]['name'] != "" &&
442 is_uploaded_file($_FILES[$val."_file"]['tmp_name'])) {
443 $this->set_cert("$val", $_FILES[$val."_file"]['tmp_name']);
444 }
445 }
447 /* Save serial number */
448 if (isset($_POST["certificateSerialNumber"]) &&
449 $_POST["certificateSerialNumber"] != ""){
451 if (!is_id($_POST["certificateSerialNumber"])){
452 print_red (_("Please enter a valid serial number"));
454 foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
455 if ($this->$cert != ""){
456 $smarty->assign("$cert"."_state", "true");
457 } else {
458 $smarty->assign("$cert"."_state", "");
459 }
460 }
461 return ($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
462 }
464 $this->certificateSerialNumber= $_POST["certificateSerialNumber"];
465 $this->is_modified= TRUE;
466 }
468 $this->cert_dialog= FALSE;
469 $this->dialog= FALSE;
470 }
471 }
472 /* Display picture dialog */
473 if ($this->picture_dialog){
474 return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
475 }
477 /* Display cert dialog */
478 if ($this->cert_dialog){
479 $smarty->assign("CertificateACL",$this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
480 $smarty->assign("Certificate_readable",$this->acl_is_readable("Certificate"));
482 foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
483 if ($this->$cert != ""){
484 /* import certificate */
485 $certificate = new certificate;
486 $certificate->import($this->$cert);
488 /* Read out data*/
489 $timeto = $certificate->getvalidto_date();
490 $timefrom = $certificate->getvalidfrom_date();
493 /* Additional info if start end time is '0' */
494 $add_str_info = "";
495 if($timeto == 0 && $timefrom == 0){
496 $add_str_info = "<br><i>"._("(Some types of certificates are currently not supported and may be displayed as 'invalid'.)")."</i>";
497 }
499 $str = "<table summary=\"\" border=0>
500 <tr>
501 <td style='vertical-align:top'>CN</td>
502 <td>".preg_replace("/ /", " ", $certificate->getname())."</td>
503 </tr>
504 </table><br>".
506 sprintf(_("Certificate is valid from %s to %s and is currently %s."),
507 "<b>".date('d M Y',$timefrom)."</b>",
508 "<b>".date('d M Y',$timeto)."</b>",
509 $certificate->isvalid()?"<b><font style='color:green'>"._("valid")."</font></b>":
510 "<b><font style='color:red'>"._("invalid")."</font></b>").$add_str_info;
512 $smarty->assign($cert."info",$str);
513 $smarty->assign($cert."_state","true");
514 } else {
515 $smarty->assign($cert."info", "<i>"._("No certificate installed")."</i>");
516 $smarty->assign($cert."_state","");
517 }
518 }
519 $smarty->assign("governmentmode", "false");
520 return($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
521 }
523 /* Prepare password hashes */
524 if ($this->pw_storage == ""){
525 $this->pw_storage= $this->config->current['HASH'];
526 }
528 $temp= passwordMethod::get_available_methods();
529 $hashes = $temp['name'];
531 /* Load attributes and acl's */
532 $ui =get_userinfo();
533 foreach($this->attributes as $val){
534 $smarty->assign("$val", $this->$val);
535 }
537 /* Set acls */
538 $tmp = $this->plinfo();
539 foreach($tmp['plProvidedAcls'] as $val => $translation){
540 $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
541 }
543 $smarty->assign("pwmode", $hashes);
544 $smarty->assign("pwmode_select", $this->pw_storage);
545 $smarty->assign("passwordStorageACL", $this->getacl("userPassword",(!is_object($this->parent) && !isset($_SESSION['edit']))));
546 $smarty->assign("base_select", $this->base);
547 $smarty->assign("CertificatesACL", $this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
548 $smarty->assign("userPictureACL", $this->getacl("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
549 $smarty->assign("userPicture_is_readable", $this->acl_is_readable("userPicture",(!is_object($this->parent) && !isset($_SESSION['edit']))));
551 /* Create base acls */
552 @$smarty->assign("bases", $this->allowedBasesToMoveTo());
554 /* Save government mode attributes */
555 if (isset($this->config->current['GOVERNMENTMODE']) &&
556 preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){
557 $smarty->assign("governmentmode", "true");
558 $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet",
559 "internet,ivbv", "internet,testa", "internet,ivbv,testa");
560 $smarty->assign("ivbbmodes", $ivbbmodes);
561 foreach ($this->govattrs as $val){
562 $smarty->assign("$val", $this->$val);
563 $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
564 }
565 } else {
566 $smarty->assign("governmentmode", "false");
567 }
569 /* Special mode for uid */
570 $uidACL= $this->getacl("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])));
571 if (isset ($this->dn)){
572 if ($this->dn != "new"){
573 $uidACL= preg_replace("/w/","",$uidACL);
574 }
575 } else {
576 $uidACL= preg_replace("/w/","",$uidACL);
577 }
579 $smarty->assign("uidACL", $uidACL);
580 $smarty->assign("is_template", $this->is_template);
581 $smarty->assign("use_dob", $this->use_dob);
583 if (isset($this->parent)){
584 if (isset($this->parent->by_object['phoneAccount']) &&
585 $this->parent->by_object['phoneAccount']->is_account){
586 $smarty->assign("has_phoneaccount", "true");
587 } else {
588 $smarty->assign("has_phoneaccount", "false");
589 }
590 } else {
591 $smarty->assign("has_phoneaccount", "false");
592 }
593 return($smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__))));
594 }
597 /* remove object from parent */
598 function remove_from_parent()
599 {
600 $ldap= $this->config->get_ldap_link();
601 $ldap->rmdir ($this->dn);
602 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/generic account with dn '%s' failed."),$this->dn));
604 new log("remove","users/".get_class($this),$this->dn,$this->attributes,$ldap->get_error());
606 /* Delete references to groups */
607 $ldap->cd ($this->config->current['BASE']);
608 $ldap->search ("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("uid"));
609 while ($ldap->fetch()){
610 $g= new group($this->config, $ldap->getDN());
611 $g->removeUser($this->uid);
612 $g->save ();
613 }
615 /* Delete references to object groups */
616 $ldap->cd ($this->config->current['BASE']);
617 $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
618 while ($ldap->fetch()){
619 $og= new ogroup($this->config, $ldap->getDN());
620 unset($og->member[$this->dn]);
621 $og->save ();
622 }
624 /* Kerberos server defined? */
625 if (isset($this->config->data['SERVERS']['KERBEROS'])){
626 $cfg= $this->config->data['SERVERS']['KERBEROS'];
627 }
628 if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
630 /* Connect to the admin interface */
631 $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
632 $cfg['ADMIN'], $cfg['PASSWORD']);
634 /* Errors? */
635 if ($handle === FALSE){
636 print_red (_("Kerberos database communication failed"));
637 return (2);
638 }
640 /* Build user principal, get list of existsing principals */
641 $principal= $this->uid."@".$cfg['REALM'];
642 $principals = kadm5_get_principals($handle);
644 /* User exists in database? */
645 if (in_array($principal, $principals)){
647 /* Ok. User exists. Remove him/her */
648 $ret= kadm5_delete_principal ( $handle, $principal);
649 if ($ret === FALSE){
650 print_red (_("Can't remove user from kerberos database."));
651 }
652 }
654 /* Free kerberos admin handle */
655 kadm5_destroy($handle);
656 }
658 /* Remove ACL dependencies too,
659 */
660 $tmp = new acl($this->config,$this->parent,$this->dn);
661 $tmp->remove_acl();
663 /* Optionally execute a command after we're done */
664 $this->handle_post_events("remove",array("uid" => $this->uid));
665 }
668 /* Save data to object */
669 function save_object()
670 {
671 if (isset($_POST['generic'])){
673 /* Make a backup of the current selected base */
674 $base_tmp = $this->base;
676 /* Parents save function */
677 plugin::save_object ();
679 /* Save government mode attributes */
680 if ($this->config->current['GOVERNMENTMODE']){
681 foreach ($this->govattrs as $val){
682 if ($this->acl_is_writeable($val,(!is_object($this->parent) && !isset($_SESSION['edit']))) && isset($_POST["$val"])){
683 $data= stripcslashes($_POST["$val"]);
684 if ($data != $this->$val){
685 $this->is_modified= TRUE;
686 }
687 $this->$val= $data;
688 }
689 }
690 }
692 /* In template mode, the uid is autogenerated... */
693 if ($this->is_template){
694 $this->uid= strtolower($this->sn);
695 $this->givenName= $this->sn;
696 }
698 /* Save base and pw_storage, since these are no LDAP attributes */
699 if (isset($_POST['base'])){
701 $tmp = $this->get_allowed_bases();
702 if(isset($tmp[$_POST['base']])){
703 $base= validate($_POST['base']);
704 if ($base != $this->base){
705 $this->is_modified= TRUE;
706 }
707 $this->base= $base;
708 }else{
709 $this->base = $base_tmp;
710 print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base'])));
711 $this->set_acl_base('dummy,'.$this->base);
712 }
713 }
715 /* Get pw_storage mode */
716 if (isset($_POST['pw_storage'])){
717 foreach(array("pw_storage") as $val){
718 if(isset($_POST[$val])){
719 $data= validate($_POST[$val]);
720 if ($data != $this->$val){
721 $this->is_modified= TRUE;
722 }
723 $this->$val= $data;
724 }
725 }
726 }
728 $this->set_acl_base('dummy,'.$this->base);
729 }
730 }
732 function rebind($ldap, $referral)
733 {
734 $credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']);
735 if (ldap_bind($ldap, $credentials['ADMIN'], $credentials['PASSWORD'])) {
736 $this->error = "Success";
737 $this->hascon=true;
738 $this->reconnect= true;
739 return (0);
740 } else {
741 $this->error = "Could not bind to " . $credentials['ADMIN'];
742 return NULL;
743 }
744 }
746 /* Save data to LDAP, depending on is_account we save or delete */
747 function save()
748 {
749 /* Only force save of changes ....
750 If this attributes aren't changed, avoid saving.
751 */
752 if($this->gender=="0") $this->gender ="";
753 if($this->preferredLanguage=="0") $this->preferredLanguage ="";
756 /* First use parents methods to do some basic fillup in $this->attrs */
757 plugin::save ();
759 if ($this->use_dob == "1"){
760 /* 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. */
761 if(!is_array($this->attrs['dateOfBirth'])) {
762 $this->attrs['dateOfBirth'] = date("Y-m-d", $this->dateOfBirth);
763 }
764 }
766 /* Remove additional objectClasses */
767 $tmp= array();
768 foreach ($this->attrs['objectClass'] as $key => $set){
769 $found= false;
770 foreach (array("ivbbentry", "gosaUserTemplate") as $val){
771 if (preg_match ("/^$set$/i", $val)){
772 $found= true;
773 break;
774 }
775 }
776 if (!$found){
777 $tmp[]= $set;
778 }
779 }
781 /* Replace the objectClass array. This is done because of the
782 separation into government and normal mode. */
783 $this->attrs['objectClass']= $tmp;
785 /* Add objectClasss for template mode? */
786 if ($this->is_template){
787 $this->attrs['objectClass'][]= "gosaUserTemplate";
788 }
790 /* Hard coded government mode? */
791 if ($this->config->current['GOVERNMENTMODE'] != 'false'){
792 $this->attrs['objectClass'][]= "ivbbentry";
794 /* Copy standard attributes */
795 foreach ($this->govattrs as $val){
796 if ($this->$val != ""){
797 $this->attrs["$val"]= $this->$val;
798 } elseif (!$this->is_new) {
799 $this->attrs["$val"]= array();
800 }
801 }
803 /* Remove attribute if set to "nein" */
804 if ($this->publicVisible == "nein"){
805 $this->attrs['publicVisible']= array();
806 if($this->is_new){
807 unset($this->attrs['publicVisible']);
808 }else{
809 $this->attrs['publicVisible']=array();
810 }
812 }
814 }
816 /* Special handling for attribute userCertificate needed */
817 if ($this->userCertificate != ""){
818 $this->attrs["userCertificate;binary"]= $this->userCertificate;
819 $remove_userCertificate= false;
820 } else {
821 $remove_userCertificate= true;
822 }
824 /* Special handling for dateOfBirth value */
825 if ($this->use_dob != "1"){
826 if ($this->is_new) {
827 unset($this->attrs["dateOfBirth"]);
828 } else {
829 $this->attrs["dateOfBirth"]= array();
830 }
831 }
832 if (!$this->gender){
833 if ($this->is_new) {
834 unset($this->attrs["gender"]);
835 } else {
836 $this->attrs["gender"]= array();
837 }
838 }
839 if (!$this->preferredLanguage){
840 if ($this->is_new) {
841 unset($this->attrs["preferredLanguage"]);
842 } else {
843 $this->attrs["preferredLanguage"]= array();
844 }
845 }
847 /* Special handling for attribute jpegPhote needed, scale image via
848 image magick to 147x200 pixels and inject resulting data. */
849 if ($this->jpegPhoto == "*removed*"){
851 /* Reset attribute to avoid writing *removed* as value */
852 $this->attrs["jpegPhoto"] = array();
854 } else {
856 /* Fallback if there's no image magick inside PHP */
857 if (!function_exists("imagick_blob2image")){
858 /* Get temporary file name for conversation */
859 $fname = tempnam ("/tmp", "GOsa");
861 /* Open file and write out photoData */
862 $fp = fopen ($fname, "w");
863 fwrite ($fp, $this->photoData);
864 fclose ($fp);
866 /* Build conversation query. Filename is generated automatically, so
867 we do not need any special security checks. Exec command and save
868 output. For PHP safe mode, you'll need a configuration which respects
869 image magick as executable... */
870 $query= "convert -size 147x200 $fname -resize 147x200 +profile \"*\" -";
871 @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
872 $query, "Execute");
874 /* Read data written by convert */
875 $output= "";
876 $sh= popen($query, 'r');
877 while (!feof($sh)){
878 $output.= fread($sh, 4096);
879 }
880 pclose($sh);
882 unlink($fname);
884 /* Save attribute */
885 $this->attrs["jpegPhoto"] = $output;
887 } else {
889 /* Load the new uploaded Photo */
890 if(!$handle = imagick_blob2image($this->photoData)) {
891 new log("debug","users/".get_class($this),"",array(),"Could not access uploaded image");
892 }
894 /* Resizing image to 147x200 and blur */
895 if(!imagick_resize($handle,147,200,IMAGICK_FILTER_GAUSSIAN,0)){
896 new log("debug","users/".get_class($this),"",array(),"Could not resize uploaded image");
897 }
899 /* Converting image to JPEG */
900 if(!imagick_convert($handle,"JPEG")) {
901 new log("debug","users/".get_class($this),"",array(),"Could not convert uploaded image to jepg");
902 }
904 /* Creating binary Code for the Image */
905 if(!$dump = imagick_image2blob($handle)){
906 new log("debug","users/".get_class($this),"",array(),"Could not create new user image");
907 }
909 /* Sending Image */
910 $output= $dump;
912 /* Save attribute */
913 $this->attrs["jpegPhoto"] = $output;
914 }
916 }
918 /* This only gets called when user is renaming himself */
919 $ldap= $this->config->get_ldap_link();
920 if ($this->dn != $this->new_dn){
922 /* Write entry on new 'dn' */
923 $this->update_acls($this->dn,$this->new_dn);
924 $this->move($this->dn, $this->new_dn);
926 /* Happen to use the new one */
927 change_ui_dn($this->dn, $this->new_dn);
928 $this->dn= $this->new_dn;
929 }
932 /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
933 new entries. So do a check first... */
934 $ldap->cat ($this->dn, array('dn'));
935 if ($ldap->fetch()){
936 $mode= "modify";
937 } else {
938 $mode= "add";
939 $ldap->cd($this->config->current['BASE']);
940 $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
941 }
943 /* Set password to some junk stuff in case of templates */
944 if ($this->is_template){
945 $this->attrs['userPassword']= '{crypt}N0T$3T4N0W';
946 }
948 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
949 $this->attributes, "Save via $mode");
951 /* Finally write data with selected 'mode' */
952 $this->cleanup();
954 if(isset($this->attrs['preferredLanguage'])){
955 $_SESSION['ui']->language = $this->preferredLanguage;
956 $_SESSION['Last_init_lang'] = "update";
957 }
959 $ldap->cd ($this->dn);
960 $ldap->$mode ($this->attrs);
961 if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/generic account with dn '%s' failed."),$this->dn))){
962 return (1);
963 }
966 /* Remove ACL dependencies too,
967 */
968 if($this->dn != $this->orig_dn && $this->orig_dn != "new"){
969 $tmp = new acl($this->config,$this->parent,$this->dn);
970 $tmp->update_acl_membership($this->orig_dn,$this->dn);
971 }
973 if($mode == "modify"){
974 new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
975 }else{
976 new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
977 }
979 /* Remove cert?
980 For some reason, the 'ldap' class doesn't want to remove binary entries, so I need
981 to work around myself. */
982 if ($remove_userCertificate == true && !$this->is_new && $this->had_userCertificate){
984 /* Reset array, assemble new, this should be reworked */
985 $this->attrs= array();
986 $this->attrs['userCertificate;binary']= array();
988 /* Prepare connection */
989 if (!($ds = ldap_connect($this->config->current['SERVER']))) {
990 die ("Could not connect to LDAP server");
991 }
992 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
993 if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
994 ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
995 ldap_set_rebind_proc($ds, array(&$this, "rebind"));
996 }
997 if(isset($config->current['TLS']) && $config->current['TLS'] == "true"){
998 ldap_start_tls($ds);
999 }
1000 if (!($res = @ldap_bind($ds, $this->config->current['ADMIN'],
1001 $this->config->current['PASSWORD']))) {
1002 die ("Could not bind to LDAP");
1003 }
1005 /* Modify using attrs */
1006 ldap_mod_del($ds,$this->dn,$this->attrs);
1007 ldap_close($ds);
1008 }
1010 /* Kerberos server defined? */
1011 if (isset($this->config->data['SERVERS']['KERBEROS'])){
1012 $cfg= $this->config->data['SERVERS']['KERBEROS'];
1013 }
1014 if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
1016 /* Connect to the admin interface */
1017 $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
1018 $cfg['ADMIN'], $cfg['PASSWORD']);
1020 /* Errors? */
1021 if ($handle === FALSE){
1022 print_red (_("Kerberos database communication failed"));
1023 return (2);
1024 }
1026 /* Build user principal, get list of existsing principals */
1027 $principal= $this->uid."@".$cfg['REALM'];
1028 $principals = kadm5_get_principals($handle);
1030 /* User exists in database? */
1031 if (in_array($principal, $principals)){
1033 /* Ok. User exists. Remove him/her when pw_storage has
1034 changed to be NOT kerberos. */
1035 if ($this->pw_storage != $this->config->current['KRBSASL']){
1036 $ret= kadm5_delete_principal ( $handle, $principal);
1038 if ($ret === FALSE){
1039 print_red (_("Can't remove user from kerberos database."));
1040 }
1041 }
1043 } else {
1045 /* User doesn't exists, create it when pw_storage is kerberos. */
1046 if ($this->pw_storage == "kerberos" || $this->pw_storage == "sasl" ){
1047 $ret= kadm5_create_principal ( $handle, $principal);
1049 if ($ret === FALSE){
1050 print_red (_("Can't add user to kerberos database."));
1051 }
1052 }
1054 }
1056 /* Free kerberos admin handle */
1057 kadm5_destroy($handle);
1058 }
1060 /* Optionally execute a command after we're done */
1061 if ($mode == "add"){
1062 $this->handle_post_events("add", array("uid" => $this->uid));
1063 } elseif ($this->is_modified){
1064 $this->handle_post_events("modify", array("uid" => $this->uid));
1065 }
1067 /* Fix tagging if needed */
1068 $this->handle_object_tagging();
1070 return (0);
1071 }
1074 /* Check formular input */
1075 function check()
1076 {
1077 /* Call common method to give check the hook */
1078 $message= plugin::check();
1080 $pt= "";
1081 if(isset($this->config->current['INCLUDE_PERSONAL_TITLE']) && preg_match("/true/i",$this->config->current['INCLUDE_PERSONAL_TITLE'])){
1082 if(!empty($this->personalTitle)){
1083 $pt = $this->personalTitle." ";
1084 }
1085 }
1086 $this->cn= $pt.$this->givenName." ".$this->sn;
1088 /* Permissions for that base? */
1089 if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
1090 $this->new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
1091 } else {
1092 /* Don't touch dn, if cn hasn't changed */
1093 if (isset($this->saved_attributes['cn']) && $this->saved_attributes['cn'] == $this->cn &&
1094 $this->orig_base == $this->base ){
1095 $this->new_dn= $this->dn;
1096 } else {
1097 $this->new_dn= $this->create_unique_dn('cn', get_people_ou().$this->base);
1098 }
1099 }
1101 /* Set the new acl base */
1102 if($this->dn == "new") {
1103 $this->set_acl_base($this->base);
1104 }
1106 /* must: sn, givenName, uid */
1107 if ($this->sn == "" && ($this->acl_is_writeable("sn",(!is_object($this->parent) && !isset($_SESSION['edit'])) || ($this->is_new)))){
1108 $message[]= _("The required field 'Name' is not set.");
1109 }
1111 /* UID already used? */
1112 $ldap= $this->config->get_ldap_link();
1113 $ldap->cd($this->config->current['BASE']);
1114 $ldap->search("(uid=$this->uid)", array("uid"));
1115 $ldap->fetch();
1116 if ($ldap->count() != 0 && $this->dn == 'new'){
1117 $message[]= _("There's already a person with this 'Login' in the database.");
1118 }
1120 /* In template mode, the uid and givenName are autogenerated... */
1121 if (!$this->is_template){
1122 if ($this->givenName == "" && $this->acl_is_writeable("givenName",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1123 $message[]= _("The required field 'Given name' is not set.");
1124 }
1125 if ($this->uid == "" && $this->acl_is_writeable("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
1126 $message[]= _("The required field 'Login' is not set.");
1127 }
1128 if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
1129 $ldap->cat($this->new_dn);
1130 if ($ldap->count() != 0 && $this->dn != $this->new_dn && $this->dn == 'new'){
1131 $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
1132 }
1133 }
1134 }
1136 /* Check for valid input */
1137 if ($this->is_modified && !is_uid($this->uid)){
1138 $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed.");
1139 }
1140 if (!is_url($this->labeledURI)){
1141 $message[]= _("The field 'Homepage' contains an invalid URL definition.");
1142 }
1143 if (preg_match ("/[\\\\]/", $this->sn)){
1144 $message[]= _("The field 'Name' contains invalid characters.");
1145 }
1146 if (preg_match ("/[\\\\]/", $this->givenName)){
1147 $message[]= _("The field 'Given name' contains invalid characters.");
1148 }
1150 /* Check phone numbers */
1151 if (!is_phone_nr($this->telephoneNumber)){
1152 $message[]= _("The field 'Phone' contains an invalid phone number.");
1153 }
1154 if (!is_phone_nr($this->facsimileTelephoneNumber)){
1155 $message[]= _("The field 'Fax' contains an invalid phone number.");
1156 }
1157 if (!is_phone_nr($this->mobile)){
1158 $message[]= _("The field 'Mobile' contains an invalid phone number.");
1159 }
1160 if (!is_phone_nr($this->pager)){
1161 $message[]= _("The field 'Pager' contains an invalid phone number.");
1162 }
1164 /* Check for reserved characers */
1165 if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName)){
1166 $message[]= _("The field 'Given name' contains invalid characters.");
1167 }
1168 if (preg_match ('/[,+"?\'()=<>;]/', $this->sn)){
1169 $message[]= _("The field 'Name' contains invalid characters.");
1170 }
1172 return $message;
1173 }
1176 /* Indicate whether a password change is needed or not */
1177 function password_change_needed()
1178 {
1179 return ($this->pw_storage != $this->last_pw_storage);
1180 }
1183 /* Load a jpegPhoto from LDAP, this is going to be simplified later on */
1184 function load_picture()
1185 {
1186 $ldap = $this->config->get_ldap_link();
1187 $ldap->cd ($this->dn);
1188 $data = $ldap->get_attribute($this->dn,"jpegPhoto");
1190 if((!$data) || ($data == "*removed*")){
1192 /* In case we don't get an entry, load a default picture */
1193 $this->set_picture ();//"./images/default.jpg");
1194 $this->jpegPhoto= "*removed*";
1195 }else{
1197 /* Set picture */
1198 $this->photoData= $data;
1199 $_SESSION['binary']= $this->photoData;
1200 $_SESSION['binarytype']= "image/jpeg";
1201 $this->jpegPhoto= "";
1202 }
1203 }
1206 /* Load a certificate from LDAP, this is going to be simplified later on */
1207 function load_cert()
1208 {
1209 $ds= ldap_connect($this->config->current['SERVER']);
1210 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
1211 if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
1212 ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
1213 ldap_set_rebind_proc($ds, array(&$this, "rebind"));
1214 }
1215 if(isset($this->config->current['TLS']) &&
1216 $this->config->current['TLS'] == "true"){
1218 ldap_start_tls($ds);
1219 }
1221 $r= ldap_bind($ds);
1222 $sr= @ldap_read($ds, $this->dn, "userCertificate=*", array("userCertificate"));
1224 if ($sr) {
1225 $ei= @ldap_first_entry($ds, $sr);
1227 if ($ei) {
1228 if (!$info = @ldap_get_values_len($ds, $ei, "userCertificate;binary")){
1229 $this->userCertificate= "";
1230 } else {
1231 $this->userCertificate= $info[0];
1232 }
1233 }
1234 } else {
1235 $this->userCertificate= "";
1236 }
1238 ldap_unbind($ds);
1239 }
1242 /* Load picture from file to object */
1243 function set_picture($filename ="")
1244 {
1245 if (!is_file($filename) || $filename =="" ){
1246 $filename= "./images/default.jpg";
1247 $this->jpegPhoto= "*removed*";
1248 }
1250 $fd = fopen ($filename, "rb");
1251 $this->photoData= fread ($fd, filesize ($filename));
1252 $_SESSION['binary']= $this->photoData;
1253 $_SESSION['binarytype']= "image/jpeg";
1254 $this->jpegPhoto= "";
1256 fclose ($fd);
1257 }
1260 /* Load certificate from file to object */
1261 function set_cert($cert, $filename)
1262 {
1263 if(!$thsi->acl_is_writeable("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit'])))) return;
1264 $fd = fopen ($filename, "rb");
1265 if (filesize($filename)>0) {
1266 $this->$cert= fread ($fd, filesize ($filename));
1267 fclose ($fd);
1268 $this->is_modified= TRUE;
1269 } else {
1270 print_red(_("Could not open specified certificate!"));
1271 }
1272 }
1274 /* Adapt from given 'dn' */
1275 function adapt_from_template($dn)
1276 {
1277 plugin::adapt_from_template($dn);
1279 /* Get base */
1280 $this->base= preg_replace('/^[^,]+,'.get_people_ou().'/i', '', $dn);
1282 if ($this->config->current['GOVERNMENTMODE']){
1284 /* Walk through govattrs */
1285 foreach ($this->govattrs as $val){
1287 if (isset($this->attrs["$val"][0])){
1289 /* If attribute is set, replace dynamic parts:
1290 %sn, %givenName and %uid. Fill these in our local variables. */
1291 $value= $this->attrs["$val"][0];
1293 foreach (array("sn", "givenName", "uid") as $repl){
1294 if (preg_match("/%$repl/i", $value)){
1295 $value= preg_replace ("/%$repl/i",
1296 $this->parent->$repl, $value);
1297 }
1298 }
1299 $this->$val= $value;
1300 }
1301 }
1302 }
1304 /* Get back uid/sn/givenName */
1305 if ($this->parent !== NULL){
1306 $this->uid= $this->parent->uid;
1307 $this->sn= $this->parent->sn;
1308 $this->givenName= $this->parent->givenName;
1309 }
1310 }
1313 /* This avoids that users move themselves out of their rights.
1314 */
1315 function allowedBasesToMoveTo()
1316 {
1317 /* Get bases */
1318 $bases = $this->get_allowed_bases();
1319 return($bases);
1320 }
1323 function getCopyDialog()
1324 {
1325 $str = "";
1327 $_SESSION['binary'] = $this->photoData;
1328 $_SESSION['binarytype']= "image/jpeg";
1330 /* Get random number for pictures */
1331 srand((double)microtime()*1000000);
1332 $rand = rand(0, 10000);
1334 $smarty = get_smarty();
1336 $smarty->assign("passwordTodo","clear");
1338 if(isset($_POST['passwordTodo'])){
1339 $smarty->assign("passwordTodo",$_POST['passwordTodo']);
1340 }
1342 $smarty->assign("sn", $this->sn);
1343 $smarty->assign("givenName",$this->givenName);
1344 $smarty->assign("uid", $this->uid);
1345 $smarty->assign("rand", $rand);
1346 $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
1349 $ret = array();
1350 $ret['string'] = $str;
1351 $ret['status'] = "";
1352 return($ret);
1353 }
1355 function saveCopyDialog()
1356 {
1357 /* Set_acl_base */
1358 $this->set_acl_base("cn=dummy,".get_people_ou().$this->base);
1360 if((isset($_FILES['picture_file']['tmp_name'])) && ($_FILES['picture_file']['size'] > 0)){
1361 $this->set_picture($_FILES['picture_file']['tmp_name']);
1362 }
1364 /* Remove picture? */
1365 if (isset($_POST['picture_remove'])){
1366 $this->jpegPhoto= "*removed*";
1367 $this->set_picture ("./images/default.jpg");
1368 $this->is_modified= TRUE;
1369 }
1371 $attrs = array("uid","givenName","sn");
1372 foreach($attrs as $attr){
1373 if(isset($_POST[$attr])){
1374 $this->$attr = $_POST[$attr];
1375 }
1376 }
1377 }
1380 function PrepareForCopyPaste($source)
1381 {
1382 plugin::PrepareForCopyPaste($source);
1384 /* Reset certificate information addepted from source user
1385 to avoid setting the same user certificate for the destination user. */
1386 $this->userPKCS12= "";
1387 $this->userSMIMECertificate= "";
1388 $this->userCertificate= "";
1389 $this->certificateSerialNumber= "";
1390 $this->old_certificateSerialNumber= "";
1391 $this->old_userPKCS12= "";
1392 $this->old_userSMIMECertificate= "";
1393 $this->old_userCertificate= "";
1394 }
1397 function plInfo()
1398 {
1400 $govattrs= array(
1401 "gouvernmentOrganizationalUnit" => _("Unit"),
1402 "houseIdentifier" => _("House identifier"),
1403 "vocation" => _("Vocation"),
1404 "ivbbLastDeliveryCollective" => _("Last delivery"),
1405 "gouvernmentOrganizationalPersonLocality" => _("Person locality"),
1406 "gouvernmentOrganizationalUnitDescription" => _("Unit description"),
1407 "gouvernmentOrganizationalUnitSubjectArea" => _("Subject area"),
1408 "functionalTitle" => _("Functional title"),
1409 "certificateSerialNumber" => _("Certificate serial number"),
1410 "publicVisible" => _("Public visible"),
1411 "street" => _("Street"),
1412 "role" => _("Role"),
1413 "postalCode" => _("Postal code"));
1415 $ret = array(
1416 "plShortName" => _("Generic"),
1417 "plDescription" => _("Generic user settings"),
1418 "plSelfModify" => TRUE,
1419 "plDepends" => array(),
1420 "plPriority" => 1,
1421 "plSection" => array("personal" => _("My account")),
1422 "plCategory" => array("users" => array("description" => _("Users"),
1423 "objectClass" => "gosaAccount")),
1425 "plProvidedAcls" => array(
1426 "base" => _("Base"),
1427 "userPassword" => _("User password"),
1428 "sn" => _("Surename"),
1429 "givenName" => _("Given name"),
1430 "uid" => _("User identification"),
1431 "personalTitle" => _("Personal title"),
1432 "academicTitle" => _("Academic title"),
1433 "homePostalAddress" => _("Home postal address"),
1434 "homePhone" => _("Home phone number"),
1435 "labeledURI" => _("Homepage"),
1436 "o" => _("Organization"),
1437 "ou" => _("Department"),
1438 "dateOfBirth" => _("Date of birth"),
1439 "gender" => _("Gender"),
1440 "preferredLanguage" => _("Preferred language"),
1441 "departmentNumber" => _("Department number"),
1442 "employeeNumber" => _("Employee number"),
1443 "employeeType" => _("Employee type"),
1444 "l" => _("Location"),
1445 "st" => _("State"),
1446 "userPicture" => _("User picture"),
1447 "roomNumber" => _("Room number"),
1448 "telephoneNumber" => _("Telefon number"),
1449 "mobile" => _("Mobile number"),
1450 "pager" => _("Pager number"),
1451 "Certificate" => _("User certificates"),
1453 "postalAddress" => _("Postal address"),
1454 "facsimileTelephoneNumber" => _("Fax number"))
1455 );
1457 /* Append government attributes if required */
1458 global $config;
1459 if (isset($config->current['GOVERNMENTMODE']) && preg_match('/true/i', $config->current['GOVERNMENTMODE'])){
1460 foreach($govattrs as $attr => $desc){
1461 $ret["plProvidedAcls"][$attr] = $desc;
1462 }
1463 }
1465 return($ret);
1466 }
1467 }
1469 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1470 ?>