Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - ASP Connecting to multiple Active Directories

Reply
 
Old 02-11-2009   #1 (permalink)
kah521


 
 

ASP Connecting to multiple Active Directories

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 System SpecsSystem Spec
Old 02-11-2009   #2 (permalink)
kah521


 
 

ASP Connecting to multiple Active Directories

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 System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Connecting to VPN stops Internet and Multiple Networks Issue Vista networking & sharing
Folder Size Multiple Directories VB Script
Copy files from multiple directories.. PowerShell
How to delete multiple mail sub-directories Live Mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46