Code

ba328fccfd1bc5d1dd564c013e3e7b76b5f2784c
[gosa.git] / plugins / admin / groups / class_groupGeneric.inc
1 <?php
2 class group extends plugin
3 {
4   /* CLI vars */
5   var $cli_summary= "Handling of GOsa's base group object";
6   var $cli_description= "Some longer text\nfor help";
7   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
9   /* Group attributes */
10   var $cn= "";
11   var $description= "";
12   var $gidNumber= "";
13   var $memberUid= array();
15   /* Helpers */
16   var $base= "";
17   var $force_gid= FALSE;
18   var $fon_group= FALSE;
19   var $smbgroup= FALSE;
20   var $groupType= FALSE;
21   var $samba3= FALSE;
22   var $sambaSID= "";
23   var $sambaDomainName= "DEFAULT";
24   var $SID= "";
25   var $ridBase= 0;
26   var $members= array();
27   var $users= array();
28   var $allusers= array();
29   var $department= "";
30   var $saved_gidNumber= "";
31   var $oldgroupType= "";
32   var $orig_dn= "";
33   var $has_mailAccount= FALSE;
34   var $group_dialog= FALSE;
35   var $nagios_group =FALSE;
36   var $sambaGroupType;
37   var $dialog;
39   /* attribute list for save action */
40   var $attributes= array("cn", "description", "gidNumber","memberUid","sambaGroupType","sambaSID");
41   var $objectclasses= array("top", "posixGroup");
43   function group ($config, $dn= NULL)
44   {
45     plugin::plugin ($config, $dn);
47     /* Load attributes depending on the samba version */
48     $this->samba3= ($config->current['SAMBAVERSION'] == 3);
49     $this->orig_dn= $dn;
51     /* Get member list */
52     if (isset($this->attrs['memberUid'][0])){
53       $tmp= array();
54       for ($i= 0; $i<$this->attrs['memberUid']['count']; $i++){
55         $tmp[]= $this->attrs['memberUid'][$i];
56       }
57       $this->memberUid= $tmp;
58       sort ($this->memberUid);
59     }
61     /* Save gidNumber for later use */
62     if (isset($this->attrs['gidNumber'])){
63       $this->saved_gidNumber= $this->attrs['gidNumber'][0];
64     }
66     /* Is a samba group? */
67     if (isset($this->attrs['objectClass'])){
68       if (array_search ('sambaGroupMapping', $this->attrs['objectClass']) == NULL ){
69         $this->smbgroup= FALSE;
70       } else {
71         $this->smbgroup= TRUE;
72         if (isset($this->attrs['sambaSID'])){
73           $this->sambaSID= $this->attrs['sambaSID'][0];
74         }
75       }
76       if (array_search ('goFonPickupGroup', $this->attrs['objectClass']) == NULL ){
77         $this->fon_group= FALSE;
78       } else {
79         $this->fon_group= TRUE;
80       }
81       if (array_search ('nagiosContactGroup', $this->attrs['objectClass']) == NULL ){
82         $this->nagios_group= FALSE;
83       } else {
84         $this->nagios_group= TRUE;
85       }
86     }
88     /* Set mail flag */
89     if (isset($this->attrs['objectClass']) && in_array('gosaMailAccount', $this->attrs['objectClass'])){
90       $this->has_mailAccount= TRUE;
91     }
93     /* Get samba Domain in case of samba 3 */
94     if ($this->samba3 && $this->sambaSID != ""){
95       $this->SID= preg_replace ("/-[^-]+$/", "", $this->sambaSID);
96       $ldap= $this->config->get_ldap_link();
97       $ldap->cd($this->config->current['BASE']);
98       $ldap->search ("(&(objectClass=sambaDomain)(sambaSID=$this->SID))",array("sambaAlgorithmicRidBase"));
99       if ($ldap->count() != 0){
100         $attrs= $ldap->fetch();
101         $this->ridBase= $attrs['sambaAlgorithmicRidBase'][0];
103         /* Get domain name for SID */
104         $this->sambaDomainName= "DEFAULT";
105         foreach ($this->config->data['SERVERS']['SAMBA'] as $key => $val){
106           if ($val['SID'] == $this->SID){
107             $this->sambaDomainName= $key;
108             break;
109           }
110         }
111       } else {
112         if (isset($this->config->current['RIDBASE'])){
113           $this->sambaDomainName= "DEFAULT";
114           $this->ridBase= $this->config->current['RIDBASE'];
115           $this->SID= $this->config->current['SID'];
116         } else {
117           print_red(_("Can't find this groups SID in LDAP or in your configuration file!"));
118         }
119       }
121       /* Get group type */
122       $this->groupType= (int)substr(strrchr($this->sambaSID, "-"), 1);
123       if ($this->groupType < 500 || $this->groupType > 553){
124         $this->groupType= 0;
125       }
126       $this->oldgroupType= $this->groupType;
127     }
129     /* Get global filter config */
130     if (!is_global("gufilter")){
131       $ui= get_userinfo();
132       $base= get_base_from_people($ui->dn);
133       $gufilter= array( "dselect"       => $base,
134           "regex"           => "*");
135       register_global("gufilter", $gufilter);
136     }
137     $gufilter= get_global('gufilter');
139       /* Bases / Departments */
140       
141     if(isset($_SESSION['groupfilter']['depselect'])){
142       $this->base = $_SESSION['groupfilter']['depselect'];
143     }else{
144       if ($this->dn == "new"){
145         $ui= get_userinfo();
146         $this->base= dn2base($ui->dn);
147       } else {
148         $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
149       }
150     }
153     /* This is always an account */
154     $this->is_account= TRUE;
155     $this->reload();
156   }
158   function execute()
159   {
160         /* Call parent execute */
161         plugin::execute();
163   $ui= get_userinfo();
164   $acla= get_permissions ($ui->dn, $ui->subtreeACL);
165   $this->acl= get_module_permission($acla, "group", $ui->dn);
166   /* Do we represent a valid group? */
167     if (!$this->is_account && $this->parent == NULL){
168       $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
169         _("This 'dn' is no group.")."</b>";
170       return ($display);
171     }
173     /* Delete user from group */
174     if (isset($_POST['del_users']) && isset($_POST['members'])){
175       foreach ($_POST['members'] as $value){
176         unset ($this->members["$value"]);
177         $this->removeUser($value);
178       }
179       $this->reload();
180     }
182     /* Add objects? */
183     if (isset($_POST["edit_membership"])){
184       $this->group_dialog= TRUE;
185       $this->dialog= TRUE;
186     }
188     /* Add objects finished? */
189     if (isset($_POST["add_users_finish"]) || isset($_POST["add_users_cancel"])){
190       $this->group_dialog= FALSE;
191       $this->dialog= FALSE;
192     }
194     /* Add user to group */
195     if (isset($_POST['add_users_finish']) && isset($_POST['users'])){
196       foreach ($_POST['users'] as $value){
197         $this->members["$value"]= $this->allusers[$value];
198         asort($this->members);
199         $this->addUser($value);
200       }
201       $this->reload();
202     }
204     /* Base select dialog */
205     $once = true;
206     foreach($_POST as $name => $value){
207       if(preg_match("/^chooseBase/",$name) && $once){
208         $once = false;
209         $this->dialog = new baseSelectDialog($this->config);
210         $this->dialog->setCurrentBase($this->base);
211       }
212     }
214     /* Dialog handling */
215     if(is_object($this->dialog)){
216       /* Must be called before save_object */
217       $this->dialog->save_object();
219       if($this->dialog->isClosed()){
220         $this->dialog = false;
221       }elseif($this->dialog->isSelected()){
222         $this->base = $this->dialog->isSelected();
223         $this->dialog= false;
224       }else{
225         return($this->dialog->execute());
226       }
227     }
229    /* Assign templating stuff */
230     $smarty= get_smarty();
231     if ($this->samba3){
232       $smarty->assign("samba3", "true");
233     } else {
234       $smarty->assign("samba3", "");
235     }
237     if(search_config($this->config->data['MENU'], "nagiosaccount", "CLASS")){
238       $smarty->assign("nagios",true);
239     }else{
240       $smarty->assign("nagios",false);
241     }
242     
243     if(search_config($this->config->data['MENU'], "phoneAccount", "CLASS")){
244       $smarty->assign("pickupGroup",true);
245     }else{
246       $smarty->assign("pickupGroup",false);
247     }
249     /* Manage object add dialog */
250     if ($this->group_dialog){
252       /* Save data */
253       $gufilter= get_global("gufilter");
254       foreach( array("dselect", "regex") as $type){
255         if (isset($_POST[$type])){
256           $gufilter[$type]= $_POST[$type];
257         }
258       }
259       if (isset($_GET['search'])){
260         $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
261         if ($s == "**"){
262           $s= "*";
263         }
264         $gufilter['regex']= $s;
265       }
266       $regex= preg_replace('/[*]/', ".*", $gufilter['regex']);
267       register_global("gufilter", $gufilter);
268       $this->reload();
270       /* Show dialog */
271       $smarty->assign("search_image", get_template_path('images/search.png'));
272       $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
273       $smarty->assign("tree_image", get_template_path('images/tree.png'));
274       $smarty->assign("deplist", $this->config->idepartments);
275       $smarty->assign("alphabet", generate_alphabet());
276       foreach( array("dselect", "regex") as $type){
277         $smarty->assign("$type", $gufilter[$type]);
278       }
279       $smarty->assign("hint", print_sizelimit_warning());
281       $users= array();
282       foreach ($this->allusers as $key => $value){
283         if (!array_key_exists($key, $this->members)){
284           if (preg_match("/^$regex/i", $key)){
285             $users[$key]= $value;
286           }
287         }
288       }
289       $smarty->assign("users", $users);
290       $smarty->assign("apply", apply_filter());
291       $display= $smarty->fetch (get_template_path('group_objects.tpl', TRUE, dirname(__FILE__)));
292       return ($display);
293     }
295     /* Bases / Departments */
296     if (isset($_POST['base'])){
297       $this->base= $_POST['base'];
298     }
300     $smarty->assign("bases", $this->config->idepartments);
301     $smarty->assign("base_select", $this->base);
302     $smarty->assign("department", $this->department);
304     if ($this->samba3){
305       $domains= array();
306       foreach($this->config->data['SERVERS']['SAMBA'] as $name => $content){
307         $domains[$name]= $name;
308       }
309       $smarty->assign("sambaDomains", $domains);
310       $smarty->assign("sambaDomainName", $this->sambaDomainName);
311       $groupTypes= array(0 => _("Samba group"), 512 => _("Domain admins"), 513 => _("Domain users"),
312           514 => _("Domain guests"));
314       /* Don't loose special groups! If not key'ed above, add it to
315          the combo box... */    
316       if ($this->groupType >= 500 && $this->groupType <= 553 && !isset($groupTypes[$this->groupType])){
317         $groupTypes[$this->groupType]= sprintf(_("Special group (%d)"), $this->groupType);
318       }
320       $smarty->assign("groupTypes", $groupTypes);
321       $smarty->assign("groupType", $this->groupType);
322     }
324     /* Members and users */
325     $smarty->assign("members", $this->members);
327     /* Checkboxes */
328     foreach (array("force_gid", "smbgroup") as $val){
329       if ($this->$val == "1"){
330         $smarty->assign("$val", "checked");
331       } else {
332         $smarty->assign("$val", "");
333       }
334     }
335     if ($this->force_gid != "1"){
336       $smarty->assign("forceMode", "disabled");
337     }else{
338       $smarty->assign("forceMode", "");
339     }
340     $smarty->assign("force_gidACL", chkacl($this->acl, "gidNumber"));
341     $smarty->assign("sambaDomainNameACL", chkacl($this->acl, "sambaDomainName"));
342     if ($this->fon_group){
343       $smarty->assign("fon_group", "checked");
344     } else {
345       $smarty->assign("fon_group", "");
346     }
347     $smarty->assign("fon_groupACL", chkacl($this->acl, "fon_group"));
349     if ($this->nagios_group){
350       $smarty->assign("nagios_group", "checked");
351     } else {
352       $smarty->assign("nagios_group", "");
353     }
354     $smarty->assign("nagios_groupACL", chkacl($this->acl, "nagios_group"));
356     /* Fields */
357     foreach (array("cn", "description", "gidNumber") as $val){
358       $smarty->assign("$val", $this->$val);
359       $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
360     }
362     /* Missing ACL's */
363     foreach (array("base", "smbgroup", "members") as $val){
364       $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
365     }
367     /* Show main page */
368     $smarty->assign("alphabet", generate_alphabet(10));
369     $smarty->assign("search_image", get_template_path('images/search.png'));
370     $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
371     $smarty->assign("tree_image", get_template_path('images/tree.png'));
372     $smarty->assign("deplist", $this->config->idepartments);
373     return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
374   }
376   function addUser($uid)
377   {
378     $this->memberUid[]= $uid;
379     $this->memberUid= array_unique($this->memberUid);
380   }
382   function removeUser($uid)
383   {
384     $temp= array();
385     foreach ($this->memberUid as $value){
386       if ($value != $uid){
387         $temp[]= $value;
388       }
389     }
390     $this->memberUid= $temp;
391   }
394   /* Reload data */
395   function reload()
396   {
397     /* Generate userlists */
398     $this->last_sorting= "invalid";
399     $this->users= array();
400     $ldap= $this->config->get_ldap_link();
401     $gufilter= get_global("gufilter");
403     $ldap->cd ($this->config->current['BASE']);
404     $ldap->cd (get_people_ou().$gufilter['dselect']);
405     $ldap->ls ("(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(!(uid=*$)))",get_people_ou().$gufilter['dselect'],array("uid", "sn", "givenName"));
406     $this->allusers= array();
407     while ($attrs= $ldap->fetch()){
408       if (isset($attrs["givenName"][0]) && isset($attrs["sn"][0])){
409         $this->allusers[$attrs["uid"][0]]= $attrs["sn"][0].", ".
410           $attrs["givenName"][0]." [".$attrs["uid"][0]."]";
411       } else {
412         $this->allusers[$attrs["uid"][0]]= $attrs['uid'][0];
413       }
414     }
415     natcasesort ($this->allusers);
416     reset ($this->allusers);
418     /* Fill memberlist */
419     $this->members= array();
420     foreach ($this->memberUid as $value){
421       if (isset($this->allusers[$value])){
422         $this->members[$value]= $this->allusers[$value];
423       } else {
424         $this->members[$value]= "[$value]";
425       }
426     }
427     asort($this->members);
428     reset($this->members);
429   }
433   function remove_from_parent()
434   {
435     plugin::remove_from_parent();
437     $ldap= $this->config->get_ldap_link();
438     $ldap->rmdir($this->dn);
439     show_ldap_error($ldap->get_error());
441     /* Delete references to object groups */
442     $ldap->cd ($this->config->current['BASE']);
443     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
444     while ($ldap->fetch()){
445       $og= new ogroup($this->config, $ldap->getDN());
446       unset($og->member[$this->dn]);
447       $og->save ();
448     }
450     /* Send signal to the world that we've done */
451     $this->handle_post_events("remove");
452   }
455   /* Save data to object */
456   function save_object()
457   {
458     /* Save additional values for possible next step */
459     if (isset($_POST['groupedit'])){
460       plugin::save_object();
462       $this->force_gid= 0;
463       $this->smbgroup= 0;
464       foreach (array("force_gid", "department", "base", "smbgroup") as $val) {
465         if (chkacl ($this->acl, "$val") == "" && isset($_POST["$val"])){
466           $this->$val= $_POST["$val"];
467         }
468       }
470       /* Save sambaDomain attribute */
471       if (chkacl ($this->acl, "sambaDomainName") == "" && $this->samba3 &&
472           isset ($_POST['sambaDomainName'])){
474         $this->sambaDomainName= $_POST['sambaDomainName'];
475         $this->groupType= $_POST['groupType'];
476       }
478       /* Save fon attribute */
479       if (chkacl ($this->acl, "fon_group") == ""){
480         if (isset ($_POST['fon_group'])){
481           $this->fon_group= TRUE;
482         } else {
483           $this->fon_group= FALSE;
484         }
485       }
486          if (chkacl ($this->acl, "nagios_group") == ""){
487         if (isset ($_POST['nagios_group'])){
488           $this->nagios_group= TRUE;
489         } else {
490           $this->nagios_group= FALSE;
491         }
492       }
493     }
494   }
497   /* Save to LDAP */
498   function save()
499   {
500     /* ID handling */
501     if ($this->force_gid == 0){
502       if ($this->saved_gidNumber != ""){
503         $this->gidNumber= $this->saved_gidNumber;
504       } else {
505         /* Calculate new, lock uids */
506         $wait= 10;
507         while (get_lock("uidnumber") != ""){
508           sleep (1);
510           /* timed out? */
511           if ($wait-- == 0){
512             break;
513           }
514         }
515         add_lock ("uidnumber", "gosa");
516         $this->gidNumber= $this->get_next_id("gidNumber");
517       }
518     }
520     plugin::save(); 
522     /* Remove objectClass for samba/phone support */
523     $tmp= array();
524     for ($i= 0; $i<count($this->attrs["objectClass"]); $i++){
525       if ($this->attrs['objectClass'][$i] != 'sambaGroupMapping' &&
526           $this->attrs['objectClass'][$i] != 'sambaIdmapEntry' &&
527           $this->attrs['objectClass'][$i] != 'goFonPickupGroup' &&
528          $this->attrs['objectClass'][$i] != 'nagiosContactGroup'){
529         $tmp[]= $this->attrs['objectClass'][$i];
530       }
531     }
532     $this->attrs['objectClass']= $tmp;
533     $ldap= $this->config->get_ldap_link();
535     /* Add samba group functionality */
536     if ($this->samba3 && $this->smbgroup){
537   
538       /* Fixed undefined index ... 
539        */ 
540       $this->SID = $this->ridBase = "";
541       if(isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'])){
542         $this->SID    = $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'];
543       }else{
544         print_red(sprintf(_("No configured SID found for '%s'."),$this->sambaDomainName));
545       }
546       if(isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE'])){
547         $this->ridBase= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE']; 
548       }else{
549         print_red(sprintf(_("No configured RIDBASE found for '%s'."),$this->sambaDomainName));
550       }
552       $this->attrs['objectClass'][]= 'sambaGroupMapping';
553       $this->attrs['sambaGroupType']= "2";
555       /* Check if we need to create a special entry */
556       if ($this->groupType == 0){
558         if ($this->sambaSID == "" || $this->oldgroupType != $this->groupType){
559           $gidNumber= $this->gidNumber;
560           while(TRUE){
561             $sid= $this->SID."-".($gidNumber*2 + $this->ridBase+1);
562             $ldap->cd($this->config->current['BASE']);
563             $ldap->search("(sambaSID=$sid)",array("sambaSID"));
564             if ($ldap->count() == 0){
565               break;
566             }
567             $gidNumber++;
568           }
569           $this->attrs['sambaSID']= $sid;
570           $this->sambaSID= $sid;
571         }
573       } else {
574         $this->attrs['sambaSID']=$this->SID."-".$this->groupType;
575       }
577       /* User wants me to fake the idMappings? This is useful for
578          making winbind resolve the group names in a reasonable amount
579          of time in combination with larger databases. */
580       if (isset($this->config->current['SAMBAIDMAPPING']) &&
581           preg_match('/true/i', $this->config->current['SAMBAIDMAPPING'])){
582         $this->attrs['objectClass'][]= "sambaIdmapEntry";
583       }
585     }
587     /* Add phone functionality */
588     if ($this->fon_group){
589       $this->attrs['objectClass'][]= "goFonPickupGroup";
590     }
592     /* Add nagios functionality */
593     if ($this->nagios_group){
594         $this->attrs['objectClass'][]= "nagiosContactGroup";
595     }
597     /* Take members array */
598     if (count ($this->memberUid)){
599       $this->attrs['memberUid']= array_unique($this->memberUid);
600     }
602     /* New accounts need proper 'dn', propagate it to remaining objects */
603     if ($this->dn == 'new'){
604       $this->dn= 'cn='.$this->cn.','.get_groups_ou().$this->base;
605     }
607     /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
608        new entries. So do a check first... */
609     $ldap->cat ($this->dn);
610     if ($ldap->fetch()){
611       /* Modify needs array() to remove values :-( */
612       if (!count ($this->memberUid)){
613         $this->attrs['memberUid']= array();
614       }
615       if ($this->samba3){
616         if (!$this->smbgroup){
617           $this->attrs['sambaGroupType']= array();
618           $this->attrs['sambaSID']= array();
619         }
620       }
621       $mode= "modify";
622     } else {
623       $mode= "add";
624       $ldap->cd($this->config->current['BASE']);
625       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
626     }
628     /* Write back to ldap */
629     $ldap->cd($this->dn);
630     $this->cleanup();
631     $ldap->$mode($this->attrs);
633     $ret= 0;
634     if (show_ldap_error($ldap->get_error())){
635       $ret= 1;
636     }
638     /* Remove uid lock */
639     del_lock ("uidnumber");
641     /* Post that we've done*/
642     $this->handle_post_events($mode);
644     return ($ret);
645   }
647   function check()
648   {
649     $message= array();
651     /* Permissions for that base? */
652     if ($this->base != ""){
653       $new_dn= 'cn='.$this->cn.','.get_groups_ou().$this->base;
654     } else {
655       $new_dn= $this->dn;
656     }
658     $ui= get_userinfo();
659     $acl= get_permissions ($ui->dn, $ui->subtreeACL);
660     $acl= get_module_permission($acl, "group", $ui->dn);
661     if (chkacl($this->acl, "create") != ""){
662       $message[]= _("You have no permissions to create a group on this 'Base'.");
663     }
665     /* must: cn */
666     if ($this->cn == "" && chkacl ($this->acl, "cn") == ""){
667       $message[]= "The required field 'Name' is not set.";
668     }
670     /* Check for valid input */
671     if (!is_uid($this->cn)){
672       $message[]= _("The field 'Name' contains invalid characters. Lowercase, numbers and dashes are allowed.");
673     }
675     /* Check for used 'cn' */
676     $ldap= $this->config->get_ldap_link();
677     $ldap->cd($this->config->current['BASE']);
678     $ldap->search("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))",array("cn"));
679     if ($ldap->count() != 0){
681       /* New entry? */
682       if ($this->dn == 'new'){
683         $message[]= _("Value specified as 'Name' is already used.");
684       }
685       
686       /* Moved? */
687       elseif ($new_dn != $this->orig_dn){
688         $ldap->fetch();
689         if ($ldap->getDN() != $this->orig_dn){
690           $message[]= _("Value specified as 'Name' is already used.");
691         }
692       }
693     }
695     /* Check ID */
696     if ($this->force_gid == "1"){
697       if (!is_id($this->gidNumber)){
698         $message[]= _("Value specified as 'GID' is not valid.");
699       } else {
700         if ($this->gidNumber < $this->config->current['MINID']){
701           $message[]= _("Value specified as 'GID' is too small.");
702         }
704       }
705     }
707     return ($message);
708   }
710   function get_next_id($attrib)
711   {
712     $ids= array();
713     $ldap= $this->config->get_ldap_link();
715     $ldap->cd ($this->config->current['BASE']);
716     if (preg_match('/gidNumber/i', $attrib)){
717       $oc= "posixGroup";
718     } else {
719       $oc= "posixAccount";
720     }
721     $ldap->search ("(&(objectClass=$oc)($attrib=*))", array("$attrib"));
723     /* Get list of ids */
724     while ($attrs= $ldap->fetch()){
725       $ids[]= (int)$attrs["$attrib"][0];
726     }
728     /* Find out next free id near to UID_BASE */
729     for ($id= $this->config->current['UIDBASE']; $id++; $id<65000){
730       if (!in_array($id, $ids)){
731         return ($id);
732       }
733     }
735     /* Should not happen */
736     if ($id == 65000){
737       print_red(_("Too many users, can't allocate a free ID!"));
738       exit;
739     }
740   }
744 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
745 ?>