IADsPropertyList::ResetPropertyItem method (iads.h)
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(
[in] VARIANT varEntry
);
Parameters
[in] varEntry
Entry to be reset.
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.
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.
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(&var)=SysAllocString(item);
V_VT(&var)=VT_BSTR;
pList->ResetPropertyItem(var);
VariantClear(&var);
}
void TestResetItem()
{
IADsPropertyEntry *pEntry = NULL;
IADsPropertyList *pList = NULL;
long count;
BSTR bstr;
HRESULT hr;
pList = GetPropertyCache(L"WinNT://myComputer,computer");
hr = pList->get_PropertyCount(&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<count; i++)
{
pEntry = GetNextEntry(pList);
hr = pEntry->get_Name(&bstr);
if(SUCCEEDED(hr))
{
printf(" Name : %S\n",bstr);
SysFreeString(bstr);
}
}
pList->Reset(); // Move the cursor to the beginning of the list.
ResetItem(pList, L"Owner");
hr = pList->get_PropertyCount(&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<count; i++)
{
pEntry = GetNextEntry(pList);
hr = pEntry->get_Name(&bstr);
if(SUCCEEDED(hr))
{
printf(" Name : %S\n",bstr);
SysFreeString(bstr);
}
}
pEntry->Release();
pList->Release();
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Vista |
Minimum supported server | Windows Server 2008 |
Target Platform | Windows |
Header | iads.h |
DLL | Activeds.dll |