Platform SDK: Active Directory, ADSI, and Directory Services |
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).
HRESULT ResetPropertyItem( VARIANT VarData );
This method supports the standard HRESULT return values, including S_OK. For other return values, see ADSI Error Codes.
The following Visual Basic code snippet shows how ResetPropertyItem is used.
Dim propList As IADsPropertyList Set propList = GetObject("LDAP://DC=Microsoft,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
The following C++ code snippet shows the effect produced by a call to IADsPropertylist::ResetItem. See IADsPropertyList for the listing of the GetPropertyCache function. See IADsPropertyList::Next and IADsPropertyList::Item for the listing of PropertyNext and PropertyItem, respectively.
IADsPropertyList *GetPropertyCache(LPWSTR); IADsPropertyEntry *PropertyNext(IADsPropertyList *); IADsPropertyEntry *PropertyItem(IADsPropertyList *,LPWSTR); void ResetItem(IADsPropertyList *pList,LPWSTR item) { VARIANT var; VariantInit(&var); V_BSTR(&var)=SysAllocString(item); V_VT(&var)=VT_BSTR; pList->ResetPropertyItem(var); VariantClear(&var); } void TestResetItem() { IADsPropertyEntry *pEntry; IADsPropertyList *pList; long count; BSTR bstr; pList=GetPropertyCache(L"WinNT://myComputer,computer"); pList->get_PropertyCount(&count); printf(" Count before item reset : %d\n",count); printf("Walking up the property list before item reset: \n"); for (int i=0; i<count; i++) { pEntry = PropertyNext(pList); pEntry->get_Name(&bstr); printf(" Name : %S\n",bstr); } pList->Reset(); // move the cursor to the beginning of the list. ResetItem(pList,L"Owner"); pList->get_PropertyCount(&count); printf(" Count after item reset : %d\n",count); printf("Walking up the property list after item reset: \n"); for (i=0; i<count; i++) { pEntry = PropertyNext(pList); pEntry->get_Name(&bstr); printf(" Name : %S\n",bstr); } pEntry->Release(); pList->Release(); SysFreeString(bstr); }
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.
ADSI Error Codes, IADsPropertyList, IADsPropertyList::Item, IADsPropertyList::Next, IADsPropertyList Property Methods