I have what looks like a rather strange array, to me anyway, this is the result of a print_r ($info) and of var_export; :
print_r ($info);
output
Array ( [count] => 1 [0] =>
Array ( [sessiontimeout] => Array ( [count] => 1 [0] => 0 ) [0] => sessiontimeout [description] => Array ( [count] => 1 [0] => Admin group ) [1] => description [cn] => Array ( [count] => 1 [0] => ldap-admin ) [2] => cn [objectclass] => Array ( [count] => 2 [0] => top [1] => GroupV2 ) [3] => objectclass [enabled] => Array ( [count] => 1 [0] => TRUE ) [4] => enabled [uniquemember] => Array ( [count] => 2 [0] => uid=username1,cn=users,dc=abc,dc=net [1] => uid=username2,cn=users,dc=abc,dc=net )
[5] => uniquemember [count] => 6 [dn] => cn=ldap-admin,cn=staff,cn=company,cn=groups,dc=abc,dc=net ) )
var_export($info);
array ( 'count' => 1, 0 => array ( 'sessiontimeout' => array ( 'count' => 1, 0 => '0', ), 0 => 'sessiontimeout', 'description' => array ( 'count' => 1, 0 => 'Admin group', ), 1 => 'description', 'cn' => array ( 'count' => 1, 0 => 'ldap-admin', ), 2 => 'cn', 'objectclass' => array ( 'count' => 2, 0 => 'top', 1 => 'oGroupV2', ), 3 => 'objectclass', 'enabled' => array ( 'count' => 1, 0 => 'TRUE', ), 4 => 'enabled', 'uniquemember' => array ( 'count' => 2, 0 => 'uid=username1,cn=users,dc=jhc,dc=net', 1 => 'uid=username2,cn=users,dc=abc,dc=net', ), 5 => 'uniquemember', 'count' => 6, 'dn' => 'cn=ldap-admin,cn=staff,cn=company,cn=groups,dc=abc,dc=net', ), )
im only interested in the uniquemember uid= parts. I have been trying to set a variable that is uid=usernameX and then check if the variable contains the username i have been given previously in my code. It looks like this:
for ($i=0; $i<=$info["count"]; $i++) {
$uid = $info[$i]["uniquemember"][$i];
if (strpos($info, "uid=$username")) {
echo "$username valid";
} else {
echo $username not valid";
}
}
As far as i can tell my variable uid is not being reset to the second instance of uid=, in this case it should be "uid=username2"
If the username provided is username1 i get the output
username1 valid
If the username is username2 i get
username2 not valid
When i would expect it to be valid.