LDAP and asp

T

TomB

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
 
R

rwg

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" <[email protected]>
| 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
|
|
|
 
T

TomB

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" said:
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
 
T

TomB

You're right, I'm a loser.

I have it set to Anonymous on my developer server.

Thanks

Tom B

"rwg" said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top