Platform SDK: Active Directory, ADSI, and Directory Services

Accessing Attributes with ADSI

You can use the IADs::Get or the IADs::GetEx functions to access attribute values. Both functions return a variant value. These functions are only available for directories that support a schema. When using a directory without a schema you must use the IADsProperty interfaces to manipulate data.

IADs::Get returns a variant which may or may not be a variant array depending on the number of values returned by the server. For example, if only one value is returned from the server, regardless of whether it is a single or multiple valued attribute, IADs::Get returns a non-variant array. On the other hand, if more than one value is returned, a variant array is returned.

IADs::Get can also return a variant which contains another COM object (via IDispatch).

In other words, IADs::Get always returns one of three types of variant:

Note  The Visual Basic Scripting Language supports variant and variant arrays of variants. Hence, you cannot use VBScript to read binary data. The ADSI SDK includes a sample program called the Octet String Converter that allows you to read binary data from VBScript. Visual Basic does not have this limitation.