Click to See Complete Forum and Search --> : how can i access users through active directory in asp


X-il3
February 13th, 2001, 05:21 AM
I was wondering how i can get the username table is active directory? I am developing a web page that requires to have up-to-date info on users and then import that table into sql database.

jgauntz
February 13th, 2001, 10:20 AM
Username table ?? I am not familiar with a "username" table in Active Directory. If you just want to get a list of users, simply use ADO to connect to AD and then query for all users where their objectClass=user. If you need more let me know.

- Jason

X-il3
February 13th, 2001, 10:21 AM
Could you give me an example? I am a little new to this. Thanks.

jgauntz
February 13th, 2001, 10:35 AM
If you give me your email address I can send you an example. It seems this site does not like "" in the text.

X-il3
February 13th, 2001, 10:35 AM
elvar@naskef.navy.mil

jgauntz
February 13th, 2001, 10:49 AM
I sent the email to you. Let me know if I can be of any more help.

X-il3
February 13th, 2001, 11:02 AM
Do u have any email that i can contact u?

X-il3
February 13th, 2001, 11:42 AM
I havent received anything yet. I hope u sent it on the right address.

jgauntz
February 13th, 2001, 12:31 PM
I can be contacted via email at jgauntz@smartpipes.com

jgauntz
February 13th, 2001, 02:40 PM
Here is an example I wrote in VBScript


dim DBConnect
set DBConnect = CreateObject("ADODB.Connection")

DBConnect.Provider = "ADSDSOObject"
DBConnect.Properties("User ID") = "userID"
DBConnect.Properties("Password") = "password"
DBConnect.Properties("Encrypt Password") = True
DBConnect.CursorLocation = 3
DBConnect.Open "DS Query"

dim Command
set Command = CreateObject("ADODB.Command")
set Command.ActiveConnection = DBConnect

dim attributes
dim filter

'// the attributes you wish to return from AD
attributes = "name, userPrincipalName"
filter = "(|(objectClass=user))"

Command.CommandText = "(LDAP://servername or ip address of server with AD);" & filter & "; " & attributes & " ;subTree"


set infRS = Command.Execute

recordSetCount = infRS.RecordCount
msgbox(recordSetCount)


NOTE : For Command.CommandText - where there is a "(" replace with less than sign, and where there is a ")" replace with greater than sign. For some reason this forum will not allow less than and greater than signs.