Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LDAP ADO Query: Can anyone Explain this STRANGE behavior?

Status
Not open for further replies.

rklein

IS-IT--Management
Sep 28, 2005
10
US
I have this sample ASP program that:


1) Binds to an AD user object
2) Displays the property count
3) Displays the property Names with their Values
4) Displays the property Names only


When run from a client browser, it's only able to display a few
property values (telephoneNumber, cn, mail, and a couple more) in part
3 although all 83 property names are displayed in part 4. If I don't
have the On Error Resume in #3 I get the dreaded "Unspecified Error".


UNTIL (this is the weird part) I log into the server and execute it
from a browser there which not only diplays all of the property values
but also enables it to work from client browsers as well.


When the webserver is rebooted, I need to execute the ASP page locally
again for client browsers to work.


This has behavior has been duplicated on freshly installed Windows 2000
& 2003 servers. I'm running the ASP page and the same user (a Domain
Admin) everytime.


<%@ Language=VBScript %>
<%
Option Explicit


sub GetDisplayName


dim objConnection, objCommand, objRecordSet, objUser, objDomain,
objADsPath, objRootOU, f, i, p, ff


Set objDomain = GetObject ("GC://rootDSE")
objADsPath = objDomain.Get("defaultNamingContext")
Set objDomain = Nothing


response.write objADsPath & "<br>"


Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"


objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection


objCommand.CommandText = "SELECT AdsPath FROM 'LDAP://" & objADsPath
& "' WHERE sAMAccountname='<***INSERT ACCOUNT NAME HERE***>'"
set objRecordSet = objCommand.Execute


response.write "**AdsPath: " & objRecordSet("AdsPath") & "<br>"


Set objUser = GetObject(objRecordSet.Fields("AdsPath").Value)


response.write "<hr>" & objUser.PropertyCount & "<br>"


for i= 0 to objUser.PropertyCount-1
set p = objUser(i)
On Error Resume Next
response.write p.Name & ": " & objUser.Get(p.Name) & "<br>"
next


response.write "<hr>"


for i= 0 to objUser.PropertyCount-1
set p = objUser(i)
On Error Resume Next
response.write p.Name & "<br>"
next


objRecordSet.close
objConnection.close
set objRecordSet=nothing
set objConnection=nothing
end sub


%>


<html>
<body>


<%call GetDisplayName%>


</body>
</html>


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top