Link to home
Start Free TrialLog in
Avatar of elucero
elucero

asked on

ADO.NET Query issues with 'Union' and 'In'

I'm using an ado.net source to get ad groups. I'm having issues with the queries below.  I cannot use an 'in' or a 'union' to get multiple groups.  Any suggestions?


SELECT displayName, Mail, telephoneNumber, name, sAMAccountName, givenName, sn, distinguishedName
  FROM 'LDAP://xxxx'
WHERE objectClass='user'  AND memberOf in('CN=AGrp-aaaa','CN=AGrp-bbb')



SELECT displayName, Mail, telephoneNumber, name, sAMAccountName, givenName, sn, distinguishedName
  FROM 'LDAP://xxxx'
WHERE objectClass='user'  AND memberOf = 'CN=AGrp-aaaa'
union all
SELECT displayName, Mail, telephoneNumber, name, sAMAccountName, givenName, sn, distinguishedName
  FROM 'LDAP://xxxx'
WHERE objectClass='user'  AND memberOf = 'CN=AGrp-bbbb'
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

( Added ADO, ADO.NET, and SQL Server zones)

>I cannot use an 'in' or a 'union' to get multiple groups.
Why's that?  Is there an error message that is returned when you attempt this?  Copy-pasting that error message into this question would greatly help.

Also if the 'LDAP://xxxx' values above are identical, and you can't use IN (still don't know why), try using order of precedence parentheses ( ) and an OR..
SELECT displayName, Mail, telephoneNumber, name, sAMAccountName, givenName, sn, distinguishedName
FROM 'LDAP://xxxx'
WHERE objectClass='user' AND (memberOf = 'CN=AGrp-aaaa' OR memberOf = 'CN=AGrp-bbbb') 

Open in new window

Avatar of elucero
elucero

ASKER

the error is ADsDSOObject failed with no error message available

I used the parentheses and or and got the same message
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.