Hi, my site uses LDAP to verify users when they login (this is not an LDAP question ) the code below works fine: $lrSearch = @ldap_search($lConnect, 'OU=Systems,DC=mydomainname,DC=com', LDAP_USERNAME_FIELD."=".$_SESSION['user'].LDAP_USERNAME_END); $nMatchingEntries = @ldap_count_entries($lConnect, $lrSearch); if($nMatchingEntries != 1) { $this->sLoginFailure = 'Ooops... Invalid username supplied'; return false; } PHP: however now i need to change the code above as i have more than one group of users. The code above 'OU=Systems,DC=mydomainname,DC=com' is fine if there is only 1 group but now i have 4 groups of users so it must now allow any of these groups below: - OU=Systems,DC=mydomainname,DC=com - CN=Users,DC=mydomainname,DC=com - OU=Business,DC=mydomainname,DC=com - OU=Marketing,DC=mydomainname,DC=com Can anyone help me create this as quickly, i'm sure there is afew ways to do this. Do i need to use an OR statement or what is required thanks in advance
$groups = array('OU=Systems,DC=mydomainname,DC=com', 'CN=Users,DC=mydomainname,DC=com', 'OU=Business,DC=mydomainname,DC=com', 'OU=Marketing,DC=mydomainname,DC=com' ); $count = count($groups); for ($i = 0; $i < $count; $i++) { $lrSearch = @ldap_search($lConnect, $groups[$i], LDAP_USERNAME_FIELD . "=" . $_SESSION['user'] . LDAP_USERNAME_END); $nMatchingEntries = @ldap_count_entries($lConnect, $lrSearch); if ($nMatchingEntries == 1) { break; } } if ($nMatchingEntries != 1) { $this->sLoginFailure = 'Ooops... Invalid username supplied'; return false; } PHP: Untested, but it should work