I have to create a view querying AD group using OpenQuery. I have gone through this question but this doesn't work in case of an SQL view since we can't have local variables in a view.
Please see my below view query:
SELECT
emp.PersonnelID
FROM
OPENQUERY(
MyLinkerServer,
'SELECT
sAMAccountName
FROM
''LDAP://DC=**domain**,DC=organisation,DC=com''
WHERE
objectCategory = ''Person'' AND
objectClass = ''user'' AND
memberOf = ''CN=ADGroupName,OU=SecurityGroups,DC=**domain**,DC=organisation,DC=com'' '
) a
INNER JOIN Employee emp ON
emp.Alias = a.sAMAccountName
I want to replace domain
by fetching it from another table called config
which has columns - key
and value
. I should be able to select value passing a key and that value should replace domain