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 Forum
Connecting to VPN stops Internet and Multiple Networks Issue
Hi, I had this issue with Vista and since upgrading to 7 RC1 I seem to get the same issue so it's abveously supposed to happen. I am on a...
Vista networking & sharing
Default Directories
Now that I can access documents on my Main PC from my Laptop, is there a way to set the default directories for Word & Excel on my Laptop to get...
Vista networking & sharing
Folder Size Multiple Directories
Hello, Can someone please tell me if there is a script out there that would collect all folder sizes in a Windows Server 2003 Directory?...
VB Script
Copy files from multiple directories..
Here's what I'm trying to do. We have files that we would like to copy over from different servers and shares to 1 central server each night. ...
PowerShell
How to delete multiple mail sub-directories
Cannot imagine why WLM left out the simple process of multiple mail sub-directory selecting process, so that user can delete or move them. Any idea...
Live Mail
Using FolderShare for "active" directories...
I'd like to have FolderShare operating in the background on my work directories at the office and at home to keep both machines synced. The...
Live Folder Share
FTP whole directories?
I was wondering if there is anway to FTP whole directories. I want to schedule FTP to downlaod an entire directory every night. I have tried...
Vista General