2
votes

The thing is very simple:

$results = ldap_search( $ldapconn, 'DC=testdomain,DC=com', '(&(objectClass=user)(objectClass=computer))' );

This works, getting 3 results.

However, negating the second expression as defined in many manuals and tutorials, returns in Bad Search Filter:

$results = ldap_search( $ldapconn, 'DC=testdomain,DC=com', '(&(objectClass=user)(!objectClass=computer))' );

Any help?

[Wed Apr 10 16:59:05 2013] [error] [client 127.0.0.1] PHP Warning: ldap_search(): Search: Bad search filter in /var/www/test2.php on line 29

1
Hmmmmmm I figured out I need to add extra parenthesis, though I don't know why and where it is explained :S since in Microsoft's documentation doesn't say soJorgeeFG
@mkaatman thanks but that isn't my problem. I figured out what it was but I can't find documentation on why it is that way.JorgeeFG

1 Answers

3
votes

I think it's because I trusted Microsoft Active Directory's Documentation on LDAP:

http://technet.microsoft.com/en-us/library/aa996205%28v=exchg.65%29.aspx

Other sites mentions the (!(expression)) like http://www.google.com/support/enterprise/static/postini/docs/admin/en/dss_admin/prep_ldap.html