IADsClass interface

The IADsClass interface is designed for managing schema class objects that provide class definitions for any ADSI object. Other schema management interfaces include IADsProperty for attribute definitions and IADsSyntax for attribute syntax.

Methods

The IADsClass interface has these methods.

Method Description
IADsClass::Qualifiers Returns a collection of ADSI objects that describe additional qualifiers for this schema class.

Remarks

Schema objects are organized in the schema container of a given directory. To access an object's schema class, use the object's Schema property (namely, call the IADs::get_Schema property method) to obtain the ADsPath string and use that string to bind to its schema class object.

Examples

The following code example shows how to implement the IADsClass interface.

Dim obj As IADs
Dim cls As IADsClass

On Error GoTo Cleanup

Set obj = GetObject("WinNT://myMachine,computer")
Set cls = GetObject(obj.Schema)
 
' Inspecting mandatory and optional properties.
For Each p In cls.MandatoryProperties
    MsgBox "Must-have: " & p
Next
For Each p In cls.OptionalProperties
    MsgBox "May-have: " & p
Next

Cleanup:
    If (Err.Number<>0) Then
        MsgBox("An error has occurred. " & Err.Number)
    End If
    Set obj = Nothing
    Set cls = Nothing

The following code example shows how to implement the IADsClass interface.

HRESULT hr = S_OK;
IADsClass *pCls = NULL;
IADs *pADs;
BSTR bstrSchema;
VARIANT var;
 
hr = CoInitialize(NULL);
hr = ADsGetObject(L"WinNT://myComputer,computer",
                  IID_IADs,
                  (void**)&pADs);
if (FAILED(hr)) { goto Cleanup;}
 
hr = pADs->get_Schema(&bstrSchema);
pADs->Release();
if(FAILED(hr)) { goto Cleanup; }
 
hr = ADsGetObject(bstrSchema, IID_IADsClass, (void**)&pCls);
if(FAILED(hr)) { goto Cleanup; }
 
VariantInit(&var);
pCls->get_MandatoryProperties(&var);
hr = printVarArray(var);
 
VariantClear(&var);
pCls->get_OptionalProperties(&var);
hr = printVarArray(var);

Cleanup:
    if(pCls)
        pCls->Release();

    if(pADs)
        pADs->Release();

    SysFreeString(bstrSchema);
    VariantClear(&var);
    CoUninitialize();
    return hr;

The following code example shows how to implement the printVarArray function.

HRESULT printVarArray(VARIANT var)
{
    LONG lstart, lend;
    VARIANT varItem;
    HRESULT hr;
    SAFEARRAY *sa = V_ARRAY( &var );
    hr = SafeArrayGetLBound( sa, 1, &lstart );
    hr = SafeArrayGetUBound( sa, 1, &lend );
    VariantInit(&varItem);
    for ( long idx=lstart; idx <= lend; idx++ ) {
        hr = SafeArrayGetElement( sa, &idx, &varItem );
        printf("   %S \n", V_BSTR(&varItem));
        VariantClear(&varItem);
    }
    printf("\n");
    return S_OK;
}

Requirements

   
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Target Platform Windows
Header iads.h

See Also

IADs

IADsContainer

IADsProperty

IADsSyntax

IDispatch