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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting Fields gives unsepecified error. Using * doesn't.

Status
Not open for further replies.

st3ph3n

Programmer
Sep 18, 2004
15
0
0
GB
Argghhhhhh. This is annoying me now. I've coded up a nice ASP solution based on some of the excellent work previously seen on this site, in particular that of zcolton. It retrieves details about a user from AD based on the Auth_User. It's for logging support requests for the IT department, and it emails all the details to us so we have them to hand.

But to my problem. I'm trying to get the same system working on the Intranet server (Windows 2000, IIS5.0, MDAC 2.8 and part of the Domain), rather than my PC (Windows XP, SP2, .NET 1.1, Latest MDAC too, and part of the Domain, of which I am an Admin) in preperation for it going live. It was failing on an unspecified error, so I have broken the system into a manageable chunk to find the problem.

The code I'm using to to test is as follows:

<%@ Language=VBScript %>
<%
Option Explicit
Dim con,rs,Com,objADsPath,objDomain
%>
<html>
<head>
</head>
<body bgcolor="#CCCCCC">
<%
Set objDomain = GetObject ("GC://RootDSE")
objADsPath = objDomain.Get("defaultNamingContext")
Set objDomain = Nothing
Set con = Server.CreateObject("ADODB.Connection")
con.provider ="ADsDSOObject"
con.open "Active Directory Provider"
Set Com = CreateObject("ADODB.Command")
Set Com.ActiveConnection = con
Com.CommandText ="select * from 'LDAP://"+objADsPath+"' WHERE objectCategory='person' AND sAMAccountName='*' order by name"
Set rs = Com.Execute

Do While Not rs.EOF Or rs.BOF

Response.Write rs(0) & "<BR>"

rs.MoveNext
Loop
rs.Close

con.Close
Set rs = Nothing
Set con = Nothing
%>
</body>
</html>

This code works fine, and I get a list of all the accounts back, in the format "LDAP://CN=The Name,OU=Whatever,DC=msl,DC=net".

If I want to actually retrieve back the particular details about someone then I obviously have to change my select statement.

So I change the line to:
Com.CommandText ="select sAMAccountName from 'LDAP://"+objADsPath+"' WHERE objectCategory='person' AND sAMAccountName='*' order by name"
I'm just trying to bring back the account name as a test. This results in the error:
Provider error '80004005'

Unspecified error

/test2.asp, line 20

I'm at my wits end here trying to get this working. Does anyone have any suggestions?

Many Thanks

Stephen
 
Yay! I got it working.

After another few days of searching I read this Microsoft KB article - - and deleted the registry entry it suggests. Then I rebooted the Intranet box and tried my test page again and it worked. So then I tried the site thats been developed on my PC and it worked first time. Fantastic.
 
Thanks for the info -- I'm having a very similar problem. Can't access the department or sAMAccountName fields - even though I can get to most other fields listed in the schema.

Can't quite make sense, however, out of the solution you linked to in the KB. Can you elaborate just a bit more as to what was going wrong?

 
Sure thing. I believe the Intranet PC had cached a previous LDAP query, or had built the cache itself. Either way the fields I required were not available in the cache, and it wasn't refreshing for me.

So what I did was to delete the appropriate registry key - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ADs\Providers\LDAP\distinguished name of the schema container

I backed it up first of course.

Then I rebooted the PC, in this case the company Intranet server, fired up my test page again, making sure to properly refresh it, and all was well.
 
I've been away from this for a few weeks, but back to it ... and it is STILL not working.

You're saying that all you did was delete the registry key, reboot the machine, and you could Select department..?

What did your "distinguished name of the schema container" contain? All that is on my system is "cn=Subschema".

Rob
 
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ADs\Providers\LDAP\CN=Aggregate,CN=Schema,CN=Configuration,DC=msl,DC=net

Our domain is msl.net.

I've actually had a few problems here and there with this. Always on our Intranet box, never on my PC. It was rebooted recently and then wasn't playing ball when it came back on again. I eventually got it working, but I'm not really sure how.

I think I deleted the schema cache (%SystemRoot%\SchCache\msl.net.sch) and the registry entry, then rebooted.

I might even have copied the cache from this PC to the server and changed the time value in the registry to match what it was on my PC.

One of them worked and one of them didn't. I tried so many things in the space of 20 minutes that I can't really remember what fixed it.

I have vowed to document what I do the next time the Intranet server is rebooted (if it causes a problem). I'll post my findings when I do.
 
Resurrecting my own thread here.

The problem has happened again. And this time I can't fix it. I've even tried it on other servers and they give me the same error, both Win2K and Win2K3.

I've searched everywhere for a proper solution with no luck.
 
Well after a few days of trying I have finally made it work.

I rebooted the Intranet server. Logged into it and openned up one of my sites. It worked! Went back to my PC and it worked from there too. Tried it on 2 different servers and it fixed it.

I've now added an entry in the startup that opens up one of these sites. So now after a reboot and someone logging in it should work fine.

Still don't know the cause and/or a proper solution. But that worked for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top