FengShui1998
MIS
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
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