Debugging Hints

Here are some hints for the most common errors experienced by first-time ADSI application writers:

Case-sensitivity
The ProgIDs for ADSI are case sensitive! This is a feature of the underlying namespace because some directory services use case sensitive path names. For example, when you call ADsGetObject with an ADsPath name for the ADSI LDAP provider, use "LDAP:" and not "ldap:".
VT_BOOLEAN for Automation clients
A reminder that VT_BOOLEAN is defined as -1, not 1.
Dim for Automation clients
The Dim() statement sets the upper bound of an array. For example, if you Dim(8), you get an array of size 9 where the first element index is 0 and the last element index is 8. If you initialize just 8 elements of the array and pass the result to an ADSI method expecting an initialized VARIANT, Visual Basic errors out.
Binding to an object over the net
If you are having trouble getting ADsGetObject to get past the server connection and return without error, try accessing the same ADsPath string through a command prompt window, using the "net use <ADsPath>".For example, if
GetObject("WinNT://MyDomain/MyComputer")
 

results in an error, enter the following at the command prompt:

>net use * \\MyDomain\netlogon
 

If you can successfully execute the command prompt syntax, you know your ADsPath is accurate and that your network connections are valid and can continue to look elsewhere for the problem.

Not finding properties for an object
In some implementations of ADSI, there is a direct correspondence between the properties listed in a schema definition for an object and the underlying properties in a directory service. In other implementations of ADSI, the property names included in the mandatory and optional attribute lists of the schema class object may be simulated from various places in the underlying system to supply an easy way to work with these properties. In both cases, when client software calls .get or get_propertyname and a corresponding property does not exist in the underlying directory service, E_ADS_PROPERTY_NOT_FOUND is returned. Whether the underlying directory service property had never been set or there is no underlying value, the client code should handle the result gracefully. For more information about how the property cache works, see Property Cache.