Hi,
I'm not familiar with the type of code that you posted. But since it's returning groups to your application I assume that the code is ok. In Active Directory both user & group objects have an objectClass attribute. For groups the value = group, for users it is person.
What you could try is change:
to:
or:
(please try both)
It's just a wild guess but hope it helps.