DirectoryTree / LdapRecord

A fully-featured LDAP framework.
https://ldaprecord.com
MIT License
507 stars 45 forks source link

[Bug] Invalid query filter [memberof=cn=foo,ou=Groups,dc=example,dc=org] #652

Closed ishanvyas22 closed 11 months ago

ishanvyas22 commented 11 months ago

Environment:

Describe the bug:

memberOf filter doesn't work when using Parser::parse():

// Throws "Invalid query filter [memberof=cn=foo,ou=Groups,dc=example,dc=org]" error
$filter = Parser::parse('(&(objectClass=inetOrgPerson)(memberof=cn=foo,ou=Groups,dc=example,dc=org))');

$query->rawFilter(Parser::assemble($filter));

However when using that same filter using ldapsearch command, it works fine:

root@ldap-server:/# ldapsearch -x -D cn=admin,dc=example,dc=org -w <password> -b "dc=example,dc=org" "(&(objectClass=inetOrgPerson)(memberof=cn=foo,ou=Groups,dc=example,dc=org))"
# extended LDIF
#
# LDAPv3
# base <dc=example,dc=org> with scope subtree
# filter: (&(objectClass=inetOrgPerson)(memberof=cn=foo,ou=Groups,dc=example,dc=org))
# requesting: ALL
#

# jdoe1, Users, example.org
dn: uid=jdoe1,ou=Users,dc=example,dc=org
cn: John Doe
description: <description>
givenName: John
mail: adoe@test.local
objectClass: inetOrgPerson
objectClass: top
sn: doe
uid: jdoe1

# sdoe1, Users, example.org
dn: uid=sdoe1,ou=Users,dc=example,dc=org
cn: Steve doe
description: <description>
givenName: Steve
mail: sdoe@test.local
objectClass: inetOrgPerson
objectClass: top
sn: doe
uid: sdoe1

# search result
search: 2
result: 0 Success

# numResponses: 3
# numEntries: 2
stevebauman commented 11 months ago

Hi @ishanvyas22!

Thanks for the report! Yea this is a bug -- the parser should be able to extract the value here.

I'll work on a patch for this, but in the meantime, a PR is always welcome 👍

ishanvyas22 commented 11 months ago

I just tested the filter with latest released version and it works like a charm. Thanks for the quick support 🙏🏼

stevebauman commented 11 months ago

Happy to help @ishanvyas22! And thanks again for your work on the PR 🙏