Windows Vista Forums

ASP Connecting to multiple Active Directories

  1. #1


    kah521 Guest

    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

  2. #2


    kah521 Guest

    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

ASP Connecting to multiple Active Directories

Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting to VPN stops Internet and Multiple Networks Issue Mike D Vista networking & sharing 2 12 Jul 2009
Folder Size Multiple Directories Yorgy VB Script 2 15 Feb 2009
Copy files from multiple directories.. Steve Grosz PowerShell 8 12 Jan 2009
How to delete multiple mail sub-directories User66 Live Mail 2 31 Aug 2008
Using FolderShare for "active" directories... Derek Live Folder Share 1 04 Mar 2008