Método IADsPropertyList::ResetPropertyItem (iads.h)

O método IADsPropertyList::ResetPropertyItem remove o item especificado da lista; ou seja, do cache. Você pode especificar o item a ser removido pelo nome (como uma cadeia de caracteres) ou por índice (como um inteiro).

Sintaxe

HRESULT ResetPropertyItem(
  [in] VARIANT varEntry
);

Parâmetros

[in] varEntry

Entrada a ser redefinida.

Retornar valor

Esse método dá suporte aos valores de retorno HRESULT padrão, incluindo S_OK. Para obter mais informações e outros valores retornados, consulte Códigos de erro ADSI.

Comentários

ResetPropertyItem afeta apenas o conteúdo do cache e não afeta as propriedades no objeto real no diretório; que está chamando SetInfo depois de chamar ResetPropertyItem não exclui as propriedades no objeto de diretório.

Exemplos

O exemplo de código a seguir mostra como implementar 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

O exemplo de código a seguir mostra o efeito produzido por uma chamada para IADsPropertyList::ResetPropertyItem. Para obter mais informações e a listagem da função GetPropertyCache , consulte IADsPropertyList. Para obter mais informações e a listagem das funções GetNextEntry e PropertyItem , consulte IADsPropertyList::Next e IADsPropertyList::Item , respectivamente.

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();
}

Requisitos

Requisito Valor
Cliente mínimo com suporte Windows Vista
Servidor mínimo com suporte Windows Server 2008
Plataforma de Destino Windows
Cabeçalho iads.h
DLL Activeds.dll

Confira também

Códigos de erro ADSI

IADsPropertyList

Métodos de propriedade IADsPropertyList

IADsPropertyList::Item

IADsPropertyList::Next