ADO.Net to fetch ActiveDirectory this function bugs in Asp.net but works in Vb.n 
Author Message
 ADO.Net to fetch ActiveDirectory this function bugs in Asp.net but works in Vb.n

Hi !!

I've written this generic function that receive in
arguments: an LDAP query, UserId and Password. It creates
connection, fills a dataset and returns the dataset. Used
in my VB code, it works but when I used it in ASP.net code
or as a WebService, it fails each time with the
error: "DB_E_NOTABLE(0x80040E37)."

I tried to change the "Provider=ADsDSOObject" string but
the error message changed so I tried to change the "Data
Source=Active Directory Provider" string and there, the
error message did not change so I'm wondering if the
problem wouldn't the data source...

Is there a way to know if that datasource is available on
my server and how to install it

Thanks for any help,
Claude Vernier

As an example, this query is supposed to be working:
SELECT distinguishedName
FROM 'LDAP://myadserver:404/ou=People,dc=cvi,dc=hyrule,dc=c
om' WHERE objectClass='CVIperson' AND cn='gandalf'

'Feel free to use this function in your VB.NET code to
fetch AD data using ADO.NET
Public Function CreateDataSetForActiveDirectory(ByVal
sQuery As String, Optional ByVal sUid As String
= "anonymous", Optional ByVal sPwd As String
= "anonymous") As System.Data.DataSet

Dim oOleDbDataSet As New System.Data.DataSet()

Try

Dim oOleDbConn As System.Data.OleDb.OleDbConnection
Try
oOleDbConn = New System.Data.OleDb.OleDbConnection
("Provider=ADsDSOObject;" & _
"Data Source=Active Directory Provider;" & _
"User ID=" & sUid & ";" & _
"Password=" & sPwd)
Dim adapter As New System.Data.OleDb.OleDbDataAdapter()
Try
adapter.SelectCommand = New System.Data.OleDb.OleDbCommand
(sQuery, oOleDbConn)
adapter.Fill(oOleDbDataSet)

Catch exOleDb As System.Data.OleDb.OleDbException
debug.print "exOleDb created: " & exOleDb.Message
Dim oErr As System.Data.OleDb.OleDbError
For Each oErr In exOleDb.Errors
debug.print "OleDb Error occured: " & oErr.Message
Next

Catch ex As Exception
debug.print "Error occured in SelectCommand or Fill: " &
ex.Message
oOleDbDataSet = Nothing
End Try

Catch ex As Exception
debug.print "Error occured in New Command: " & ex.Message
oOleDbDataSet = Nothing

Finally
Try
oOleDbConn.Close()
Catch ex As Exception
debug.print "Error occured in Closing Connection: " &
ex.Message
oOleDbDataSet = Nothing
End Try
End Try

Catch ex As Exception
debug.print "Error occured in Dim oOleDbConn As
System.Data.OleDb.OleDbConnection: " & ex.Message
oOleDbDataSet = Nothing
End Try

Return oOleDbDataSet

End Function



Wed, 04 May 2005 00:55:06 GMT  
 ADO.Net to fetch ActiveDirectory this function bugs in Asp.net but works in Vb.n

Hi !!

I've written this generic function that receive in
arguments: an LDAP query, UserId and Password. It creates
connection, fills a dataset and returns the dataset. Used
in my VB code, it works but when I used it in ASP.net code
or as a WebService, it fails each time with the
error: "DB_E_NOTABLE(0x80040E37)."

I tried to change the "Provider=ADsDSOObject" string but
the error message changed so I tried to change the "Data
Source=Active Directory Provider" string and there, the
error message did not change so I'm wondering if the
problem wouldn't the data source...

Is there a way to know if that datasource is available on
my server and how to install it

I'm going to take a guess and say that the account under which the ASP.NET page is running doesn't
have permissions to query AD objects. This would especially be the case if you were using Anonymous
(non) authentication.

If you aren't using at least Basic authentication, try turning it on for your ASP.NET application
and use a valid user ID and password to authenticate.


Microsoft MVP (Visual Basic)



Wed, 04 May 2005 02:28:25 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ADO.NET with ASP.NET using VB.NET

2. Crystal Reports from ASP.NET without compiling VB.NET on SQL/ADO changes

3. VB .Net and ActiveDirectory

4. ADO.Net/ASP.Net strategies for tabulating resultsets

5. Migration to .NET:ASP.NET with ADO

6. Shell function in VB6 COM not working in ASP after installing .Net

7. Bug in VisualStudio.NET editor for VB.NET

8. Know anyone a good .NET/C#/Vb.net/ASP.NET/ADO.NET message board/mailing list/newsletter???????

9. Survey on ASP/VS6.0 versus ASP.NET/VS.NET

10. Bug found in VB.NET - Any work arounds?

11. Visual Basic.NET , ASP or ASP.NET

12. VB6/ASP vs .NET/ASP.NET development

 

 
Powered by phpBB® Forum Software