다음을 통해 공유


IADsPropertyList::ResetPropertyItem 메서드(iads.h)

IADsPropertyList::ResetPropertyItem 메서드는 목록에서 지정된 항목을 제거합니다. 즉, 캐시에서 입니다. 이름(문자열) 또는 인덱스(정수)로 제거할 항목을 지정할 수 있습니다.

구문

HRESULT ResetPropertyItem(
  [in] VARIANT varEntry
);

매개 변수

[in] varEntry

초기화할 항목입니다.

반환 값

이 메서드는 S_OK 포함하여 표준 HRESULT 반환 값을 지원합니다. 자세한 내용 및 기타 반환 값은 ADSI 오류 코드를 참조하세요.

설명

ResetPropertyItem은 캐시의 내용에만 영향을 미치며 디렉터리의 실제 개체에 대한 속성에는 영향을 주지 않습니다. ResetPropertyItem을 호출한 후 SetInfo를 호출하는 가 디렉터리 개체의 속성을 삭제하지 않습니다.

예제

다음 코드 예제에서는 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

다음 코드 예제에서는 IADsPropertyList::ResetPropertyItem 호출에 의해 생성된 효과를 보여 줍니다. 자세한 내용과 GetPropertyCache 함수 목록은 IADsPropertyList를 참조하세요. 자세한 내용과 GetNextEntryPropertyItem 함수 목록은 각각 IADsPropertyList::NextIADsPropertyList::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();
}

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows Vista
지원되는 최소 서버 Windows Server 2008
대상 플랫폼 Windows
헤더 iads.h
DLL Activeds.dll

추가 정보

ADSI 오류 코드

IADsPropertyList

IADsPropertyList 속성 메서드

IADsPropertyList::Item

IADsPropertyList::Next