PC Review


Reply
 
 
Adam Hafner
Guest
Posts: n/a
 
      25th Aug 2003
I am attempting to use the System.Data.OleDb namespace to
connect to an Active Directory running under Win2000. I
have initialized the OleDbConnection with a connection
string of "Provider=ADSDSOObject;". I have a simple query
string as follows: "SELECT sAMAccountName
FROM 'LDAP://mydomain.com/' WHERE objectClass = 'User'"

I receive an errror when I try to read the
results: "OleDbDataReader result = myCommand.ExecuteReader
(CommandBehavior.CloseConnection);"

The error states: DB_E_ERRORSINCOMMAND(0x80040E14) - An
unhandled exception occurred during the execution of the
current web request.

Any samples or suggestions are greatly appreciated.

Thanks!
 
Reply With Quote
 
 
 
 
Paul Clement
Guest
Posts: n/a
 
      26th Aug 2003
On Mon, 25 Aug 2003 12:09:12 -0700, "Adam Hafner" <(E-Mail Removed)> wrote:

¤ I am attempting to use the System.Data.OleDb namespace to
¤ connect to an Active Directory running under Win2000. I
¤ have initialized the OleDbConnection with a connection
¤ string of "Provider=ADSDSOObject;". I have a simple query
¤ string as follows: "SELECT sAMAccountName
¤ FROM 'LDAP://mydomain.com/' WHERE objectClass = 'User'"
¤
¤ I receive an errror when I try to read the
¤ results: "OleDbDataReader result = myCommand.ExecuteReader
¤ (CommandBehavior.CloseConnection);"
¤
¤ The error states: DB_E_ERRORSINCOMMAND(0x80040E14) - An
¤ unhandled exception occurred during the execution of the
¤ current web request.
¤
¤ Any samples or suggestions are greatly appreciated.

In addition to the other suggestions, I would first try to trap the error using Try...Catch. I
haven't heard anything that indicates that the AD provider is not supported by the OLEDB .NET
provider.

There are different ways to query but I've typically used the default naming context. In my instance
it's: LDAP://DC=testdomain,DC=org but you should be able to use DirectoryServices to extract this
information.

Also, I would try removing the CommandBehavior.CloseConnection argument to see if it makes any
difference.


Paul ~~~ (E-Mail Removed)
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
Adam Hafner
Guest
Posts: n/a
 
      26th Aug 2003
Paul,

Thanks for responding to my post. I noticed that you had
similiar problems with ADO.NET from your posting on .Net
247
(http://www.dotnet247.com/247referenc...25/127645.aspx
). Did you ever get the problems with ADO resolved or did
you use directory services in place of ADO to query AD?
I've used System.DirectoryServices with some success. I
have code that uses
System.DirectoryServices.DirectorySearcher and runs
several times in a row before it stops working. For
instance, I run the code and retrieve results 10 times in
a row. I then wait several minutes and attempt to run the
code again and it hangs. Eventually, the method returns a
message:

An unhandled exception of
type 'System.Runtime.InteropServices.COMException'
occurred in system.directoryservices.dll

Additional information: Unknown error (0x80005000)

I reboot my development box and the code runs fine again
(for awhile). Maybe I'm hitting a connection limit? I'm
not sure what system services (on either the client or
server side) that System.DirectoryServices depend on?
When I reboot, something is getting reset that causes the
code to run again. This is why I began looking at ADO.NET
as an alternative.

Thanks!

>-----Original Message-----
>On Mon, 25 Aug 2003 12:09:12 -0700, "Adam Hafner"

<(E-Mail Removed)> wrote:
>
>¤ I am attempting to use the System.Data.OleDb namespace

to
>¤ connect to an Active Directory running under Win2000.

I
>¤ have initialized the OleDbConnection with a connection
>¤ string of "Provider=ADSDSOObject;". I have a simple

query
>¤ string as follows: "SELECT sAMAccountName
>¤ FROM 'LDAP://mydomain.com/' WHERE objectClass = 'User'"

>¤ I receive an errror when I try to read the
>¤ results: "OleDbDataReader result =

myCommand.ExecuteReader
>¤ (CommandBehavior.CloseConnection);"

>¤ The error states: DB_E_ERRORSINCOMMAND(0x80040E14) -

An
>¤ unhandled exception occurred during the execution of

the
>¤ current web request.

>¤ Any samples or suggestions are greatly appreciated.
>
>In addition to the other suggestions, I would first try

to trap the error using Try...Catch. I
>haven't heard anything that indicates that the AD

provider is not supported by the OLEDB .NET
>provider.
>
>There are different ways to query but I've typically

used the default naming context. In my instance
>it's: LDAP://DC=testdomain,DC=org but you should be able

to use DirectoryServices to extract this
>information.
>
>Also, I would try removing the

CommandBehavior.CloseConnection argument to see if it
makes any
>difference.
>
>
>Paul ~~~ (E-Mail Removed)
>Microsoft MVP (Visual Basic)
>.
>

 
Reply With Quote
 
Adam Hafner
Guest
Posts: n/a
 
      26th Aug 2003
Roy,

Thanks for your reply. I haven't used the
System.Management object. Would I use it in a similiar
manner as System.DirectoryServices? If so, I've had some
success with that (see my post below).

Thanks!

>-----Original Message-----
>Why not use the system.Management object model?
>
>
>--
>Regards,
>
>Roy Osherove
>http://www.iserializable.com
>---------------------------------------------
>
>"Adam Hafner" <(E-Mail Removed)> wrote in message
>news:280401c36b3c$5e8a0820$(E-Mail Removed)...
>> I am attempting to use the System.Data.OleDb namespace

to
>> connect to an Active Directory running under Win2000. I
>> have initialized the OleDbConnection with a connection
>> string of "Provider=ADSDSOObject;". I have a simple

query
>> string as follows: "SELECT sAMAccountName
>> FROM 'LDAP://mydomain.com/' WHERE objectClass = 'User'"
>>
>> I receive an errror when I try to read the
>> results: "OleDbDataReader result =

myCommand.ExecuteReader
>> (CommandBehavior.CloseConnection);"
>>
>> The error states: DB_E_ERRORSINCOMMAND(0x80040E14) - An
>> unhandled exception occurred during the execution of

the
>> current web request.
>>
>> Any samples or suggestions are greatly appreciated.
>>
>> Thanks!

>
>
>.
>

 
Reply With Quote
 
Adam Hafner
Guest
Posts: n/a
 
      26th Aug 2003
Marc,

Thanks for the reply. I tried the variations on the SQL
syntax you suggested below, but had the same outcome. I
thought maybe I was experiencing a security problem, but
I would think the error returned would indicate this. I
will continue to try some other variations.

Thanks!
>-----Original Message-----
>>I am attempting to use the System.Data.OleDb namespace

to
>>connect to an Active Directory running under Win2000. I
>>have initialized the OleDbConnection with a connection
>>string of "Provider=ADSDSOObject;". I have a simple

query
>>string as follows: "SELECT sAMAccountName
>>FROM 'LDAP://mydomain.com/' WHERE objectClass = 'User'"

>
>I would try two things:
>
>1) Do a SELECT on different properties - e.g.
>
>SELECT name,cn FROM 'LDAP://mydomain.com/' WHERE

objectClass = 'User'"
>
>2) Do the SELECT on an existing container
>
>SELECT sAMAccountName FROM
>'LDAP://mydomain.com/cn=Users,dc=mydomain,dc=com' WHERE

objectClass =
>'User'"
>
>Not sure - but you might need to specify your domain

using the dc=
>notation, rather than the way you're doing it now - if

you need to
>specify something just after the LDAP:// moniker, it

would have to be
>a SERVER (full DNS server name):
>
>Try:
>SELECT sAMAccountName FROM 'LDAP://dc=mydomain,dc=com'

WHERE
>objectClass = 'User'"
>
>or:
>SELECT sAMAccountName FROM
>'LDAP://myserver.mydomain.com/dc=mydomain,dc=com' WHERE

objectClass =
>'User'"
>
>
>Does any of that help?
>
>Marc
>=========================================================

=======
>Marc Scheuner May The Source Be

With You!
>Bern, Switzerland m.scheuner(at)

inova.ch
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query regarding ADSI Edit tool Pete Halasovski Microsoft Windows 2000 Active Directory 6 9th Jan 2009 11:46 PM
ADSI Query fails with unspecified error sjoshi Microsoft C# .NET 4 2nd May 2006 12:49 PM
ADSI query Concatenate? =?Utf-8?B?Sm9yZHk=?= Microsoft Dot NET 0 30th Mar 2006 05:02 PM
ADSI Query to filter out machine accounts in the domain Prasad Karunakaran Microsoft C# .NET 12 12th Mar 2004 08:03 PM
ADSI/LDAP Query khaja shaik Microsoft ASP .NET 0 21st Jul 2003 11:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:00 PM.