# Using OPENQUERY for AD filtering

**URL:** <https://forum.inductiveautomation.com/t/using-openquery-for-ad-filtering/17203>\
**Category:** Ignition\
**Tags:** database\
**Created:** [March 2, 2018, 5:46pm UTC](https://forum.inductiveautomation.com/t/using-openquery-for-ad-filtering/17203 "2018-03-02T17:46:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![misael.lopez](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@misael.lopez](https://forum.inductiveautomation.com/u/misael.lopez)\
**Post date:** [March 2, 2018, 5:46pm UTC](https://forum.inductiveautomation.com/t/using-openquery-for-ad-filtering/17203/1 "2018-03-02T17:46:44Z")

</div>

Hello! I’ve been playing around with OPENQUERY in Ignition to pull more information from users who reside in Active Directory. I’ve had success pulling their names, employee IDs, etc., however, I am not able to query using tag/component values.

For example, lets say I have an employee ID that is 101. I can query it using:  
SELECT \* FROM OPENQUERY (AD,'Select cn  
FROM ‘‘LDAP://myserver.local’’  
WHERE objectClass = ‘‘User’’ AND employeeID = 101  
ORDER BY cn ASC ') AS tblAD

However, if I use a tag/component instead of directly writing the number, the query fails. I believe this is because there are many single and double quotes involved that it cannot distinguish it is a tag/component.

Is there any workaround for this? Can a transaction group be created that can do OPENQUERY?  
(The only workaround I’ve found so far is to have the query as a string and concatenate the tag or component’s value)
