具有特定AD组的LDAP_Search过滤器出错

I'm using a very slightly modified code from samJL from here

function get_members($group,$user,$password) {
$ldap_host = "AD-IP-Address";
$ldap_dn = "DC=MyDomain,DC=edu";
$base_dn = "DC=MyDomain,DC=edu";
$ldap_usr_dom = "@MyDomain";
$ldap = ldap_connect($ldap_host);

ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION,3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS,0);

ldap_bind($ldap, $user . $ldap_usr_dom, $password);
$results = ldap_search($ldap,$ldap_dn, "cn=" . $group);
$member_list = ldap_get_entries($ldap, $results);
$dirty = 0;
$group_member_details = array();

foreach($member_list[0]['member'] as $member) {
    if($dirty == 0) {
        $dirty = 1;
    } else {
        $member_dn = explode_dn($member);
        $member_cn = str_replace("CN=","",$member_dn[0]);
        $filter = 'CN='.$member_cn.'';
        $member_search = ldap_search($ldap, $base_dn, "(CN=" . $member_cn . ")");   <----  Line 43 of myFile, where the error is indicated
        $member_details = ldap_get_entries($ldap, $member_search);
        $group_member_details[] = array($member_details[0]['samaccountname'][0],$member_details[0]['useraccountcontrol'][0]);
    }
}
unset($member_list);
ldap_close($ldap);
print_r($group_member_details);
return $group_member_details;

}

When called using:

get_members('Portal_Director',$username,$password);

the "print_r" at the end procudes the correct list of users, with no errors.

When called using:

get_members('Instructors',$username,$password);

The "print_r" at the end still produces the correct list, and the function is still usable, however I also get an error:

Warning: ldap_search(): Search: Bad search filter in myfile on line 43

The username and passoword have not changed, and Instructors is a valid user group. I've echoed out the filter as:

echo '(CN=' . $member_cn . ')'.'<br/>';

in both cases the filters are identical.

  1. Why am i getting this error?
  2. This is part of an Ajax response file. is it ok to ignore the error since it doesn't interfere with the end result?