Directory Services

IADsPropertyList::PurgePropertyList

The IADsPropertyList::PurgePropertyList method deletes all items from the property list.

HRESULT PurgePropertyList();

Parameters

This method has no parameters.

Return Values

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

Remarks

When the PurgePropertyList method is called, all the items are removed from the cache. Thus, calling GetPropertyItem after that will generate an error. Be aware that PurgePropertyList 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 PurgePropertyList does not delete the properties on the directory object.

Example Code [Visual Basic]

The following code example shows how to implement IADsPropertyList::PurgePropertyList.

Dim propList As IADsPropertyList
 
On Error GoTo Cleanup

Set propList = GetObject("LDAP://dc03/DC=Fabrikam,DC=com")
propList.GetInfo
 
propList.PurgePropertyList
 
'- None of GetPropertyItem should work, because the list is purged.
'- The following line should generate error.
Set propEntry = propList.GetPropertyItem("adminDescription", ADSTYPE_CASE_IGNORE_STRING)

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

	Set propList = Nothing

Example Code [C++]

The following code example shows the effect produced by a call to IADsPropertyList::PurgePropertyList. For more information about the GetPropertyCache function and a code example, see IADsPropertyList.

IADsPropertyList *GetPropertyCache(LPWSTR);
 
void TestPurgePropertyList()
{
	IADsPropertyList *pList;
	pList=GetPropertyCache(L"WinNT://myComputer,computer");
 
	long count;

	if(pList)
	{
		pList->get_PropertyCount(&count);
		printf("Number of properties before purging: %d\n",count);
 
		count = -1;
		pList->PurgePropertyList();
		pList->get_PropertyCount(&count);
		printf("Number of properties after purging: %d\n",count);
}
}

Requirements

Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Iads.h.

See Also

ADSI Error Codes, IADsPropertyList, IADsPropertyList::GetPropertyItem, IADsPropertyList Property Methods