Ignore:
Timestamp:
06/21/07 08:32:34 (17 years ago)
Author:
niltonneto
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/instant_messenger/inc/class.ldap_im.inc.php

    r32 r33  
    1414                $this->user             = $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']; 
    1515                $this->password         = $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber']; 
    16                 $this->connect_ldap(true); 
     16                $this->connect_ldap(false); 
    1717        } 
    1818         
     
    3535        function get_photo_ldap($user,$getPhoto) 
    3636        { 
    37                 $result = ""; 
    3837                if ($this->conn) { 
    39                         $filter="uid=".$user;            
     38                        $filter="(&(uid=".$user.")(phpgwAccountType=u))";                
    4039                        $justthese = array("jpegphoto"); 
    4140                        $search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese); 
    4241                        $entry = ldap_first_entry($this->conn, $search); 
    43                         if($entry != 'undefined'){ 
    44                                 $jpeg_data = @ldap_get_values_len($this->conn, $entry, "jpegphoto"); 
     42                        $jpeg_data = @ldap_get_values_len($this->conn, $entry, "jpegphoto"); 
     43                         
     44                        if( count($jpeg_data) > 1){ 
     45 
    4546                                $photo = imagecreatefromstring($jpeg_data[0]); 
    4647                                if($photo){ 
     
    7273        } 
    7374         
    74         function list_users_ldap($filter) 
     75        function list_users_ldap($search) 
    7576        { 
    76  
    77                 if( $this->conn ){ 
    78                         $filter = "(&(|".$filter.")(phpgwAccountType=u))"; 
    79                         $justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn");                    
    80                         $search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese); 
     77                 
     78                if($this->conn){ 
     79                        $filter = "(&(".$search.")(phpgwAccountType=u))"; 
     80                        $justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn"); 
     81                        $search = ldap_search($this->conn,$this->ldap_context,$filter,$justthese); 
    8182                        $entry = ldap_get_entries($this->conn,$search); 
    8283                } 
    83  
     84                 
    8485                if( $entry['count'] > 0){ 
    8586                        $i = 0; 
     87                        $result_user = array(); 
    8688                        foreach($entry as $tmp) 
    8789                        { 
    88                                 if($tmp['uidnumber'][0] != ""){ 
     90                                if($tmp['uidnumber'][0] != "" && $tmp['phpgwaccountvisible'][0] != "-1"){ 
    8991                                        $result_user[$i]['uidnumber'] = $tmp['uidnumber'][0];                    
    9092                                        $result_user[$i]['mail'] = $tmp['mail'][0]; 
    9193                                        $result_user[$i]['uid'] = $tmp['uid'][0]; 
    9294                                        $result_user[$i]['cn'] = $tmp['cn'][0]; 
    93                                         $dn = explode(",dc=",$tmp['dn']); 
    94                                         $ou = explode(",",$dn[0]); 
    95                                         $result_user[$i]['ou'] = strtoupper(array_pop($ou)); 
     95                                        $ou = explode("dc=",$tmp['dn']); 
     96                                        $ou = explode("ou=",$ou[0]); 
     97                                        $ou = array_pop($ou); 
     98                                        $result_user[$i]['dn'] = strtoupper(substr($ou,0,strlen($ou)-1));                                        
    9699                                        $i++; 
    97100                                }                                
     
    102105        } 
    103106         
    104         function list_groups_ldap($filter) 
     107        function list_groups_ldap($search) 
    105108        { 
    106109 
    107110                if( $this->conn ){ 
    108                         $filter = "(&(|".$filter.")(phpgwAccountType=g))"; 
     111                        $filter = "(&(".$search.")(phpgwAccountType=g))"; 
    109112                        $justthese = array("gidnumber","cn","memberuid");                        
    110113                        $search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese); 
     
    112115                } 
    113116                 
    114                 if( $entry['count'] > 0 ){ 
     117                if($entry['count'] > 0){ 
    115118                        $i = 0; 
    116                         foreach($entry as $tmp) 
    117                         { 
    118                                 if($tmp['gidnumber'][0] != ""){ 
    119                                         $result_groups[$i]['gidnumber'] = $tmp['gidnumber'][0]; 
    120                                         $org = explode(",",$tmp['dn']); 
    121                                         $result_groups[$i]['ou'] = strtoupper($org[1]); 
    122                                         array_shift($tmp['memberuid']); 
    123                                         foreach($tmp['memberuid'] as $mb) 
    124                                                 $result_groups[$i]['members'][] = $mb; 
     119                        $result_groups = array(); 
     120                        foreach($entry as $tmpg){ 
     121                                if($tmpg['gidnumber'] != ""){ 
     122                                        $result_groups[$i]['gidnumber'] = $tmpg['gidnumber'][0]; 
     123                                        array_shift($tmpg['memberuid']); 
     124                                        foreach($tmpg['memberuid'] as $tmp) 
     125                                                $result_groups[$i]['members'][] = $tmp;                                  
    125126                                        $i++; 
    126127                                } 
    127                         } 
     128                        }        
    128129                        return $result_groups; 
    129130                } 
    130131                return 0; 
    131  
    132132        } 
    133133         
     
    149149                        } 
    150150                } 
    151                  
    152151                sort($result_org); 
    153  
    154152                return $result_org; 
    155153        } 
     
    157155        function info_user($user) 
    158156        { 
    159                 $uid = $user['uid']; 
    160                 $filter = "(uid=".$uid.")"; 
     157                $uid = "uid=".$user['uid']; 
    161158                $i= 0; 
    162159                 
    163                 $entry = $this->list_users_ldap($filter); 
     160                $entry = $this->list_users_ldap($uid); 
    164161                 
    165                 if( count($entry) > 0 ){ 
     162                if( count($entry) > 0 ) 
    166163                        return $entry; 
    167                 }else{ 
     164                else 
    168165                        return false;    
    169                 } 
    170166        } 
    171167} 
Note: See TracChangeset for help on using the changeset viewer.