Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querying the activedirectory

Status
Not open for further replies.

Robbomobb

Technical User
May 27, 2003
21
SE
I'm trying to query our directory server for all the e-mail adresses within our domain. I know that i need to add the DC as a linked server and then use the OPENQUERY for the select statement.

1. I'm a little uncertain about the process of adding the linked server and what effects (if any?) it will have on the domain, or DC.

2. How do i retrieve the e-mail adresses from it.

Thankful for all replies.
 
First and most important....is the data on the DC stored in a MS SQL Server database?

Normally email addresses are part of Exchange, which isn't SQL Server based (as far as I know).

-SQLBill
 
SQLBill has a good point! If it is in the Exchange Server(ES), which I feel is the case, you will need to create a batch job and schedule it to create the ES export of email addresses. You may even be able to create this in a stored procedure and/or job. Would also be very do-able via a DTS Package.

Here is a link to chew on for the first (export/batch) step from ES

Thanks

J. Kusch
 
According to this article you can create a linked server to your AD domain controller. If this actually works, let me know


Let me know if this works, and I'll put together an FAQ. I'd test it my self, but we don't have AD here. You should be able to get the email address's using this.

Denny

--Anything is possible. All it takes is a little research. (Me)
 
Thanks for the input.

SQLBill:
The data isn't stored in a MS SQL Server database, as far as know.

There is a field named "E-Mail" under the "General" property window. within an account.

What i'm trying is to get that field from each an every account within our domain.

JayKusch:
Yeah, maybe this is a job to do on the ES. I didn't get the link thou.

mrdenny:
I've tried out what was suggested in the article. I'm sorry to say it didn't work. I get an error message saying

"An error occurred while preparing a query for execution against OLE DB provider 'ADSDSOObject'."

I'll keep trying thou.


 
How are you trying to query the domain controller for the information? Reason I ask is that this forum is for Microsoft SQL Server. If you aren't using SQL Server in anyway, we most likely won't be able to assist you.

You might also consider posting in an Exchange forum. To find out if there is one, use the search at the top of the page.

Good Luck!

-SQLBill
 
Try these query examples,
which assumes that the LDAP (AD) server has been
appropriately configured as a SQL linked server:

-- select from Sun iPlanet
select top 100 * from
OPENQUERY(LDAP_Server,'SELECT UserID, UserStatus
FROM ''LDAP://ldapserver:389/dc=org1,dc=org2'' WHERE objectclass=''*''')

-- select from Microsoft Membership Directory (Site Server)
select top 10 ADsPath
FROM OPENQUERY(Membershipserver,
'SELECT ADsPath FROM ''LDAP://memberserver:389/o=microsoft/ou=Members''
WHERE objectClass = ''*''')
 
SQLBill
I'm trying to setup the DC as a linked server so i can query it from my SQL-server. So far i've had no success in the linked server configuration.

Any help about how to configure the DC as a linked server would be greatly appreciated.

snag57
Thanks for the examples. I'll try them out once i get my liked server configuration to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top