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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DL List from AD

Status
Not open for further replies.
Apr 27, 1999
705
US
Hello,

I am trying to list the members of a DL in Active Directory. I can run the script fine from VBScript, but when I use it from a function in ASP, I get an error '80072020'.

I am thinking this is a permissions problem and my credentials are not being passed to AD using an ASP page.

Here is the code below: Thanks for your help.

' ===============================
Function Get_DL_Members(tmpDL)
' ===============================

domainusr = "mydom\myaccount"
domainpwd = "mypassword"

Set Container = GetObject("GC:")
For each objGC in Container
Set GC = objGC
Next
ADsPath = GC.ADsPath

Set con = CreateObject("ADODB.Connection")
con.Provider = "ADsDSOObject; User Id=" & domainusr & "; Password=" & domainpwd
con.Open
Set conCommand = CreateObject("ADODB.Command")
Set conCommand.ActiveConnection = con
conCommand.Properties("Page Size") = 99
conCommand.Properties("Cache Results") = True
conCommand.Properties("Asynchronous") = True

strResults = "distinguishedName,displayName,adspath,employeeID,mailnickname"
strFilter = "(&(objectClass=group)(mailnickname=*)(|(displayname=" & tmpDL & ")))"
StrSearch = "<" & ADsPath & ">"
conCommand.CommandText = strSearch & ";" & lcase(strFilter) & ";" & strResults & ";subtree"
Set rsDLs = conCommand.Execute
rsDLs.movefirst

Do While Not rsDLs.eof
DistinguishedName = rsDLs.Fields("DistinguishedName")
Lname = rsDLs.Fields("DisplayName")
Set objDL = GetObject(rsDLs.Fields("adspath"))
mgrDN = objDL.managedBy
mgr = objDL.manager

empID_list = ""
For Each oMember in objDL.Members
if oMember.employeeID <> "" then

email = oMember.mail
empID = oMember.employeeID

if empid_list = "" then
empid_list = empid

elseif empid <> "" then
empid_list = empid_list & "," & empid

end if

end if

Next

rsDLs.movenext
Loop
Get_DL_Members = empid_list

End Function
 
The webserver has to be running on a domain controller to allow ASP code to run AD functions.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top