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 $config;
28 var $subtreeACL= array();
30 /* get acl's an put them into the userinfo object
31 attr subtreeACL (userdn:components, userdn:component1#sub1#sub2,component2,...) */
32 function userinfo($config, $userdn){
33 $this->config= $config;
34 $ldap= $this->config->get_ldap_link();
35 $ldap->cat($userdn);
36 $attrs= $ldap->fetch();
38 if (isset($attrs['givenName'][0]) && isset($attrs['sn'][0])){
39 $this->cn= $attrs['givenName'][0]." ".$attrs['sn'][0];
40 } else {
41 $this->cn= $attrs['uid'][0];
42 }
44 $this->dn= $userdn;
45 $this->ip= $_SERVER['REMOTE_ADDR'];
46 }
49 function loadACL()
50 {
51 $ldap= $this->config->get_ldap_link();
53 /* Load ACL's from all groups we're in */
54 $this->subtreeACL= array();
55 $ldap->cd($this->config->current['BASE']);
56 $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaObject)".
57 "(|(memberUid=$this->username)(cn=$this->username)))");
59 while($attrs = $ldap->fetch()){
60 $base= preg_replace('/^[^,]+,ou=[^,]+,/i', "",$ldap->getDN());
61 $base= preg_replace("/[ ]*,[ ]*/", ",", $base);
63 for ($i= 0; $i<$attrs["gosaSubtreeACL"]["count"]; $i++){
64 $this->subtreeACL[$base][]= $attrs["gosaSubtreeACL"][$i];
65 }
66 }
67 }
69 }
71 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
72 ?>