IADsPropertyEntry 屬性方法

IADsPropertyEntry介面的屬性方法可讓您存取下列屬性。 如需屬性方法的詳細資訊,請參閱 Interface Property Methods

屬性

ADsType

Name屬性的資料類型。 資料類型的值定義于 ADSTYPEENUM 列舉中。

存取類型:讀取/寫入

腳本資料類型: LONG

// C++ method syntax
HRESULT get_ADsType(
  [out] LONG* plADsType
);
HRESULT put_ADsType(
  [in] LONG lADsType
);

ControlCode

常數,指定要在具名屬性上執行的作業。 值定義于 ADS_PROPERTY_OPERATION_ENUM 列舉中。

存取類型:讀取/寫入

腳本資料類型: LONG

// C++ method syntax
HRESULT get_ControlCode(
  [out] LONG* pControlCode
);
HRESULT put_ControlCode(
  [in] LONG lnControlCode
);

名稱

屬性專案的名稱。 此名稱應對應至架構中所定義的屬性名稱。

存取類型:讀取/寫入

腳本資料類型: BSTR

// C++ method syntax
HRESULT get_Name(
  [out] BSTR* pbstrName
);
HRESULT put_Name(
  [in] BSTR bstrName
);

VARIANT陣列。 這個陣列中的每個專案都代表具名屬性的值。 這類屬性值是由實作IADsPropertyValue 和 IADsPropertyValue2介面的 ADSI 物件表示。 因此,VARIANT陣列會在實作IADsPropertyValue 和IADsPropertyValue2介面的 ADSI 物件上保存IDispatch介面的指標陣列。

存取類型:讀取/寫入

腳本資料類型: VARIANT

// C++ method syntax
HRESULT get_Values(
  [out] VARIANT* pvValues
);
HRESULT put_Values(
  [in] VARIANT vValues
);

備註

每個屬性方法都支援標準 HRESULT 傳回值,包括S_OK。 如需其他傳回值的詳細資訊,請參閱 ADSI 錯誤碼

範例

下列程式碼範例示範如何從快取擷取具名屬性,並建立新的屬性專案。

 
Dim propList As IADsPropertyList
Dim propEntry As IADsPropertyEntry
Dim propVal As IADsPropertyValue

On Error GoTo Cleanup

'------------------------------------------------------------
'----- Getting IADsPropertyEntry ----------------------------
'------------------------------------------------------------
 
' Create the property list object.
Set propList = GetObject("LDAP://dc01/DC=Fabrikam,DC=com")
propList.GetInfo
 
' Get a named property entry object.
Set propEntry = propList.GetPropertyItem("dc", ADSTYPE_CASE_IGNORE_STRING)

' Insert code to do something with propEntry
Set propEntry = Nothing
 
'------------------------------------------------------------
'---- Setting IADsPropertyEntry -----------------------------
'------------------------------------------------------------
 
' Create a property value object.
Set propVal = New PropertyValue
 
'---- Property Value -----
propVal.CaseIgnoreString = "Fabrikam, Inc - Seattle, WA"
propVal.ADsType = ADSTYPE_CASE_IGNORE_STRING
 
'---- Create a new Property Entry ----
Set propEntry = New PropertyEntry
propEntry.Name = "adminDescription"
propEntry.Values = Array(propVal)
propEntry.ControlCode = ADS_PROPERTY_UPDATE
propEntry.ADsType = ADS_CASE_IGNORE_STRING
 
' ---- Put the newly created property entry to the cache ----
propList.PutPropertyItem (propEntry)
 
' Commit the entry to the directory store.
propList.SetInfo

Cleanup:
    If (Err.Number<>0) Then
        MsgBox("An error has occurred. " & Err.Number)
    End If
    Set propList = Nothing
    Set propEntry = Nothing
    Set propVal = Nothing

下列程式碼範例示範如何從快取取得具名屬性。

#include <activeds.h>
#include <stdio.h>
 
IADsPropertyList *pList = NULL;
IADsPropertyEntry *pEntry = NULL;
IADs *pObj = NULL;
VARIANT var;
long valType = ADSTYPE_CASE_IGNORE_STRING;
 
VariantInit(&var);
 
// Bind to directory object.
HRESULT hr = ADsGetObject(L"LDAP://dc01/DC=Fabrikam,DC=com",
                          IID_IADsPropertyList,
                          (void**)&pList);
if(FAILED(hr)){return;}
 
// Initialize the property cache.
hr = pList->QueryInterface(IID_IADs,(void**)&pObj);
if(FAILED(hr)){goto Cleanup;}
pObj->GetInfo();
pObj->Release();
 
// Get a property entry.
hr = pList->GetPropertyItem(CComBSTR("description"), valType, &var);
pList->Release();
if(FAILED(hr)){goto Cleanup;}
hr = V_DISPATCH(&var)->QueryInterface(IID_IADsPropertyEntry,
                                      (void**)&pEntry);
VariantClear(&var);
if(FAILED(hr)){goto Cleanup;}
 
// Get the name and the type of the property entry.
BSTR nm = NULL;
hr = pEntry->get_Name(&nm);
printf("Property name = %S\n",nm);
VariantClear(&var);
long at;
hr = pEntry->get_ADsType(&at);
printf("Property type = %d\n",a);

Cleanup:
    if(nm)
        SysFreeString(nm);

    if(pList)
        pList->Release();

    if(pEntry)
        pEntry->Release();

    if(pObj)
        pObj->Release();

    VariantClear(&var);

規格需求

需求
最低支援的用戶端
Windows Vista
最低支援的伺服器
Windows Server 2008
標頭
Iads.h
DLL
Activeds.dll
IID
IID_IADsPropertyEntry定義為 05792C8E-941F-11D0-8529-00C04FD8D503

另請參閱

ADS_PROPERTY_OPERATION_ENUM

ADSI 錯誤碼

ADSTYPEENUM

IADsPropertyEntry

IADsPropertyValue

IADsPropertyValue2

IDispatch