Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Analyzer
Posting Yak Master
115 Posts |
Posted - 2014-03-19 : 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 sAMAccountNameFROM OPENQUERY(ADSI, 'SELECT sAMAccountName, userAccountControl FROM ''LDAP://DC=myDCServer,DC=com,DC=uk'' WHERE objectCategory = ''Person'' AND objectClass = ''user''') WHERE userAccountControl & 2 <> 0; -- disabledError:Msg 7321, Level 16, State 2, Line 2An 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". |
|
|
|
|