Last active
April 27, 2018 17:08
-
-
Save R41D3NN/ac322c29558012fed3a3968b63b036cd to your computer and use it in GitHub Desktop.
Secret Server report to show discovered AD Users and each group they are in. Each group is in it's own row. Filtered by group name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
A.[OU DN], | |
A.[AccountName], | |
Split.a.value('.', 'VARCHAR(1000)') AS [Group] | |
FROM ( | |
SELECT | |
[ou].[DistinguishedName] AS 'OU DN', | |
[ca].[AccountName], | |
CAST ('<M>' + REPLACE(REPLACE(REPLACE(REPLACE([ca].[SearchGroups], '&', '\u0026'), '<', '\u003C'), '>', '\u003E'), CHAR(59), '</M><M>') + '</M>' AS XML) AS [Group] | |
FROM [tbComputerAccount] [ca] | |
JOIN [tbOrganizationUnit] [ou] ON [ca].[OrganizationUnitId] = [ou].[OrganizationUnitId] | |
) AS A | |
CROSS APPLY [Group].nodes ('/M') AS Split(a) | |
WHERE Split.a.value('.', 'VARCHAR(1000)') LIKE '%' + #CUSTOMTEXT + '%' | |
ORDER BY | |
[Group], | |
A.[OU DN], | |
A.[AccountName] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment