blouckswwu
asked on
Query Active Directory with SQL Server
Is there any way to setup SQL Server to link to Active Directory so I can setup various reports to run automatically querying the SQL server? I am looking for a solution that will work with my existing setup, so I do not have to purchase expensive software.
Thanks for any help!
Thanks for any help!
ASKER
So what do put in the other fields?
Product Name: (??)
Data Source: (servername of my Active Directory Master Browser)
Provider String: (??)
Location: (??)
I'm sorry if these seem like stupid questions, but I can't seem to find any information on how to set this up.
Thanks for your help!!
Product Name: (??)
Data Source: (servername of my Active Directory Master Browser)
Provider String: (??)
Location: (??)
I'm sorry if these seem like stupid questions, but I can't seem to find any information on how to set this up.
Thanks for your help!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I must be missing something here. I followed the msdn article to a 'T' and I still get a damn error. I am using Windows Auth and I am a Domain Admin. But I still get this same error everytime. I was assuming that this was not rocket science, but I assumed wrong. Its frustrating to have all this information in a Database (Active Directory) and I can't get it out easly and Microsoft doesn't put out hardly any information on how to get it out. That one link you gave me was the only real document that shows that it can be done and its one little page. Sorry just frustrated. If you can get a chance to test it and figure out what I am doing wrong, I will give you 1500 points, as I have 3 entries out on different sections regarding this.
Thanks again
Thanks again
Relax... it's not about points. I bet we can figure this out.
What error are you getting?
What error are you getting?
ASKER
Sorry...had a long day yesterday. Here is the error:
Error 7301: Could not obtain a required interface from OLE DB provider 'ADsDSOObject'.
OLE DB error trace [OLE/DB Provider 'ADsDSOObject' IUnknown::QueryInterface returned 0x80004002: IDBSchemaRowset].
I have looked up that error code on google and got nothing worth looking at. I'm wondering if this has something to do with permissions? I am wondering what login SQL server is using to connect to Active Directory? I would assume that you would have to be a domain admin to be able to connect. I looked at the security tab and tried different settings, but couldn't get anything to work.
Thanks
Error 7301: Could not obtain a required interface from OLE DB provider 'ADsDSOObject'.
OLE DB error trace [OLE/DB Provider 'ADsDSOObject' IUnknown::QueryInterface returned 0x80004002: IDBSchemaRowset].
I have looked up that error code on google and got nothing worth looking at. I'm wondering if this has something to do with permissions? I am wondering what login SQL server is using to connect to Active Directory? I would assume that you would have to be a domain admin to be able to connect. I looked at the security tab and tried different settings, but couldn't get anything to work.
Thanks
ASKER
Ok...on one of my other post I got this solution:
https://www.experts-exchange.com/questions/20429310/Linking-with-Windows-2000-Servers-Active-Directory.html
I followed it and I get this error when I run the query (the one with the accepted answer):
Server: Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing a query for execution against OLE DB provider 'ADSDSOObject'.
OLE DB error trace [OLE/DB Provider 'ADSDSOObject' ICommandPrepare::Prepare returned 0x80040e14].
Here is the query:
--Create the Link to Active Directory
EXEC sp_addlinkedserver 'ADSI2', 'Active Directory
Services 2.0', 'ADSDSOObject', 'adsdatasource'
Go
--Create a login entry (not sure what this is for, since it looks like its putting in nulls)
EXEC sp_addlinkedsrvlogin ADSI2, false, null, null, null
Go
--Actual Query
SELECT *
FROM OpenQuery( ADSI2, 'SELECT name, adsPath
FROM ''LDAP://DC=am1st,DC=com''
WHERE objectCategory = ''Person'' AND objectClass= ''user''')
Thanks
https://www.experts-exchange.com/questions/20429310/Linking-with-Windows-2000-Servers-Active-Directory.html
I followed it and I get this error when I run the query (the one with the accepted answer):
Server: Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing a query for execution against OLE DB provider 'ADSDSOObject'.
OLE DB error trace [OLE/DB Provider 'ADSDSOObject' ICommandPrepare::Prepare returned 0x80040e14].
Here is the query:
--Create the Link to Active Directory
EXEC sp_addlinkedserver 'ADSI2', 'Active Directory
Services 2.0', 'ADSDSOObject', 'adsdatasource'
Go
--Create a login entry (not sure what this is for, since it looks like its putting in nulls)
EXEC sp_addlinkedsrvlogin ADSI2, false, null, null, null
Go
--Actual Query
SELECT *
FROM OpenQuery( ADSI2, 'SELECT name, adsPath
FROM ''LDAP://DC=am1st,DC=com''
WHERE objectCategory = ''Person'' AND objectClass= ''user''')
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
From the SQL Management Console, <server name>, Security, Linked Server, click to create a new linked server. From the list of providers, pick "OLEDB Provider for Microsoft Directory Services"... fill out the appropriate info, and you're cooking.
The tables under this linked server are called like this in TransactSQL:
AD...TableName
(Where AD is the name of the linked server)