Platform SDK: Active Directory, ADSI, and Directory Services

IADsPropertyValue::Clear

The IADsPropertyValue::Clear method clears the current values of the property value object.

HRESULT IADsPropertyValue::Clear(
  void
);

Parameters

None

Return Values

This method support the standard HRESULT return values, including S_OK. For other return values, see ADSI Error Codes.

Example Code [Visual Basic]

The following Visual Basic code snippet shows how to use IADsPropertyValue::Clear to clear the value of the "description" property from a property list.

Dim propList As IADsPropertyList
Dim propEnty As IADsPropertyEntry
Dim propVal As IADsPropertyValue
 
' get the property list
Set propList = GetObject("LDAP://dc01/DC=Microsoft,DC=com")
propList.GetInfo
 
' get a property entry
Set propEntry = propList.GetPropertyItem("description", ADSTYPE_CASE_IGNORE_STRING)
 
' print all the values of the property entry and 
' clears them afterwards.
For Each v In propEntry.Values
    Set propVal = v
    Debug.Print propVal.CaseIgnoreString
    propVal.Clear
Next

Example Code [C++]

The following C++ code snippet shows how to use IADsPropertyValue::Clear to clear the value of the "description" property from a property list.

#include <activeds.h>
#include <stdio.h>
 
IADsPropertyList *pList;
IADsPropertyEntry *pEntry;
IADsPropertyValue *pVal;
IADs *pObj;
VARIANT var, varProp, varItem;
long valType = ADSTYPE_CASE_IGNORE_STRING;
BSTR valStr;
IEnumVARIANT *pEnum = NULL;
LONG lstart, lend;
 
VariantInit(&var);
VariantInit(&varItem);
 
// bind to directory object
HRESULT hr = ADsGetObject(L"LDAP://dc01/DC=Microsoft,DC=com",
                          IID_IADsPropertyList,
                          (void**)&pList);
 
// initialize the property cache
hr = pList->QueryInterface(IID_IADs,(void**)&pObj);
pObj->GetInfo();
pObj->Release();
 
// get a property entry
hr = pList->GetPropertyItem(L"description", valType, &var);
pList->Release();
hr = V_DISPATCH(&var)->QueryInterface(IID_IADsPropertyEntry,
                                      (void**)&pEntry);
VariantClear(&var);
 
// get the value array of the property entry
hr = pEntry->get_Values(&var);
SAFEARRAY *sa = V_ARRAY( &var );
 
// Get the lower and upper bound and iterate and print the values
hr = SafeArrayGetLBound( sa, 1, &lstart );
hr = SafeArrayGetUBound( sa, 1, &lend );
printf(" Property value(s) = ");
for ( long idx=lstart; idx < lend+1; idx++ )    {
    hr = SafeArrayGetElement( sa, &idx, &varItem );
    hr = V_DISPATCH(&varItem)->QueryInterface(IID_IADsPropertyValue,
                                              (void**)&pVal2);
    VariantClear(&varItem);
    hr = pVal->get_CaseIgnoreString(&valStr);
    printf(" %S ", valStr);     // write out description, if specified
 
    valString = L"";
    hr = pVal->Clear();
    hr = pVal->get_CaseIgnoreString(&valStr);
    printf(" %S ", valStr);        // the string is empty.
}
printf("\n");
VariantClear(&var);

Requirements

  Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with DSClient).
  Windows 95/98: Requires Windows 95 or later (with DSClient).
  Header: Declared in Iads.h.

See Also

ADSI Error Codes, IADsPropertyValue, IADsPropertyValue Property Methods