Changeset 33 for trunk/instant_messenger/inc/class.ldap_im.inc.php
- Timestamp:
- 06/21/07 08:32:34 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/instant_messenger/inc/class.ldap_im.inc.php
r32 r33 14 14 $this->user = $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']; 15 15 $this->password = $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber']; 16 $this->connect_ldap( true);16 $this->connect_ldap(false); 17 17 } 18 18 … … 35 35 function get_photo_ldap($user,$getPhoto) 36 36 { 37 $result = "";38 37 if ($this->conn) { 39 $filter=" uid=".$user;38 $filter="(&(uid=".$user.")(phpgwAccountType=u))"; 40 39 $justthese = array("jpegphoto"); 41 40 $search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese); 42 41 $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 45 46 $photo = imagecreatefromstring($jpeg_data[0]); 46 47 if($photo){ … … 72 73 } 73 74 74 function list_users_ldap($ filter)75 function list_users_ldap($search) 75 76 { 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); 81 82 $entry = ldap_get_entries($this->conn,$search); 82 83 } 83 84 84 85 if( $entry['count'] > 0){ 85 86 $i = 0; 87 $result_user = array(); 86 88 foreach($entry as $tmp) 87 89 { 88 if($tmp['uidnumber'][0] != "" ){90 if($tmp['uidnumber'][0] != "" && $tmp['phpgwaccountvisible'][0] != "-1"){ 89 91 $result_user[$i]['uidnumber'] = $tmp['uidnumber'][0]; 90 92 $result_user[$i]['mail'] = $tmp['mail'][0]; 91 93 $result_user[$i]['uid'] = $tmp['uid'][0]; 92 94 $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)); 96 99 $i++; 97 100 } … … 102 105 } 103 106 104 function list_groups_ldap($ filter)107 function list_groups_ldap($search) 105 108 { 106 109 107 110 if( $this->conn ){ 108 $filter = "(&( |".$filter.")(phpgwAccountType=g))";111 $filter = "(&(".$search.")(phpgwAccountType=g))"; 109 112 $justthese = array("gidnumber","cn","memberuid"); 110 113 $search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese); … … 112 115 } 113 116 114 if( $entry['count'] > 0){117 if($entry['count'] > 0){ 115 118 $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; 125 126 $i++; 126 127 } 127 } 128 } 128 129 return $result_groups; 129 130 } 130 131 return 0; 131 132 132 } 133 133 … … 149 149 } 150 150 } 151 152 151 sort($result_org); 153 154 152 return $result_org; 155 153 } … … 157 155 function info_user($user) 158 156 { 159 $uid = $user['uid']; 160 $filter = "(uid=".$uid.")"; 157 $uid = "uid=".$user['uid']; 161 158 $i= 0; 162 159 163 $entry = $this->list_users_ldap($ filter);160 $entry = $this->list_users_ldap($uid); 164 161 165 if( count($entry) > 0 ) {162 if( count($entry) > 0 ) 166 163 return $entry; 167 }else{164 else 168 165 return false; 169 }170 166 } 171 167 }
Note: See TracChangeset
for help on using the changeset viewer.