LDAP array value not recognised by PHP [solved]
Posted: Wed Feb 08, 2006 5:30 am
Hi,
I am trying to run an in_array function on values returned from an LDAP query against active directory. For some reason, the in_array function doesn't seem to recognise the value returned by the LDAP array, although it recognises the same value if I assign it manually as a string.
Here in the code:
//START OF CODE
//END OF CODE
Does anybody have any ideas as to why this is?
Thanks
Solution:
The code was working fine. Turns out the make_array function was generating array elements with '<br>' tags in them... Duh...
I am trying to run an in_array function on values returned from an LDAP query against active directory. For some reason, the in_array function doesn't seem to recognise the value returned by the LDAP array, although it recognises the same value if I assign it manually as a string.
Here in the code:
//START OF CODE
Code: Select all
$exception_array = array("adaosborne", "adcwoods", "ctaylor");
$ldap_array = $obj->make_array();
$no_profile_count = 0;
$no_profile_array = array();
foreach($ldap_array as $current_element)
{
if(array_key_exists('profilepath', $current_element))
{
}
else
{
$check_element = $current_element['samaccountname'];
if(in_array($check_element, $exception_array))
{
}
else
{
$no_profile_array[] = strtolower($current_element['samaccountname']);
$no_profile_count++;
}
}
?><?
}
$count_no_profile = count($no_profile_array);
$message = "<HTML><BODY><p style=\"font-size: 12pt;\">\r\n";
$message .= "There are ". $count_no_profile ." users that do not have an associated profile path:<br><br>";
asort($no_profile_array);
foreach($no_profile_array as $current_no_profile)
{
// the !in_array check works if the value is manually assigned as so:
// $current_no_profile = "adaosborne";
//but not if the check is run against the current array element
if(!in_array(strtolower($current_no_profile), $exception_array))
{
$message .= $current_no_profile . "<br>";
}
}//END OF CODE
Does anybody have any ideas as to why this is?
Thanks
Solution:
The code was working fine. Turns out the make_array function was generating array elements with '<br>' tags in them... Duh...