Discussion:
import info from Active directory into SQL table.
(too old to reply)
Gunna
2009-01-15 01:20:15 UTC
Permalink
Hi there,

Im fairly green at SQL so need a little help. I have a simple table with 2
columns. One is called userID and the second is called fullname

I need some help getting my SQl server to connect to an Active directory
server and for all users export the userID and the fullname and put this nifo
into the table. Simple enough. Can anyone help me do this? Also can it be
made dynamic or at least scheduled to keep itself up to date?

Thanks.
Todd C
2009-01-15 14:10:07 UTC
Permalink
This need not be done with DTS or SSIS, specifically. You might be able to
set up a linked server to your Active Directory catalog, or even an OPENQUERY
method.

Try this for the linked server:
********************* START ***********
sp_addLinkedServer
'ADSI',
'Active Directory Service Interfaces',
'ADSDSOObject',
'adsdatasource'

EXEC master.dbo.sp_addlinkedsrvlogin
@rmtsrvname = N'ADSI',
@locallogin = NULL ,
@useself = N'False',
@rmtuser = N''

*************** END ******************
Or try this OPENQUERY method:

************** START ***************
SELECT *
FROM OPENQUERY
(ADSI,
'SELECT
name,
title,
givenName,
sn,
mail,
department,
telephoneNumber,
homePhone,
mobile,
streetAddress,
lastLogonTimestamp
FROM ''LDAP://<YourDomainHere>.com''
WHERE objectCategory = ''Person''
'
)
*************** END ****************

No guarantees for success as AD Security might block you out.

Good Luck.
--
Todd C

[If this response was helpful, please indicate by clicking the appropriate
answer at the bottom]
Post by Gunna
Hi there,
Im fairly green at SQL so need a little help. I have a simple table with 2
columns. One is called userID and the second is called fullname
I need some help getting my SQl server to connect to an Active directory
server and for all users export the userID and the fullname and put this nifo
into the table. Simple enough. Can anyone help me do this? Also can it be
made dynamic or at least scheduled to keep itself up to date?
Thanks.
Continue reading on narkive:
Loading...