LDAP and asp

Discussion in 'ASP General' started by TomB, Apr 16, 2004.

  1. TomB

    TomB Guest

    I'm trying to browse our Active Directory.
    I found the following on a website

    <CODE>
    Set oRootDSE = GetObject("LDAP://RootDSE")
    Set oDomain = GetObject("LDAP://" & oRootDSE.Get("DefaultNamingContext"))

    Call EnumOUs(oDomain.ADsPath)

    Sub EnumOUs(sADsPath)

    Set oContainer = GetObject(sADsPath)
    oContainer.Filter = Array("OrganizationalUnit")
    For Each oOU in oContainer
    WScript.Echo oOU.ADsPath
    EnumUsers(oOU.ADsPath)
    EnumOUs(oOU.ADsPath)
    Next

    End Sub

    Sub EnumUsers(sADsPath)

    Set oContainer = GetObject(sADsPath)
    oContainer.Filter = Array("User")
    For Each oADobject in oContainer

    WScript.Echo oADobject.sAMAccountName
    WScript.Echo oADobject.displayName
    WScript.Echo oADobject.Description
    WScript.Echo oADobject.employeeID

    Next

    End Sub

    </CODE>

    Which works fine as a WSH script.

    I tried changing all of the WScript.Echo 's to Response.write 's but it
    chokes on the second line.
    (chokes = could not find table)
    Could someone tell me what I'm doing wrong.

    I've used ADSI successfully before, but now that we are on Active Directory,
    I can't seem to get what I want.

    Thanks
    Tom B
     
    TomB, Apr 16, 2004
    #1
    1. Advertising

  2. TomB

    rwg Guest

    You didn't list your error codes, but I tried this, I received an error code: error '8007054b'

    This error implies a security context issue.

    I changed my asp page to use Integrated Windows security, forcing this page to run under my domain credentials, and it worked. I hope this works for you
    also.

    -rwg
    This is what I think, not necessarily what is accurate!

    --------------------
    | From: "TomB" <>
    | Subject: LDAP and asp
    | Date: Fri, 16 Apr 2004 12:12:49 -0400
    | Lines: 52
    | Newsgroups: microsoft.public.inetserver.asp.general
    |
    | I'm trying to browse our Active Directory.
    | I found the following on a website
    |
    | <CODE>
    | Set oRootDSE = GetObject("LDAP://RootDSE")
    | Set oDomain = GetObject("LDAP://" & oRootDSE.Get("DefaultNamingContext"))
    |
    | Call EnumOUs(oDomain.ADsPath)
    |
    | Sub EnumOUs(sADsPath)
    |
    | Set oContainer = GetObject(sADsPath)
    | oContainer.Filter = Array("OrganizationalUnit")
    | For Each oOU in oContainer
    | WScript.Echo oOU.ADsPath
    | EnumUsers(oOU.ADsPath)
    | EnumOUs(oOU.ADsPath)
    | Next
    |
    | End Sub
    |
    | Sub EnumUsers(sADsPath)
    |
    | Set oContainer = GetObject(sADsPath)
    | oContainer.Filter = Array("User")
    | For Each oADobject in oContainer
    |
    | WScript.Echo oADobject.sAMAccountName
    | WScript.Echo oADobject.displayName
    | WScript.Echo oADobject.Description
    | WScript.Echo oADobject.employeeID
    |
    | Next
    |
    | End Sub
    |
    | </CODE>
    |
    | Which works fine as a WSH script.
    |
    | I tried changing all of the WScript.Echo 's to Response.write 's but it
    | chokes on the second line.
    | (chokes = could not find table)
    | Could someone tell me what I'm doing wrong.
    |
    | I've used ADSI successfully before, but now that we are on Active Directory,
    | I can't seem to get what I want.
    |
    | Thanks
    | Tom B
    |
    |
    |
     
    rwg, Apr 19, 2004
    #2
    1. Advertising

  3. TomB

    TomB Guest

    Interesting. Thanks for your input. I am running under Integrated
    Security.
    My error code is 0x800A000D
    and the message is a Type Mismatch on Line 17, which is the second line
    Set oDomain = GetObject("LDAP://" & oRootDSE.Get("DefaultNamingContext"))

    If I Response.Write oRootDSE.Get("DefaultNamingContext")) I get....
    DC=ourdomain,DC=ca

    Which seems correct.

    Thanks again for your help

    ""rwg"" <> wrote in message
    news:...
    > You didn't list your error codes, but I tried this, I received an error

    code: error '8007054b'
    >
    > This error implies a security context issue.
    >
    > I changed my asp page to use Integrated Windows security, forcing this

    page to run under my domain credentials, and it worked. I hope this works
    for you
    > also.
    >
    > -rwg
    > This is what I think, not necessarily what is accurate!
    >
    > --------------------
    > | From: "TomB" <>
    > | Subject: LDAP and asp
    > | Date: Fri, 16 Apr 2004 12:12:49 -0400
    > | Lines: 52
    > | Newsgroups: microsoft.public.inetserver.asp.general
    > |
    > | I'm trying to browse our Active Directory.
    > | I found the following on a website
    > |
    > | <CODE>
    > | Set oRootDSE = GetObject("LDAP://RootDSE")
    > | Set oDomain = GetObject("LDAP://" &

    oRootDSE.Get("DefaultNamingContext"))
    > |
    > | Call EnumOUs(oDomain.ADsPath)
    > |
    > | Sub EnumOUs(sADsPath)
    > |
    > | Set oContainer = GetObject(sADsPath)
    > | oContainer.Filter = Array("OrganizationalUnit")
    > | For Each oOU in oContainer
    > | WScript.Echo oOU.ADsPath
    > | EnumUsers(oOU.ADsPath)
    > | EnumOUs(oOU.ADsPath)
    > | Next
    > |
    > | End Sub
    > |
    > | Sub EnumUsers(sADsPath)
    > |
    > | Set oContainer = GetObject(sADsPath)
    > | oContainer.Filter = Array("User")
    > | For Each oADobject in oContainer
    > |
    > | WScript.Echo oADobject.sAMAccountName
    > | WScript.Echo oADobject.displayName
    > | WScript.Echo oADobject.Description
    > | WScript.Echo oADobject.employeeID
    > |
    > | Next
    > |
    > | End Sub
    > |
    > | </CODE>
    > |
    > | Which works fine as a WSH script.
    > |
    > | I tried changing all of the WScript.Echo 's to Response.write 's but it
    > | chokes on the second line.
    > | (chokes = could not find table)
    > | Could someone tell me what I'm doing wrong.
    > |
    > | I've used ADSI successfully before, but now that we are on Active

    Directory,
    > | I can't seem to get what I want.
    > |
    > | Thanks
    > | Tom B
    > |
    > |
    > |
    >
    >
     
    TomB, Apr 19, 2004
    #3
  4. TomB

    TomB Guest

    You're right, I'm a loser.

    I have it set to Anonymous on my developer server.

    Thanks

    Tom B

    ""rwg"" <> wrote in message
    news:...
    > You didn't list your error codes, but I tried this, I received an error

    code: error '8007054b'
    >
    > This error implies a security context issue.
    >
    > I changed my asp page to use Integrated Windows security, forcing this

    page to run under my domain credentials, and it worked. I hope this works
    for you
    > also.
    >
    > -rwg
    > This is what I think, not necessarily what is accurate!
    >
    > --------------------
    > | From: "TomB" <>
    > | Subject: LDAP and asp
    > | Date: Fri, 16 Apr 2004 12:12:49 -0400
    > | Lines: 52
    > | Newsgroups: microsoft.public.inetserver.asp.general
    > |
    > | I'm trying to browse our Active Directory.
    > | I found the following on a website
    > |
    > | <CODE>
    > | Set oRootDSE = GetObject("LDAP://RootDSE")
    > | Set oDomain = GetObject("LDAP://" &

    oRootDSE.Get("DefaultNamingContext"))
    > |
    > | Call EnumOUs(oDomain.ADsPath)
    > |
    > | Sub EnumOUs(sADsPath)
    > |
    > | Set oContainer = GetObject(sADsPath)
    > | oContainer.Filter = Array("OrganizationalUnit")
    > | For Each oOU in oContainer
    > | WScript.Echo oOU.ADsPath
    > | EnumUsers(oOU.ADsPath)
    > | EnumOUs(oOU.ADsPath)
    > | Next
    > |
    > | End Sub
    > |
    > | Sub EnumUsers(sADsPath)
    > |
    > | Set oContainer = GetObject(sADsPath)
    > | oContainer.Filter = Array("User")
    > | For Each oADobject in oContainer
    > |
    > | WScript.Echo oADobject.sAMAccountName
    > | WScript.Echo oADobject.displayName
    > | WScript.Echo oADobject.Description
    > | WScript.Echo oADobject.employeeID
    > |
    > | Next
    > |
    > | End Sub
    > |
    > | </CODE>
    > |
    > | Which works fine as a WSH script.
    > |
    > | I tried changing all of the WScript.Echo 's to Response.write 's but it
    > | chokes on the second line.
    > | (chokes = could not find table)
    > | Could someone tell me what I'm doing wrong.
    > |
    > | I've used ADSI successfully before, but now that we are on Active

    Directory,
    > | I can't seem to get what I want.
    > |
    > | Thanks
    > | Tom B
    > |
    > |
    > |
    >
    >
     
    TomB, Apr 19, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    555
    Raymond DeCampo
    Feb 21, 2006
  2. rcmn
    Replies:
    1
    Views:
    375
    =?ISO-8859-1?Q?Michael_Str=F6der?=
    Nov 6, 2006
  3. Jason Wold

    using LDAP Controls in ruby-ldap

    Jason Wold, Nov 4, 2004, in forum: Ruby
    Replies:
    5
    Views:
    281
  4. Ian Macdonald
    Replies:
    0
    Views:
    239
    Ian Macdonald
    Mar 15, 2005
  5. James Hughes
    Replies:
    4
    Views:
    351
    James Hughes
    Dec 13, 2005
Loading...

Share This Page