Code

Changed attribute name 'gosaLastSystemLogin' to 'gotoLastSystemLogin'.
[gosa.git] / include / class_userinfo.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2003-2005  Cajus Pollmeier
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
21 class userinfo
22 {
23   var $dn;
24   var $ip;
25   var $username;
26   var $cn;
27   var $gidNumber= -1;
28   var $language= "";
29   var $config;
30   var $gosaUnitTag= "";
31   var $subtreeACL= array();
33   /* get acl's an put them into the userinfo object
34      attr subtreeACL (userdn:components, userdn:component1#sub1#sub2,component2,...) */
35   function userinfo($config, $userdn){
36     $this->config= $config;
37     $ldap= $this->config->get_ldap_link();
38     $ldap->cat($userdn,array('sn', 'givenName', 'uid', 'gidNumber', 'preferredLanguage', 'gosaUnitTag'));
39     $attrs= $ldap->fetch();
41     if (isset($attrs['givenName'][0]) && isset($attrs['sn'][0])){
42       $this->cn= $attrs['givenName'][0]." ".$attrs['sn'][0];
43     } else {
44       $this->cn= $attrs['uid'][0];
45     }
46     if (isset($attrs['gidNumber'][0])){
47       $this->gidNumber= $attrs['gidNumber'][0];
48     }
50     /* Assign user language */
51     if (isset($attrs['preferredLanguage'][0])){
52       $this->language= $attrs['preferredLanguage'][0];
53     }
55     if (isset($attrs['gosaUnitTag'][0])){
56       $this->gosaUnitTag= $attrs['gosaUnitTag'][0];
57     }
59     $this->dn= $userdn;
60     $this->ip= $_SERVER['REMOTE_ADDR'];
61   }
64   function loadACL()
65   {
66     $ldap= $this->config->get_ldap_link();
68     /* Check if we should include the unittag */
69     $tag= "";
70     if ($this->gosaUnitTag != "" && isset($this->config->current['STRICT_UNITS']) &&
71         preg_match('/TRUE/i', $this->config->current['STRICT_UNITS'])){
72       $tag= "(gosaUnitTag=".$this->gosaUnitTag.")";
73     }
75     /* Load ACL's from all groups we're in */
76     $this->subtreeACL= array();
77     $ldap->cd($this->config->current['BASE']);
78     if ($this->gidNumber == -1){
79       $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaObject)".$tag.
80           "(memberUid=$this->username))");
81     } else {
82       $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaObject)".$tag.
83           "(|(memberUid=$this->username)(gidNumber=$this->gidNumber)))");
84     }
86     while($attrs = $ldap->fetch()){
87       $base= preg_replace('/^[^,]*+,'.normalizePreg(get_groups_ou()).'/i', "",$ldap->getDN());
88       $base= preg_replace("/\s*,\s*/", ",", $base);
90       for ($i= 0; $i<$attrs["gosaSubtreeACL"]["count"]; $i++){
91         $this->subtreeACL[$base][]= $attrs["gosaSubtreeACL"][$i];
92       }
93     }
94   }
96 }
98 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
99 ?>