I want to extract the CN value from DNs returned by $output[$i]
in the code below:
$result=ldap_search($conn, $ldap_dn, "cn=$myId",array("givenname","sn","memberof","primarygroupid")) or die("No search data found.");
$info = ldap_get_entries($conn, $result);
$output = $info[0]['memberof'];
array_shift($output);
$arrlen = count($output);
for ($i=0; $i<$arrlen; $i++)
{
print $output[$i] . "
";
}
Example output is
CN=FMDHS-PLM-WebTest-3,OU=Permission,OU=Groups,DC=uniwa,DC=uwa,DC=edu,DC=au
So in this example I want to just get FMDHS-PLM-WebTest-3
Any ideas how I can do this? Do I need to parse the string with PHP or is there something I can use in LDAP to acheive this?
EDIT
I ended up using ldap_explode_dn
$arrlen = count($output);
for ($i=0; $i<$arrlen; $i++)
{
$parsr=ldap_explode_dn($output[$i], 0);
print str_replace('CN=', '', $parsr[0]) . "
";
}