Exists is a shared (static) method on the DirectoryEntry
class. You should call it like this:
If DirectoryEntry.Exists("LDAP://<your object DN>") Then
'... do something here
It does not work on an instance of a DirectoryEntry.
If you have already instantiated a DirectoryEntry object
and just want to force the bind operation in order to see
if the object exists, then you just need to call one of
the properties or methods that will force a bind. Doing
something like this will work:
Dim myEntry as New DirectoryEntry("LDAP://<your object
Catch e as System.Runtime.InteropServices.COMException
'if the DN does not exist or is an invalid syntax
'e.ErrorCode will equal -2147016656 (no such object)
'or -2147016654 (invalid syntax)
'you can test for either of these results explicitly
'if you want know the exact reason why the object
'wasn't found. The "no such object" error code is
'probably the one you are most interested in.
I hope that helps.
>I would like to test to see if a specific user exists.
Quote:>frlrfSystemDirectoryServices.asp, there is a method
Exists(). I am unable
>to use it.
>I receive a compile error of "No overload for
method 'Exists' takes '0'
>arguments" when trying this:
> // Do this...
> //Do that
>I am able to read from AD otherwise. Thanks for any