sql open query on active directory with multiple where clause

1.4k views Asked by At

I'm trying to limit the results using more than one WHERE clause like it is done in .net such as

search.Filter = ("(&(objectCategory=person)(physicaldeliveryofficename=*))

but in SQL with open query on linked server I have this and works fine with only one where clause.

SELECT Name, Department, Title, Telephonenumber Phone, physicaldeliveryofficename Location FROM OPENQUERY( ADSI, 'SELECT Name, Department, Title, Telephonenumber, physicaldeliveryofficename, SN, ST FROM ''LDAP://OU=XM,DC=nix,DC=com'' WHERE physicaldeliveryofficename= ''*'' ')

Is it even possible to have more than one WHERE clause? Thanks in advance for any assistance.

1

There are 1 answers

1
baldpate On BEST ANSWER

More than one WHERE clause? Or you just want to put the filters together with "AND"?

WHERE 
    physicaldeliveryofficename= "*" AND
    objectCategory="person"