Analyzer
Posting Yak Master
United Kingdom
115 Posts |
Posted - 03/19/2014 : 06:19:15
|
Wish to cross check all logins (sql/NT) across sql estate against current logins list inside Active Directory with "Enabled" with the view to purge orphan logins.
I'm using the below syntax the LinkedServer + query but getting the error below. Any ideas where my syntax is incorrect?
EXEC sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5', 'ADSDSOObject', 'myDCServer'
SELECT sAMAccountName FROM OPENQUERY(ADSI, 'SELECT sAMAccountName, userAccountControl FROM ''LDAP://DC=myDCServer,DC=com,DC=uk'' WHERE objectCategory = ''Person'' AND objectClass = ''user''') WHERE userAccountControl & 2 <> 0; -- disabled
Error:
Msg 7321, Level 16, State 2, Line 2 An error occurred while preparing the query "SELECT sAMAccountName, userAccountControl FROM 'LDAP://DC=GBLTCPRDADC01,DC=com,DC=uk' WHERE objectCategory = 'Person' AND objectClass = 'user'" for execution against OLE DB provider "ADSDSOObject" for linked server "ADSI".
|
|