Code

I really start hating those @ in front of function calls... makes debugging very...
[gosa.git] / gosa-core / include / class_userinfo.inc
1 <?php
2 /*
3  * This code is part of GOsa (http://www.gosa-project.org)
4  * Copyright (C) 2003-2008 GONICUS GmbH
5  *
6  * ID: $$Id$$
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
23 class userinfo
24 {
25   var $dn;
26   var $ip;
27   var $username;
28   var $cn;
29   var $uid;
30   var $restrictions= array();
31   var $gidNumber= -1;
32   var $language= "";
33   var $config;
34   var $gosaUnitTag= "";
35   var $subtreeACL= array();
36   var $ACL= array();
37   var $ocMapping= array();
38   var $groups= array();
39   var $result_cache =array();
40   var $ignoreACL = FALSE;
41   var $ACLperPath = array();
42   var $ACLperPath_usesFilter = array();
44   /* get acl's an put them into the userinfo object
45      attr subtreeACL (userdn:components, userdn:component1#sub1#sub2,component2,...) */
46   function userinfo(&$config, $userdn){
47     $this->config= &$config;
48     $ldap= $this->config->get_ldap_link();
49     $ldap->cat($userdn,array('sn', 'givenName', 'uid', 'gidNumber', 'preferredLanguage', 'gosaUnitTag', 'gosaLoginRestriction'));
50     $attrs= $ldap->fetch();
52     if (isset($attrs['givenName'][0]) && isset($attrs['sn'][0])){
53       $this->cn= $attrs['givenName'][0]." ".$attrs['sn'][0];
54     } else {
55       $this->cn= $attrs['uid'][0];
56     }
57     if (isset($attrs['gidNumber'][0])){
58       $this->gidNumber= $attrs['gidNumber'][0];
59     }
61     /* Restrictions? */
62     if (isset($attrs['gosaLoginRestriction'])){
63       $this->restrictions= $attrs['gosaLoginRestriction'];
64       unset($this->restrictions['count']);
65     }
67     /* Assign user language */
68     if (isset($attrs['preferredLanguage'][0])){
69       $this->language= $attrs['preferredLanguage'][0];
70     }
72     if (isset($attrs['gosaUnitTag'][0])){
73       $this->gosaUnitTag= $attrs['gosaUnitTag'][0];
74     }
76     $this->dn= $userdn;
77     $this->uid= $attrs['uid'][0];
78     $this->ip= $_SERVER['REMOTE_ADDR'];
80     $this->ignoreACL = ($this->config->get_cfg_value("ignoreAcl") == $this->dn);
82     /* Initialize ACL_CACHE */
83     $this->reset_acl_cache();
84   }
87   public function reset_acl_cache()
88   {
89     /* Initialize ACL_CACHE */
90     session::global_set('ACL_CACHE',array());
91   }
93   function loadACL()
94   {
95     $this->ACL= array();    
96     $this->groups= array();    
97     $this->result_cache =array();
98     $this->reset_acl_cache();
99     $ldap= $this->config->get_ldap_link();
100     $ldap->cd($this->config->current['BASE']);
102     /* Get member groups... */
103     $ldap->search("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array('dn'));
104     while ($attrs= $ldap->fetch()){
105       $this->groups[$attrs['dn']]= $attrs['dn'];
106     }
108     /* Crawl through ACLs and move relevant to the tree */
109     $ldap->search("(objectClass=gosaACL)", array('dn', 'gosaAclEntry'));
110     $aclp= array();
111     $aclc= array();
112     while ($attrs= $ldap->fetch()){
114       /* Insert links in ACL array */
115       $aclp[$attrs['dn']]= substr_count($attrs['dn'], ',');
116       $aclc[$attrs['dn']]= array();
117       $ol= array();
118       for($i= 0; $i<$attrs['gosaAclEntry']['count']; $i++){
119         $ol= array_merge($ol, @acl::explodeAcl($attrs['gosaAclEntry'][$i]));
120       }
121       $aclc[$attrs['dn']]= $ol;
122     }
124     /* Resolve roles here. 
125      */
126     foreach($aclc as $dn => $data){
127       foreach($data as $prio => $aclc_value)  {
128         if($aclc_value['type'] == "role"){
130           unset($aclc[$dn][$prio]);
132           $ldap->cat($aclc_value['acl'],array("gosaAclTemplate"));
133           $attrs = $ldap->fetch();
135           if(isset($attrs['gosaAclTemplate'])){
136             for($i= 0; $i<$attrs['gosaAclTemplate']['count']; $i++){
137               $tmp = @acl::explodeAcl($attrs['gosaAclTemplate'][$i]);  
139               foreach($tmp as $new_acl){
141                 /* Keep non role attributes here! */
142                 $new_acl['filter'] = $aclc_value['filter'];
143                 $new_acl['members'] = $aclc_value['members'];
144                 $aclc[$dn][] =$new_acl;
145               }
146             }      
147           }
148         }
149       }
150     }
152     /* ACL's read, sort for tree depth */
153     asort($aclp);
155     /* Sort in tree order */
156     foreach ($aclp as $dn => $acl){
157       /* Check if we need to keep this ACL */
158       foreach($aclc[$dn] as $idx => $type){
159         $interresting= FALSE;
160         
161         /* No members? This ACL rule is deactivated ... */
162         if (!count($type['members'])){
163           $interresting= FALSE; 
164         } else {
166           /* Inspect members... */
167           foreach ($type['members'] as $grp => $grpdsc){
169             /* Some group inside the members that is relevant for us? */
170             if (in_array_ics(@LDAP::convert(preg_replace('/^G:/', '', $grp)), $this->groups)){
171               $interresting= TRUE;
172             }
174             /* User inside the members? */
175             if (preg_replace('/^U:/', '', $grp) == $this->dn){
176               $interresting= TRUE;
177             }
179             /* Wildcard? */
180             if (preg_match('/^G:\*/',  $grp)){
181               $interresting= TRUE;
182             }
183           }
184         }
186         if ($interresting){
187           if (!isset($this->ACL[$dn])){
188             $this->ACL[$dn]= array();
189           }
190           $this->ACL[$dn][$idx]= $type;
191         }
192       }
193     }
195     /* Create an array which represenet all relevant permissions settings 
196         per dn.
198       The array will look like this:
199       
200       .     ['ou=base']        ['ou=base']          = array(ACLs);
201       .     
202       .     ['ou=dep1,ou=base']['ou=dep1,ou=base']  = array(ACLs);
203       .                        ['ou=base']          = array(ACLs);
206       For object located in 'ou=dep1,ou=base' we have to both ACLs,
207        for objects in 'ou=base' we only have to apply on ACL.
208      */
209     $without_self_acl = $all_acl = array();
210     foreach($this->ACL as $dn => $acl){
211       $sdn =$dn;
212       $first= TRUE; // Run at least once 
213       while(strpos($dn,",") !== FALSE || $first){
214         $first = FALSE;
215         if(isset($this->ACL[$dn])){
216           $all_acl[$sdn][$dn] = $this->ACL[$dn];
217           $without_self_acl[$sdn][$dn] = $this->ACL[$dn]; 
218           foreach($without_self_acl[$sdn][$dn] as $acl_id => $acl_set){
219   
220             /* Remember which ACL set has speicial user filter 
221              */
222             if(isset($acl_set['filter']{1})){
223               $this->ACLperPath_usesFilter[$sdn] = TRUE;
224             }
225           
226             /* Remove all acl entries which are especially for the current user (self acl)
227              */
228             foreach($acl_set['acl'] as $object => $object_acls){
229               if(isset($object_acls[0]) && strpos($object_acls[0],"s")){
230                 unset($without_self_acl[$sdn][$dn][$acl_id]['acl'][$object]);
231               }
232             }
233           }
234         }
235         $dn = preg_replace("/^[^,]*+,/","",$dn);
236       }
237     } 
238     $this->ACLperPath =$without_self_acl;
240     /* Append Self entry */
241     $dn = $this->dn;
242     while(strpos($dn,",") && !isset($all_acl[$dn])){
243       $dn = preg_replace("/^[^,]*+,/","",$dn);
244     }
245     if(isset($all_acl[$dn])){
246       $this->ACLperPath[$this->dn] = $all_acl[$dn];
247     }
248   }
251   /* Returns an array containing all target objects we've permssions on.
252    */
253   function get_acl_target_objects()
254   {
255     return(array_keys($this->ACLperPath));
256   }
257   
259   function get_category_permissions($dn, $category, $any_acl = FALSE)
260   {
261     return($this->get_permissions($dn,$category.'/0',""));
262   }
264   
265   /*! \brief Check if the given object (dn) is copyable
266       @param  String The object dn 
267       @param  String The acl  category (e.g. users) 
268       @param  String The acl  class (e.g. user) 
269       @return Boolean   TRUE if the given object is copyable else FALSE 
270   */
271   function is_copyable($dn, $object, $class)
272   {
273     return(preg_match("/r/",$this->has_complete_category_acls($dn, $object)));
274   }
277   /*! \brief Check if the given object (dn) is cutable
278       @param  String The object dn 
279       @param  String The acl  category (e.g. users) 
280       @param  String The acl  class (e.g. user) 
281       @return Boolean   TRUE if the given object is cutable else FALSE 
282   */
283   function is_cutable($dn, $object, $class)
284   {
285     $remove = preg_match("/d/",$this->get_permissions($dn,$object."/".$class));
286     $read   = preg_match("/r/",$this->has_complete_category_acls($dn, $object));
287     return($remove && $read);
288   }
291   /*! \brief  Checks if we are allowed to paste an object to the given destination ($dn)
292       @param  String The destination dn 
293       @param  String The acl  category (e.g. users) 
294       @param  String The acl  class (e.g. user) 
295       @return Boolean   TRUE if we are allowed to paste an object.
296   */
297   function is_pasteable($dn, $object)
298   {
299     return(preg_match("/w/",$this->has_complete_category_acls($dn, $object)));
300   }
303   /*! \brief  Checks if we are allowed to restore a snapshot for the given dn.
304       @param  String The destination dn 
305       @param  String The acl  category (e.g. users) 
306       @return Boolean   TRUE if we are allowed to restore a snapshot.
307   */
308   function allow_snapshot_restore($dn, $object)
309   {
310     if(!is_array($object)){
311       $object = array($object);
312     }
313     $r = $w = TRUE;
314     foreach($object as $category){
315       $w &= preg_match("/w/",$this->has_complete_category_acls($dn, $category));
316       $r &= preg_match("/r/",$this->has_complete_category_acls($dn, $category));
317     }
318     return($r && $w ); 
319   }  
322   /*! \brief  Checks if we are allowed to create a snapshot of the given dn.
323       @param  String The source dn 
324       @param  String The acl category (e.g. users) 
325       @return Boolean   TRUE if we are allowed to restore a snapshot.
326   */
327   function allow_snapshot_create($dn, $object)
328   {
329     if(!is_array($object)){
330       $object = array($object);
331     }
332     $r = TRUE;
333     foreach($object as $category){
334       $r &= preg_match("/r/",$this->has_complete_category_acls($dn, $category));
335     }
336     return($r) ; 
337   }  
340   function get_permissions($dn, $object, $attribute= "", $skip_write= FALSE)
341   {
342     /* If we are forced to skip ACLs checks for the current user 
343         then return all permissions.
344      */
345     if($this->ignore_acl_for_current_user()){
346       if($skip_write){
347         return("rcdm");
348       }
349       return("rwcdm");
350     }
352     /* Push cache answer? */
353     $ACL_CACHE = &session::global_get('ACL_CACHE');
354     if (isset($ACL_CACHE["$dn+$object+$attribute"])){
355       $ret = $ACL_CACHE["$dn+$object+$attribute"];
356       if($skip_write){
357         $ret = str_replace(array('w','c','d','m'), '',$ret);
358       }
359       return($ret);
360     }
362     /* Check for correct category and class values... */
363     if(strpos($object,'/') !== FALSE){
364       list($aclCategory, $aclClass) = split("/", $object);
365     }else{
366       $aclCategory = $object;
367     }
368     if(!isset($this->ocMapping[$aclCategory])){
369       trigger_error("Invalid ACL category '".$aclCategory."'! ({$object})");
370       msg_dialog::display(_("Error"), "Invalid ACL category '".$aclCategory."'! ({$object})", ERROR_DIALOG);
371       return("");
372     }elseif(isset($aclClass) && !in_array($aclClass, $this->ocMapping[$aclCategory])){
373       trigger_error("Invalid ACL class '".$aclClass."'! ({$object})");
374       msg_dialog::display(_("Error"), "Invalid ACL class '".$aclClass."'! ({$object})", ERROR_DIALOG);
375       return("");
376     }
378     /* Detect the set of ACLs we have to check for this object 
379      */
380     $adn = $dn;
381     while(!isset($this->ACLperPath[$adn]) && strpos($adn,",") !== FALSE){
382       $adn = preg_replace("/^[^,]*+,/","",$adn);
383     }
384     if(isset($this->ACLperPath[$adn])){
385       $ACL = $this->ACLperPath[$adn];
386     }else{
387       $ACL_CACHE["$dn+$object+$attribute"] = "";
388       return("");
389     }
390  
391     /* If we do not need to respect any user-filter settings 
392         we can skip the per object ACL checks.
393      */
394     $orig_dn= $dn;
395     if(!isset($this->ACLperPath_usesFilter[$adn])){
396       $dn = $adn;
397       if (isset($ACL_CACHE["$dn+$object+$attribute"])){
398         $ret = $ACL_CACHE["$dn+$object+$attribute"];
399         if(!isset($ACL_CACHE["$orig_dn+$object+$attribute"])){
400           $ACL_CACHE["$orig_dn+$object+$attribute"] = $ACL_CACHE["$dn+$object+$attribute"];
401         }
402         if($skip_write){
403           $ret = str_replace('w','',$ret);
404         }
405         return($ret);
406       }
407     }
408  
409     /* Get ldap object, for later filter checks 
410      */
411     $ldap = $this->config->get_ldap_link();
413     $acl= array("r" => "", "w" => "", "c" => "", "d" => "", "m" => "", "a" => "");
415     /* Build dn array */
416     $path= explode(',', $dn);
417     $path= array_reverse($path);
419     /* Walk along the path to evaluate the acl */
420     $cpath= "";
421     foreach ($path as $element){
423       /* Clean potential ACLs for each level */
424                         if(isset($this->config->idepartments[$cpath])){
425         $acl= $this->cleanACL($acl);
426       }
428       if ($cpath == ""){
429         $cpath= $element;
430       } else {
431         $cpath= $element.','.$cpath;
432       }
434       if (isset($ACL[$cpath])){
436         /* Inspect this ACL, place the result into ACL */
437         foreach ($ACL[$cpath] as $subacl){
439           /* Reset? Just clean the ACL and turn over to the next one... */
440           if ($subacl['type'] == 'reset'){
441             $acl= $this->cleanACL($acl, TRUE);
442             continue;
443           }
445           if($subacl['type'] == "role") {
446             echo "role skipped";
447             continue;
448           }
450           /* With user filter */
451           if (isset($subacl['filter']) && !empty($subacl['filter'])){
452             $id = $dn."-".$subacl['filter'];
453             if(!isset($ACL_CACHE['FILTER'][$id])){
454               $ACL_CACHE['FILTER'][$id] = $ldap->object_match_filter($dn,$subacl['filter']);
455             }
456             if(!$ACL_CACHE['FILTER'][$id]){
457               continue;
458             }
459           }
461           /* Self ACLs? 
462            */
463           if($dn != $this->dn && isset($subacl['acl'][$object][0]) && (strpos($subacl['acl'][$object][0],"s") !== FALSE)){
464             continue;
465           }
467           /* If attribute is "", we want to know, if we've *any* permissions here... 
468               Merge global class ACLs [0] with attributes specific ACLs [attribute].
469            */
470           if ($attribute == "" && isset($subacl['acl'][$object])){
471             foreach($subacl['acl'][$object] as $attr => $dummy){
472               $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$object][$attr]);
473             }
474             continue;
475           }
477           /* Per attribute ACL? */
478           if (isset($subacl['acl'][$object][$attribute])){
479             $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$object][$attribute]);
480             continue;
481           }
483           /* Per object ACL? */
484           if (isset($subacl['acl'][$object][0])){
485             $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$object][0]);
486             continue;
487           }
489           /* Global ACL? */
490           if (isset($subacl['acl']['all'][0])){
491             $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl']['all'][0]);
492             continue;
493           }
495           /* Category ACLs    (e.g. $object = "user/0")
496            */
497           if(strstr($object,"/0")){
498             $ocs = preg_replace("/\/0$/","",$object);
499             if(isset($this->ocMapping[$ocs])){
501               /* if $attribute is "", then check every single attribute for this object.
502                  if it is 0, then just check the object category ACL.
503                */
504               if($attribute == ""){    
505                 foreach($this->ocMapping[$ocs] as $oc){
506                   if (isset($subacl['acl'][$ocs.'/'.$oc])){
508                     if($dn != $this->dn && strpos($subacl['acl'][$ocs.'/'.$oc][0],"s") !== FALSE) continue;
510                     foreach($subacl['acl'][$ocs.'/'.$oc] as $attr => $dummy){
511                       $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$ocs.'/'.$oc][$attr]);
512                     }
513                     continue;
514                   }
515                 }
516               }else{
517                 if(isset($subacl['acl'][$ocs.'/'.$oc][0])){
518                   if($dn != $this->dn && strpos($subacl['acl'][$ocs.'/'.$oc][0],"s") !== FALSE) continue;
519                   $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$ocs.'/'.$oc][0]);
520                 }
521               }
522             }
523             continue;
524           }
525         }
526       }
527     }
529     /* If the requested ACL is for a container object, then alter 
530         ACLs by applying cleanACL a last time.
531      */
532     if(isset($this->config->idepartments[$dn])){
533       $acl = $this->cleanACL($acl);
534     }
536     /* Assemble string */
537     $ret= "";
538     foreach ($acl as $key => $value){
539       if ($value !== ""){
540         $ret.= $key;
541       }
542     }
544     $ACL_CACHE["$dn+$object+$attribute"]= $ret;
545     $ACL_CACHE["$orig_dn+$object+$attribute"]= $ret;
547     /* Remove write if needed */
548     if ($skip_write){
549       $ret = str_replace(array('w','c','d','m'), '',$ret);
550     }
551     return ($ret);
552   }
555   /* Extract all departments that are accessible (direct or 'on the way' to an
556      accessible department) */
557   function get_module_departments($module, $skip_self_acls = FALSE )
558   {
559     /* If we are forced to skip ACLs checks for the current user 
560         then return all departments as valid.
561      */
562     if($this->ignore_acl_for_current_user()){
563       return(array_keys($this->config->idepartments));
564     }
566     /* Use cached results if possilbe */
567     $ACL_CACHE = &session::global_get('ACL_CACHE');
569     if(!is_array($module)){
570       $module = array($module);
571     }
573     global $plist;
574     $res = array();
575     foreach($module as $mod){
576       if(isset($ACL_CACHE['MODULE_DEPARTMENTS'][$mod])){
577         $res = array_merge($res,$ACL_CACHE['MODULE_DEPARTMENTS'][$mod]);
578         continue;
579       }
581       $deps = array();
583       /* Search for per object ACLs */
584       foreach($this->ACL as $dn => $infos){
585         foreach($infos as $info){
586           $found = FALSE;
587           foreach($info['acl'] as $cat => $data){
589             /* Skip self acls? */
590             if($skip_self_acls && isset($data['0']) && (strpos($data['0'], "s") !== FALSE)) continue;
591             if(preg_match("/^".preg_quote($mod, '/')."/",$cat)){
592               $found =TRUE;
593               break;
594             }
595           } 
597           if($found && !isset($this->config->idepartments[$dn])){
598             while(!isset($this->config->idepartments[$dn]) && strpos($dn, ",")){
599               $dn = preg_replace("/^[^,]+,/","",$dn);
600             }
601             if(isset($this->config->idepartments[$dn])){
602               $deps[$dn] = $dn;
603             }
604           }
605         }
606       }
608       /* For all gosaDepartments */
609       foreach ($this->config->departments as $dn){
610         if(isset($deps[$dn])) continue;
611         $acl = "";
612         if(strpos($mod, '/')){
613           $acl.=  $this->get_permissions($dn,$mod);
614         }else{
615           $acl.=  $this->get_category_permissions($dn,$mod,TRUE);
616         }
617         if(!empty($acl)) {
618           $deps[$dn] = $dn;
619         }
620       }
622       $ACL_CACHE['MODULE_DEPARTMENTS'][$mod] = $deps;
623       $res = array_merge($res,$deps);
624     }
626     return (array_values($res));
627   }
630   function mergeACL($acl, $type, $newACL)
631   {
632                 $at= array("psub" => "p", "sub" => "s", "one" => "1");
634     if (strpos($newACL, 'w') !== FALSE && strpos($newACL, 'r') === FALSE){
635       $newACL .= "r";
636     }
638                 /* Ignore invalid characters */
639                 $newACL= preg_replace('/[^rwcdm]/', '', $newACL);
641     foreach(str_split($newACL) as $char){
643       /* Skip "self" ACLs without combination of rwcdm, they have no effect.
644          -self flag without read/write/create/...
645        */
646       if(empty($char)) continue;
648       /* Skip permanent and subtree entries */
649       if (preg_match('/[sp]/', $acl[$char])){
650         continue;
651       }
653                         if ($type == "base" && $acl[$char] != 1) {
654                                 $acl[$char]= 0;
655                         } else {
656         $acl[$char]= $at[$type];
657                         }
658     }
660     return ($acl);
661   }
664   function cleanACL($acl, $reset= FALSE)
665   {
666     foreach ($acl as $key => $value){
668       /* Continue, if value is empty or permanent */
669       if ($value == "" || $value == "p") {
670             continue;
671       }
673       /* Reset removes everything but 'p' */
674       if ($reset && $value != 'p'){
675         $acl[$key]= "";
676         continue;
677       }
679       /* Decrease tree level */
680       if (is_int($value)){
681         if ($value){
682           $acl[$key]--;
683         } else {
684           $acl[$key]= "";
685         }
686       }
687     }
689     return ($acl);
690   }
693   /* #FIXME This could be logical wrong or could be optimized in the future
694      Return combined acls for a given category. 
695      All acls will be combined like boolean AND 
696       As example ('rwcdm' + 'rcd' + 'wrm'= 'r') 
697     
698      Results will be cached in $this->result_cache.
699       $this->result_cache will be resetted if load_acls is called.
700   */
701   function has_complete_category_acls($dn,$category)
702   {
703     $acl    = "rwcdm";
704     $types  = "rwcdm";
706     if(!is_string($category)){
707       trigger_error("category must be string");   
708       $acl = "";
709     }else{
710       if(!isset($this->result_cache['has_complete_category_acls'][$dn][$category]))   {
711         if (isset($this->ocMapping[$category])){
712           foreach($this->ocMapping[$category] as $oc){
714             /* Skip objectClass '0' (e.g. users/0) get_permissions will ever return '' ??  */
715             if($oc == "0") continue;
716             $tmp =  $this->get_permissions($dn, $category."/".$oc);
717             for($i = 0, $l= strlen($types); $i < $l; $i++) {
718               if(!preg_match("/".$types[$i]."/",$tmp)){ 
719                 $acl = preg_replace("/".$types[$i]."/","",$acl);
720               }
721             }
722           }
723         }else{
724           trigger_error("Invalid type of category ".$category);
725           $acl = "";
726         }
727         $this->result_cache['has_complete_category_acls'][$dn][$category] = $acl;
728       }else{
729         $acl = $this->result_cache['has_complete_category_acls'][$dn][$category];
730       }
731     }
732     return($acl);
733   }
735  
736   /*! \brief  Returns TRUE if the current user is configured in IGNORE_ACL=".." in your gosa.conf 
737       @param  Return Boolean TRUE if we have to skip ACL checks else FALSE.
738    */ 
739   function ignore_acl_for_current_user()
740   {
741     return($this->ignoreACL);
742   }
745   function loginAllowed()
746   {
747     // Need to check restrictions?
748     if (count($this->restrictions)){
750       // We have restrictions but cannot check them
751       if (!isset($_SERVER['REMOTE_ADDR'])){
752         return false;
753       }
755       // Move to binary...
756       $source= $_SERVER['REMOTE_ADDR'];
757       foreach ($this->restrictions as $restriction) {
759         // Single IP
760         if (preg_match('/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/', $restriction)) {
761            if ($source == $restriction){
762              return true;
763            }
764         }
766         // Match with short netmask
767         if (preg_match('/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\/([0-9]+)$/', $restriction, $matches)) {
768           if (isIpInNet($source, $matches[1], long2ip(~(pow(2, (32-$matches[2]))-1)))) {
769             return true;
770           }
771         }
773         // Match with long netmask
774         if (preg_match('/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)$/', $restriction, $matches)) {
775           if (isIpInNet($source, $matches[1], $matches[2])) {
776             return true;
777           }
778         }
780       }
782       return false;
783     }
785     return true;
786   }
791 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
792 ?>