Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ADO - ADSI Datatype woes!

2 views
Skip to first unread message

Michael Wm. Donovan

unread,
Nov 10, 1999, 3:00:00 AM11/10/99
to

I have been trying to read a Netscape Directory Server (4.1) in a
VBScript ADO program. I have enclosed the code below, but first let me
explain what has happened.

Every time I try to print a field from a Recordset which my query
returns, I get the error:

Microsoft VBScript runtime error '800a000d'

Type mismatch

/auxCART/adsi_sel.asp, line 67

It turns out this happened on the line:

Response.Write rs("cn") & ", " & rs("uid") & "<BR>"


I printed out the Query. I know it works, it tells me that 1 record has
been returned:

select uid, cn from 'LDAP://servername' WHERE uid ='phyllis'

I did a bunch of looking around. I couldn't find anything wrong with the
field definitions. So I put some code in to loop through the Recordset
Fields:

Response.Write "<Table Border=1 Cellpadding=5>"
Response.Write "<TH>Name</TH><TH>Type</TH>"

Set flds = rs.Fields
For each fld in flds

Response.Write "<TR>"
Response.Write "<TD>" & fld.Name & "</TD>"
Response.Write "<TD ALIGN=CENTER>" & fld.Type & "</TD>"
Response.Write "</TR>"

Next
Response.Write "</TABLE>"

This told me that the Field names were there but the Field Types were
all set to 12. If you look at Microsoft's DataTypeEnum page:

12 = Automation Variant. There is a note which says:

This data type is currently not supported by ADO. Usage may
cause unpredictable results.

I ran the above code against a Recordset returned from an Access
Database. All the text fields were set to 200. The DataTypeEnum says:

200 = a string value

So, I know what is wrong.

The ADS provider returns an incorrect Data Type.

Now what can I do about it?
Did Microsoft improperly implement their ADSI code for Netscape
Directory Servers?
Or do I have a bad ADs Provider?

Can anyone help me at all?

Thanks for reading this far, if yoiu are still here. Here is my code.


<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<BODY>
<CENTER><H1>ADO using ADSI Microsoft code test</H1></CENTER>
<%
Dim com
Dim con
Dim rs
Dim srchTxt

Set con = CreateObject("ADODB.Connection")
Set com = CreateObject("ADODB.Command")

con.Provider = "ADsDSOObject" 'this is the ADSI-OLEDB provider name
con.Open "ADs provider"

Set Com.ActiveConnection = con

srchTxt = "select uid, cn from "
srchTxt = srchTxt & "'LDAP://Servername' WHERE uid ='phyllis'"

Com.CommandText = srchTxt

Set rs = Com.Execute

Response.Write "<P>Records returned: " & rs.RecordCount & "<P>" &
vbCrLf

While Not rs.EOF ' Navigate the record set

Response.Write rs("cn") & ", " & rs("uid") & "<BR>"

rs.MoveNext
Wend

%>
</BODY>
</HTML>


Jason Rosenberg

unread,
Nov 12, 1999, 3:00:00 AM11/12/99
to
Michael,

I was having the same exact problem that you explained in your email. The
only difference I see is that our LDAP is Site Server v3.0 Commerce.

I had a couple very good responses when I posted my problem. One reply
stated that the 'Type Mismatch' is because the 'cn' attribute is a
multi-valued attribute. I am not sure if that is true but I managed to
compile a working code set from these replies. I put most of your paremters
from your code into mine, but you may want to check it over to make sure.
Here it is:

Note: I am running this with ADSI 2.5 and MDAC 2.1 just so you can compare
to what your running.
--------------------------
<HTML>
<HEAD>
<TITLE>ADSI/ADO</TITLE>
</HEAD>

<BODY>
<%
Dim ADOconnObj
Dim RSObj
Dim ResultObj
Dim NamespaceObj

' Create ADO Connection object
Set ADOconnObj = CreateObject("ADODB.Connection")

ADOconnObj.Provider = "ADSDSOObject"
ADOconnObj.Open "ADs Provider"

'ADO command string
bstrADOQueryString = "SELECT ADSPath FROM 'LDAP://servername' WHERE uid
='phyllis'"

'Create an ADO RecordSet object by executing command string
Set RSObj = ADOconnObj.Execute(bstrADOQueryString)
%>
<TABLE BORDER="1" width="500">
<TR>
<TD><font face="Verdana, Arial, Helvetica, sans-serif"
size="2"><B>CN</B></font></TD>
<TD><font face="Verdana, Arial, Helvetica, sans-serif"
size="2"><B>UID</B></font></TD>
<TR>
<%
'Iterate through the returned record set
count = 1
While Not RSObj.EOF
Set ResultObj = GetObject(RSObj.Fields(0).Value)
count = count + 1
Response.Write "<TD><font face=Verdana, Arial, Helvetica, sans-serif
size=2>" & ResultObj.cn & "&nbsp;</font></TD><TD><font face=Verdana, Arial,
Helvetica, sans-serif size=2>" & ResultObj.uid & "&nbsp;</font></TD</TR>"
RSObj.MoveNext
Wend
%>
<TR>
<TD COLSPAN="5" ALIGN="CENTER"><font face="Verdana, Arial, Helvetica,
sans-serif" size="2"><B>END</B></font></TD>
</TR>
</TABLE>
------------------------

I hope this helps you out.

Thanks.

Jason Rosenberg
jrose...@smtusa.com


Michael Wm. Donovan <Michael....@Boeing.Com> wrote in message
news:3829C141...@Boeing.Com...

0 new messages