Share via


Metodo IADsPropertyList::GetPropertyItem (iads.h)

Il metodo IADsPropertyList::GetPropertyItem recupera l'elemento corrispondente al nome dall'elenco.

Sintassi

HRESULT GetPropertyItem(
  [in]      BSTR    bstrName,
  [in]      LONG    lnADsType,
  [in, out] VARIANT *pVariant
);

Parametri

[in] bstrName

Contiene il nome della proprietà richiesta.

[in] lnADsType

Contiene uno dei valori di enumerazione ADSTYPEENUM che determina il tipo di dati da usare per interpretare la proprietà richiesta. Se il tipo è sconosciuto, questo parametro può essere impostato su ADSTYPE_UNKNOWN. Per i server senza schema, l'utente deve specificare il tipo.

[in, out] pVariant

Indirizzo di una variabile VARIANT allocata dal chiamante. In caso di ritorno , variant contiene il puntatore dell'interfaccia IDispatch dell'oggetto che implementa l'interfaccia IADsPropertyEntry per l'attributo recuperato.

Qualsiasi memoria allocata per questo parametro deve essere rilasciata con la funzione VariantClear quando i dati non sono più necessari.

Valore restituito

Questo metodo supporta i valori restituiti HRESULT standard, inclusi i S_OK. Se l'elemento della proprietà richiesto non viene trovato, il metodo restituisce ADS_PROPERTY_NOT_FOUND. Per altre informazioni e altri valori restituiti, vedere Codici di errore ADSI.

Commenti

La proprietà dell'oggetto IADsPropertyValue restituita da questo metodo che può essere usata dipenderà dal tipo specificato in lnADsType. La tabella seguente esegue il mapping del tipo di dati alla proprietà IADsPropertyEntry appropriata.

valore lnADsType Proprietà IADsPropertyValue da usare
ADSTYPE_INVALID Non disponibile.
ADSTYPE_DN_STRING DNString
ADSTYPE_CASE_EXACT_STRING CaseExactString
ADSTYPE_CASE_IGNORE_STRING CaseIgnoreString
ADSTYPE_PRINTABLE_STRING PrintableString
ADSTYPE_NUMERIC_STRING NumericString
ADSTYPE_BOOLEAN Boolean
ADSTYPE_INTEGER Integer
ADSTYPE_OCTET_STRING OctetString
ADSTYPE_UTC_TIME UTCTime
ADSTYPE_LARGE_INTEGER LargeInteger
ADSTYPE_PROV_SPECIFIC Usare IADsPropertyValue2::GetObjectProperty (VT_ARRAY | VT_UI1).
ADSTYPE_OBJECT_CLASS Non disponibile.
ADSTYPE_CASEIGNORE_LIST Usare IADsPropertyValue2::GetObjectProperty (IADsCaseIgnoreList).
ADSTYPE_OCTET_LIST Usare IADsPropertyValue2::GetObjectProperty (IADsOctetList ).
ADSTYPE_PATH Usare IADsPropertyValue2::GetObjectProperty (IADsPath).
ADSTYPE_POSTALADDRESS Usare IADsPropertyValue2::GetObjectProperty (IADsPostalAddress).
ADSTYPE_TIMESTAMP Usare IADsPropertyValue2::GetObjectProperty (IADsTimestamp ).
ADSTYPE_BACKLINK Usare IADsPropertyValue2::GetObjectProperty (IADsBackLink ).
ADSTYPE_TYPEDNAME Usare IADsPropertyValue2::GetObjectProperty (IADsTypedName ).
ADSTYPE_HOLD Usare IADsPropertyValue2::GetObjectProperty (IADsHold ).
ADSTYPE_NETADDRESS Usare IADsPropertyValue2::GetObjectProperty (IADsNetAddress ).
ADSTYPE_REPLICAPOINTER Usare IADsPropertyValue2::GetObjectProperty (IADsReplicaPointer ).
ADSTYPE_FAXNUMBER Usare IADsPropertyValue2::GetObjectProperty (IADsFaxNumber ).
ADSTYPE_EMAIL Usare IADsPropertyValue2::GetObjectProperty (IADsEmail ).
ADSTYPE_NT_SECURITY_DESCRIPTOR SecurityDescriptor
ADSTYPE_UNKNOWN Non disponibile.
ADSTYPE_DN_WITH_BINARY Usare IADsPropertyValue2::GetObjectProperty (IADsDNWithBinary ).
ADSTYPE_DN_WITH_STRING Usare IADsPropertyValue2::GetObjectProperty (IADsDNWithString ).
 

Esempio

Nell'esempio di codice seguente viene illustrato come recuperare una voce di proprietà usando il metodo GetPropertyItem .

Const ADSTYPE_CASE_IGNORE_STRING = 3
Dim propList As IADsPropertyList
Dim propEntry As IADsPropertyEntry
Dim propVal As IADsPropertyValue

Set propList = GetObject("LDAP://dc01/DC=Fabrikam,DC=com")
propList.GetInfo
 
Set propEntry = propList.GetPropertyItem("dc", ADSTYPE_CASE_IGNORE_STRING)
 
For Each v In propEntry.Values
    Set propVal = v

    ' Use the CaseIgnoreString property because the ADSTYPE_CASE_IGNORE_STRING 
    ' type was requested in GetPropertyItem.
    Debug.Print propVal.CaseIgnoreString
Next

Set propList = Nothing
Set propEntry = Nothing
Set propVal = Nothing

Nell'esempio di codice seguente viene illustrato come recuperare una voce di proprietà usando il metodo GetPropertyItem . Si presuppone che l'interfaccia IADsPropertyList sia stata recuperata correttamente. Per altre informazioni su come caricare la cache delle proprietà, vedere la funzione di esempio GetPropertyCache in IADsPropertyList.

#include <activeds.h>
#include <stdio.h>
 
/////////////////////////////////////////////////////////
// Function to retrieve a specified property entry 
// using the IADsPropertyList::GetPropertyItem method.
/////////////////////////////////////////////////////////
IADsPropertyEntry *GetPropertyItem(
      IADsPropertyList *pList, 
      BSTR entryName,
      long entryType)
{
   IADsPropertyEntry *pEntry;
   VARIANT var;
   VariantInit(&var);

   if(!pList || !entryName)
   {
      _tprintf("Invalid argument...");
      return NULL;
   }
 
   // Get a property entry.
   hr = pList->GetPropertyItem(entryName, entryType, &var);
   hr = V_DISPATCH(&var)->QueryInterface(IID_IADsPropertyEntry,
                                         (void**)&pEntry);
   VariantClear(&var);
 
   return pEntry;
}
 
///////////////////////////////////////////////////////
// Examine a property entry.
///////////////////////////////////////////////////////
IADsPropertyList *pList = NULL;
IADsPropertyEntry *pEntry = NULL;

pList = GetPropertyCache(L"LDAP://dc01/DC=Fabrikam,DC=COM");
 
if(pList)
{
    pEntry = GetPropertyItem(pList, L"dc", ADSTYPE_CASE_IGNORE_STRING);
}

if(pEntry)
{ 
    BSTR nm;
    HRESULT hr = pEntry->get_Name(&nm);
    if(SUCCEEDED(hr))
    {
        printf("Property name = %S\n",nm);
        SysFreeString(nm);
    }
}
 
if(pList)
    pList->Release();
if(pEntry)
    pEntry->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

ADSTYPEENUM

IADsPropertyList

Metodi di proprietà IADsPropertyList

Idispatch

VariantClear