IADsPropertyList::P urgePropertyList 方法 (iads.h)

IADsPropertyList::P urgePropertyList 方法从属性列表中删除所有项。

语法

HRESULT PurgePropertyList();

返回值

此方法支持标准 HRESULT 返回值,包括S_OK。 有关详细信息和其他返回值,请参阅 ADSI 错误代码

注解

调用 PurgePropertyList 方法时,将从缓存中删除所有项。 因此,在此之后调用 GetPropertyItem 将生成错误。 请注意,PurgePropertyList 仅影响缓存的内容,不会影响目录中实际对象的属性;也就是说,在调用 PurgePropertyList 后调用 SetInfo 不会删除目录对象上的属性。

示例

下面的代码示例演示如何实现 IADsPropertyList::P urgePropertyList

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

下面的代码示例演示调用 IADsPropertyList::P urgePropertyList 所产生的效果。 有关 GetPropertyCache 函数和代码示例的详细信息,请参阅 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);
    }
}

要求

   
最低受支持的客户端 Windows Vista
最低受支持的服务器 Windows Server 2008
目标平台 Windows
标头 iads.h
DLL Activeds.dll

另请参阅

ADSI 错误代码

IADsPropertyList

IADsPropertyList 属性方法

IADsPropertyList::GetPropertyItem