DirectoryService - Exceptions

G

Guest

Hi
Is there a way to find out what COMException is being thrown as a result of
an operation, for example

DirectoryEntry newUser = entry.Children.Add(<newuser_CNname>, "user")

I suppose this one would throw a COMException if a duplicate CNname is
found. But if other operations, coming after this one, would also throw
COMExceptions, then how can I differentiate the COMException thrown by each
operation as the COMException error message doesn't seems to provide
specific information. Do I need to throw ApplicationException in this case?
In order to do that, do I need to define my own class of
ApplicationException?

TIA

--
 
J

Joe Kaplan \(MVP - ADSI\)

Are you saying you want to know what the COM error was or want more details
than what it provides you?

The COMException has an ErrorCode property that you can use to get the exact
error codes, but they aren't much more helpful than the error messages
except for handling them programmatically.

If you want more details about the underlying failure, the only way I know
is to p/invoke ADsGetLastError. I might have a sample somewhere if I look
around.

Throwing an ApplicationException won't help you unless I totally don't
understand what you want to do.

Joe K.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top