IADsPropertyList::ResetPropertyItem method

The IADsPropertyList::ResetPropertyItem method removes the specified item from the list; that is, from the cache. You can specify the item to be removed by name (as a string) or by index (as an integer).

Syntax

HRESULT ResetPropertyItem(
  VARIANT varEntry
);

Parameters

varEntry

Return Value

This method supports the standard HRESULT return values, including S_OK. For more information and other return values, see ADSI Error Codes.

Remarks

ResetPropertyItem only affects the contents of the cache and does not affect the properties on the actual object in the directory; that is calling SetInfo after calling ResetPropertyItem does not delete the properties on the directory object.

Examples

The following code example shows how to implement ResetPropertyItem.

VB
Dim propList As IADsPropertyList

On Error GoTo Cleanup

Set propList = GetObject("LDAP://DC=Fabrikam,DC=com")

'--- Now modify the cache using PutPropertyItem Set propVal = New PropertyValue '--- Property Value----- propVal.CaseIgnoreString = "Fabrikam" propVal.ADsType = ADSTYPE_CASE_IGNORE_STRING

'--- Property Entry ---- Set propEntry = New PropertyEntry propEntry.Name = "adminDescription" propEntry.Values = Array(propVal) propEntry.ControlCode = ADS_PROPERTY_UPDATE propEntry.ADsType = ADS_CASE_IGNORE_STRING

' --- Property List---- propList.PutPropertyItem (propEntry)

' Commit to the directory. Without this, the changes take place only in the cache. propList.SetInfo

propList.GetInfo Debug.Print " Number of Properties = " & propList.PropertyCount propList.ResetPropertyItem "adminDescription"

' the property count should have been reduced by one. Debug.Print "Number of properties = " & propList.PropertyCount

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

The following code example shows the effect produced by a call to IADsPropertyList::ResetPropertyItem. For more information and the listing of the GetPropertyCache function, see IADsPropertyList. For more information and the listing of the GetNextEntry and PropertyItem functions, see IADsPropertyList::Next and IADsPropertyList::Item respectively.
C++
IADsPropertyList *GetPropertyCache(LPWSTR);
IADsPropertyEntry *GetNextEntry(IADsPropertyList *);
IADsPropertyEntry *PropertyItem(IADsPropertyList *,LPWSTR);
 
void ResetItem(IADsPropertyList *pList, LPWSTR item)
{
    VARIANT var;
    VariantInit(&var);
if(!pList)
{
    item = NULL;
    return;
}

V_BSTR(&amp;var)=SysAllocString(item);
V_VT(&amp;var)=VT_BSTR;

pList-&gt;ResetPropertyItem(var);
VariantClear(&amp;var);

}

void TestResetItem() { IADsPropertyEntry *pEntry = NULL; IADsPropertyList *pList = NULL; long count; BSTR bstr; HRESULT hr;

pList = GetPropertyCache(L"WinNT://myComputer,computer");

hr = pList-&gt;get_PropertyCount(&amp;count);
if(SUCCEEDED(hr))
{
    printf(" Count before item reset : %d\n",count);
}

printf("Walking up the property list before item reset: \n");
for (int i=0; i&lt;count; i++)
{
    pEntry = GetNextEntry(pList);
    hr = pEntry-&gt;get_Name(&amp;bstr);
    if(SUCCEEDED(hr))
    {
        printf("   Name : %S\n",bstr);
        SysFreeString(bstr);
    }
}

pList-&gt;Reset();   // Move the cursor to the beginning of the list.

ResetItem(pList, L"Owner");

hr = pList-&gt;get_PropertyCount(&amp;count);
if(SUCCEEDED(hr))
{
    printf(" Count after item reset : %d\n",count);
}

printf("Walking up the property list after item reset: \n");

for (i=0; i&lt;count; i++)
{
    pEntry = GetNextEntry(pList);
    hr = pEntry-&gt;get_Name(&amp;bstr);
    if(SUCCEEDED(hr))
    {
        printf("   Name : %S\n",bstr);
        SysFreeString(bstr);
    }
}

pEntry-&gt;Release();
pList-&gt;Release();

}

Requirements

   
Windows version Windows Vista Windows Server 2008
Target Platform Windows
Header iads.h
DLL Activeds.dll

See Also

ADSI Error Codes

IADsPropertyList

IADsPropertyList Property Methods

IADsPropertyList::Item

IADsPropertyList::Next