Condividi tramite


Metodo IADsPropertyList::ResetPropertyItem (iads.h)

Il metodo IADsPropertyList::ResetPropertyItem rimuove l'elemento specificato dall'elenco; ovvero dalla cache. È possibile specificare l'elemento da rimuovere per nome (come stringa) o per indice (come intero).

Sintassi

HRESULT ResetPropertyItem(
  [in] VARIANT varEntry
);

Parametri

[in] varEntry

Voce da reimpostare.

Valore restituito

Questo metodo supporta i valori restituiti HRESULT standard, inclusi i S_OK. Per altre informazioni e altri valori restituiti, vedere Codici di errore ADSI.

Commenti

ResetPropertyItem influisce solo sul contenuto della cache e non influisce sulle proprietà sull'oggetto effettivo nella directory; che chiama SetInfo dopo aver chiamato ResetPropertyItem non elimina le proprietà nell'oggetto directory.

Esempio

Nell'esempio di codice seguente viene illustrato come implementare 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

Nell'esempio di codice seguente viene illustrato l'effetto prodotto da una chiamata a IADsPropertyList::ResetPropertyItem. Per altre informazioni e l'elenco della funzione GetPropertyCache , vedere IADsPropertyList. Per altre informazioni e l'elenco delle funzioni GetNextEntry e PropertyItem, vedere rispettivamente IADsPropertyList::Next e IADsPropertyList::Item.

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

Requisiti

Requisito Valore
Client minimo supportato Windows Vista
Server minimo supportato Windows Server 2008
Piattaforma di destinazione Windows
Intestazione iads.h
DLL Activeds.dll

Vedi anche

Codici di errore ADSI

IADsPropertyList

Metodi di proprietà IADsPropertyList

IADsPropertyList::Item

IADsPropertyList::Next