Share via


IADsPropertyList::ResetPropertyItem-Methode (iads.h)

Die IADsPropertyList::ResetPropertyItem-Methode entfernt das angegebene Element aus der Liste. d. h. aus dem Cache. Sie können das zu entfernende Element anhand des Namens (als Zeichenfolge) oder des Indexes (als ganze Zahl) angeben.

Syntax

HRESULT ResetPropertyItem(
  [in] VARIANT varEntry
);

Parameter

[in] varEntry

Der zurückzusetzende Eintrag.

Rückgabewert

Diese Methode unterstützt die HRESULT-Standardrückgabewerte , einschließlich S_OK. Weitere Informationen und andere Rückgabewerte finden Sie unter ADSI-Fehlercodes.

Hinweise

ResetPropertyItem wirkt sich nur auf den Inhalt des Caches und nicht auf die Eigenschaften des tatsächlichen Objekts im Verzeichnis aus. durch aufrufen von SetInfo nach dem Aufrufen von ResetPropertyItem werden die Eigenschaften für das Verzeichnisobjekt nicht gelöscht.

Beispiele

Das folgende Codebeispiel zeigt, wie ResetPropertyItem implementiert wird.

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

Das folgende Codebeispiel zeigt den Effekt, der durch einen Aufruf von IADsPropertyList::ResetPropertyItem erzeugt wird. Weitere Informationen und die Auflistung der GetPropertyCache-Funktion finden Sie unter IADsPropertyList. Weitere Informationen und die Auflistung der Funktionen GetNextEntry und PropertyItem finden Sie unter IADsPropertyList::Next und 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();
}

Anforderungen

Anforderung Wert
Unterstützte Mindestversion (Client) Windows Vista
Unterstützte Mindestversion (Server) Windows Server 2008
Zielplattform Windows
Kopfzeile iads.h
DLL Activeds.dll

Weitere Informationen

ADSI-Fehlercodes

IADsPropertyList

Methoden der IADsPropertyList-Eigenschaft

IADsPropertyList::Item

IADsPropertyList::Next