Platform SDK: Active Directory, ADSI, and Directory Services

Common Errors

All ADSI-specific errors have a hexadecimal form of &H80005xxx. A few that you will encounter most often are outlined in the following table.

ADSI Error Code Description
&H80005000 An invalid ADSI pathname was passed. This error results from passing a poorly formed ADsPath to GetObject when binding to an object.
&H8000500D The ADSI property cannot be found in the property cache. This error happens often when enumerating the MandatoryProperties and OptionalProperties properties of a schema class object.
&H8000500E The ADSI object exists. If you attempt to create an ADSI object with the same name as an existing ADSI object, this error will occur.

For a complete list of ADSI error codes, see Generic ADSI Error Codes.

COM Errors

Since ADSI is composed of COM objects, it stands to reason that it will return standard COM error codes. The following table lists a couple of the most commonly encountered COM error codes encountered in ADSI programming.

COM Error Code Description
&H80004005 Unspecified error. This is probably the most frustrating error you can run into, since its description offers so little to work with. At the very least, you will know where an error occurred in your code.
&H800041E4 Object not found. This error is most likely a result of misspelling the ADsPath string when binding to an object.

See Generic COM Error Codes for a few more examples of COM errors that may occur in ADSI programming.

Win32 Errors

Any error code of the form &H8007xxxx is a standard Win32 error code. If you convert the last four digits from hexadecimal to decimal, you can then look up the error from the Windows 2000® command line:

net helpmsg number

In the command line above, number is the decimal number obtained by converting the last four digits of the error code from hexadecimal. This command line will provide a more useful description of the Win32 error, which can be of great help in debugging your script.