- Timestamp:
- 09/20/10 18:23:03 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/jabberit_messenger/inc/class.ldap_im.inc.php
r3102 r3266 42 42 43 43 // Result Ldap 44 $this->max_result = 20;44 $this->max_result = 15; 45 45 46 46 if ( file_exists('inc/attributeLdap.php') ) … … 49 49 $this->attribute = trim($attributeTypeName); 50 50 } 51 else 52 $this->attribute = "uid"; 51 53 } 52 54 … … 71 73 private final function ldapRoot() 72 74 { 75 $this->ldap_host = $_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit']; 76 $this->ldap_context = $_SESSION['phpgw_info']['jabberit_messenger']['context_ldap_jabberit']; 77 $this->ldap_user = $_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit']; 78 $this->ldap_pass = $_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit']; 79 73 80 $this->ldapConn(); 74 81 } … … 100 107 101 108 return $conn; 109 } 110 111 private function getLdapHost() 112 { 113 return $_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit']; 102 114 } 103 115 … … 167 179 168 180 return $result_groups; 181 } 182 183 public final function getMaxResults() 184 { 185 return $this->max_result; 186 } 187 188 public final function getMembers( $pMembers, $pServers ) 189 { 190 $members = $pMembers; 191 192 foreach( $pServers as $servers => $groups ) 193 { 194 if( $servers == $this->getLdapHost() || $servers == 'localhost') 195 { 196 $this->ldapRoot(); 197 198 $count = count($members[$servers]); 199 200 for( $i = 0; $i < $count; $i++ ) 201 { 202 if ( ! $this->getMemberUid($groups, $members[$servers][$i]['uid'] ) ) 203 unset( $members[$servers][$i] ); 204 } 205 206 if( $this->ldap ) 207 @ldap_close($this->ldap); 208 } 209 else 210 { 211 $confHosts = $this->hostsJabber; 212 213 for($i = 0; $i < count($confHosts); $i++ ) 214 { 215 if( $this->ldap ) 216 @ldap_close($this->ldap); 217 218 if( trim($servers) === trim($confHosts[$i]['serverLdap']) ) 219 { 220 $this->ldap_host = $confHosts[$i]['serverLdap']; 221 $this->ldap_context = $confHosts[$i]['contextLdap']; 222 $this->ldap_user = $confHosts[$i]['user']; 223 $this->ldap_org = $confHosts[$i]['org']; 224 $this->ldap_pass = $confHosts[$i]['password']; 225 $this->ldap = $this->ldapCatalog(); 226 227 $count = count($members[$servers]); 228 229 for( $i = 0; $i < $count; $i++ ) 230 { 231 if ( ! $this->getMemberUid($groups, $members[$servers][$i]['uid'] ) ) 232 unset( $members[$servers][$i] ); 233 } 234 235 if( $this->ldap ) 236 @ldap_close($this->ldap); 237 } 238 } 239 } 240 } 241 242 return $members; 243 } 244 245 private function getMemberUid( $pGidNumber, $pMemberUid ) 246 { 247 $filter = "(&(phpgwAccountType=g)(|{$pGidNumber})(memberuid={$pMemberUid}))"; 248 $justthese = array("memberuid"); 249 250 if( $this->ldap ) 251 { 252 $search = ldap_search($this->ldap, $this->ldap_context, $filter, $justthese ); 253 $result = ldap_get_entries($this->ldap,$search); 254 if( $result["count"] ) 255 return true; 256 } 257 258 return false; 169 259 } 170 260 … … 301 391 } 302 392 303 public final function getUsersLdapCatalog( $search, $ uid = false, $pLdap= false )393 public final function getUsersLdapCatalog( $search, $pLdap = false, $uid = false ) 304 394 { 305 395 $confHosts = $this->hostsJabber; … … 331 421 $return = array_merge($return, $result); 332 422 else 333 $return = $result; 423 $return = $result; 334 424 } 335 425 … … 342 432 } 343 433 344 public final function getUsersLdapRoot( $search, $uidnumber , $ous = false )434 public final function getUsersLdapRoot( $search, $uidnumber = false, $ous = false ) 345 435 { 346 436 $result = array(); … … 350 440 { 351 441 $searchRoot = ( $ous ) ? $ous.",".$this->ldap_context : $this->ldap_context ; 352 $filter = "(&(phpgwaccounttype=u)(|".$uidnumber.")(".$search ."))";442 $filter = ($uidnumber) ? "(&(phpgwaccounttype=u)(|".$uidnumber.")(".$search ."))" : "(&(phpgwaccounttype=u)(".$search ."))"; 353 443 $justthese = array( $this->attribute, "uidNumber", "cn", "mail", "phpgwAccountVisible", "dn", "jpegPhoto" ); 354 $search = ldap_search( $this->ldap, $searchRoot, $filter, $justthese, 0, $this->max_result + 1);355 $entry = ldap_get_entries( $this->ldap, $search );444 $search = @ldap_search( $this->ldap, $searchRoot, $filter, $justthese, 0, $this->max_result + 1); 445 $entry = @ldap_get_entries( $this->ldap, $search ); 356 446 $result = $this->resultArray( $entry, $this->ldap ); 357 447 }
Note: See TracChangeset
for help on using the changeset viewer.