Problem : Cannot fetch a row from OLE DB provider “ADSDSOObject”
I have a veiw in SQL that is suppose to query the ADSI linked server. When i run the query i get error: Cannot fetch a row from OLE DB provider “ADSDSOObject” for linked server”ADSI”. Here is the code for the view:
1: 2: 3: 4: 5: 6: 7: 8: 9: |
SELECT sAMAccountName AS [Login Name], givenName AS [First Name], sn AS [Last Name], displayName AS [Full Name], mail AS [E-Mail Address], telephoneNumber AS Phone, derivedtbl_1.* FROM OPENQUERY(ADSI, 'SELECT sAMAccountName, givenName, sn,displayName, mail, telephoneNumber FROM ''LDAP://dc=domain,dc=domain,dc=org'' WHERE objectClass = ''user'' and objectCategory=''person'' AND memberOf = ''cn=bla, ou=bla, ou=bla,dc=domain, dc=domain, dc=org''') AS derivedtbl_1 |
Solution: Cannot fetch a row from OLE DB provider “ADSDSOObject”
You must have Adsldp.dll, Adsldpc.dll, Adsmsext.dll, and Activeds.dll installed on your client computer to work with the provider…
Step 1: Create a linked server to your Active Directory
sp_addlinkedserver ‘ADSI’, ‘Active Directory Service Interfaces’, ‘ADSDSOObject’, ‘adsdatasource’
Step 2: Create a view in SQL server using OPENQUERY to select from Active Directory
CREATE VIEW dbo.vw_AD_USER_INFO
AS
SELECT *
FROM OPENQUERY(ADSI,
‘SELECT sAMAccountName, givenName, sn,displayName, mail, telephoneNumber
FROM
”LDAP://dc=domain,dc=domain,dc=org”
WHERE objectClass = ”user” and objectCategory=”person”’)
GO