• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

ASP Connecting to multiple Active Directories

K

kah521

#1
I have written the following VBScript method to connect to multiple Active
Directory forests. It was throwing some connectivity errors but they changed
security and firewall settings now and those errors have gone away. However,
when I check to see if someone exists in the second AD it can never find the
user. It can successfully find the user in the AD which the web server
exists in. Is it possible to read from multiple active directories with ASP
and if so what might be wrong with this code or the network that we can look
further into?

function IsUserInActiveDirectory(strNamingContext, strLogin)

On Error Resume Next
Response.Write "<BR><BR>NC: " & strNamingContext
dim objRootDSE

Set objRootDSE = GetObject("LDAP://" & strNamingContext)
Response.Write "<BR>Err1: " & Err.Number & " - " & Err.Description

dim objDSObj
dim objAuth

'validate against the namespace
set objDSObj = GetObject("LDAP:")
Response.Write "<BR>Err2: " & Err.Number & " - " & Err.Description


'Set objAuth = objDSObj.OpenDSObject("LDAP://" & strNamingContext, "", "",
ADS_SECURE_AUTHENTICATION)
'Response.Write "<BR>Err3: " & Err.Number & " - " & Err.Description



dim cn, rs
set cn = server.CreateObject("adodb.connection")
cn.Provider = "ADSDSOObject"
cn.Open
Set rs = cn.Execute("<LDAP://" & strNamingContext & ">;(sAMAccountName=" &
strLogin & ");AdsPath, cn")

Response.Write "<BR>Err4: " & Err.Number & " - " & Err.Description

if (rs.EOF) then
IsUserInActiveDirectory = False
else

IsUserInActiveDirectory = True
Dim name
name = rs(0)
name = mid(left(name , instr(name, ",")-1), instr(name, "=")+1)
Response.Write "<BR>Active Directory Name: " & name

end if


Response.Write "<BR>Context: " & strNamingContext & " - " & strLogin & " - "
& IsUserInActiveDirectory
End Function
 

My Computer

K

kah521

#2
I have written the following VBScript method to connect to multiple Active
Directory forests. It was throwing some connectivity errors but they changed
security and firewall settings now and those errors have gone away. However,
when I check to see if someone exists in the second AD it can never find the
user. It can successfully find the user in the AD which the web server
exists in. Is it possible to read from multiple active directories with ASP
and if so what might be wrong with this code or the network that we can look
further into?

function IsUserInActiveDirectory(strNamingContext, strLogin)

On Error Resume Next
Response.Write "<BR><BR>NC: " & strNamingContext
dim objRootDSE

Set objRootDSE = GetObject("LDAP://" & strNamingContext)
Response.Write "<BR>Err1: " & Err.Number & " - " & Err.Description

dim objDSObj
dim objAuth

'validate against the namespace
set objDSObj = GetObject("LDAP:")
Response.Write "<BR>Err2: " & Err.Number & " - " & Err.Description


'Set objAuth = objDSObj.OpenDSObject("LDAP://" & strNamingContext, "", "",
ADS_SECURE_AUTHENTICATION)
'Response.Write "<BR>Err3: " & Err.Number & " - " & Err.Description



dim cn, rs
set cn = server.CreateObject("adodb.connection")
cn.Provider = "ADSDSOObject"
cn.Open
Set rs = cn.Execute("<LDAP://" & strNamingContext & ">;(sAMAccountName=" &
strLogin & ");AdsPath, cn")

Response.Write "<BR>Err4: " & Err.Number & " - " & Err.Description

if (rs.EOF) then
IsUserInActiveDirectory = False
else

IsUserInActiveDirectory = True
Dim name
name = rs(0)
name = mid(left(name , instr(name, ",")-1), instr(name, "=")+1)
Response.Write "<BR>Active Directory Name: " & name

end if


Response.Write "<BR>Context: " & strNamingContext & " - " & strLogin & " - "
& IsUserInActiveDirectory
End Function
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)