Méthodes de propriété IADsPropertyValue

Les méthodes de propriété de l’interface IADsPropertyValue fournissent l’accès aux propriétés décrites dans le tableau suivant. Pour plus d’informations, consultez méthodes de propriété d’interface.

Propriétés

ADsType

Type de données de la valeur de la propriété, extrait de l’énumération ADSTYPEENUM , de la propriété Value.

Type d’accès : lecture/écriture

Type de données de script : long

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

Booléen

Valeur booléenne.

Type d’accès : lecture/écriture

Type de données de script : long

// C++ method syntax
HRESULT get_Boolean(
  [out] LONG* lnBoolean
);
HRESULT put_Boolean(
  [in] LONG lnBoolean
);

CaseExactString

Chaîne à interpréter. Respecte la casse.

Type d’accès : lecture/écriture

Type de données de script : BSTR

// C++ method syntax
HRESULT get_CaseExactString(
  [out] BSTR* bstrCaseExactString
);
HRESULT put_CaseExactString(
  [in] BSTR bstrCaseExactString
);

CaseIgnoreString

Chaîne à interpréter. Non-respect de la casse.

Type d’accès : lecture/écriture

Type de données de script : BSTR

// C++ method syntax
HRESULT get_CaseIgnoreString(
  [out] BSTR* bstrCaseIgnoreString
);
HRESULT put_CaseIgnoreString(
  [in] BSTR bstrCaseIgnoreString
);

DNString

Chaîne qui identifie le nom unique (chemin d’accès) d’un objet de valeur de service d’annuaire.

Type d’accès : lecture/écriture

Type de données de script : BSTR

// C++ method syntax
HRESULT get_DNString(
  [out] BSTR* bstrDNString
);
HRESULT put_DNString(
  [in] BSTR bstrDNString
);

Integer

Valeur de type entier.

Type d’accès : lecture/écriture

Type de données de script : long

// C++ method syntax
HRESULT get_Integer(
  [out] LONG* lnInteger
);
HRESULT put_Integer(
  [in] LONG lnInteger
);

LargeInteger

Pointeur vers l’interface IDispatch de l’objet qui implémente IADsLargeInteger pour cette valeur.

Type d’accès : lecture/écriture

Type de données de script : IDispatch

// C++ method syntax
HRESULT get_LargeInteger(
  [out] IDispatch** ppLargeInteger
);
HRESULT put_LargeInteger(
  [in] IDispatch* pLargeInteger
);

NumericString

Texte à interpréter. Type numérique.

Type d’accès : lecture/écriture

Type de données de script : BSTR

// C++ method syntax
HRESULT get_NumericString(
  [out] BSTR* bstrNumericString
);
HRESULT put_NumericString(
  [in] BSTR bstrNumericString
);

OctetString

Tableau de variants de caractères d’un octet.

Type d’accès : lecture/écriture

Type de données de script : variante

// C++ method syntax
HRESULT get_OctetString(
  [in] VARIANT* vOctetString
);
HRESULT put_OctetString(
  [in] VARIANT* vOctetString
);

PrintableString

Affichez ou imprimez une chaîne.

Type d’accès : lecture/écriture

Type de données de script : BSTR

// C++ method syntax
HRESULT get_PrintableString(
  [out] BSTR* bstrPrintableString
);
HRESULT put_PrintableString(
  [in] BSTR bstrPrintableString
);

SecurityDescriptor

Pointeur vers l’interface IDispatch de l’objet qui implémente IADsSecurityDescriptor pour cette valeur.

Type d’accès : lecture/écriture

Type de données de script : IDispatch

// C++ method syntax
HRESULT get_SecurityDescriptor(
  [out] IDispatch** ppSecurityDescriptor
);
HRESULT put_SecurityDescriptor(
  [in] IDispatch* pSecurityDescriptor
);

UTCTime

Date du type de _ Date VT exprimée au format de temps universel coordonné (UTC).

Type d’accès : lecture/écriture

Type de données de script : Date

// C++ method syntax
HRESULT get_UTCTime(
  [out] DATE* daUTCTime
);
HRESULT put_UTCTime(
  [in] DATE daUTCTime
);

Remarques

Les propriétés IADsPropertyValue définissent ou récupèrent uniquement une valeur de propriété du type spécifié. Par exemple, la propriété CaseIgnoreString sur un attribut de type ADSTYPE _ , _ comme l’attribut distinguishedName , génère une erreur. La propriété CaseIgnoreString ne fonctionne que sur les attributs de type annonces _ case ignorer la _ _ chaîne. Le tableau suivant mappe la valeur ADSTYPEENUM à la propriété IADsPropertyValue correspondante qui peut être utilisée pour accéder à ce type d’attribut. Si une valeur ADSTYPEENUM n’est pas listée dans ce tableau, elle n’est pas disponible à partir de l’interface IADsPropertyValue . L’interface IADsPropertyValue2 doit être utilisée pour obtenir des données dans les autres formats.

Valeur ADSTYPEENUM Propriété IADsPropertyValue
_chaîne DN _ ADSTYPE DNString
ADSTYPE _ _ chaîne exacte _ CaseExactString
ADSTYPE _ _ ignorer la _ chaîne CaseIgnoreString
_chaîne imprimable _ ADSTYPE PrintableString
_chaîne numérique _ ADSTYPE NumericString
ADSTYPE _ booléen Booléen
_entier ADSTYPE Integer
_chaîne d’octets ADSTYPE _ OctetString
_heure UTC _ ADSTYPE UTCTime
_entier long _ ADSTYPE LargeInteger
_descripteur de sécurité NT ADSTYPE _ _ SecurityDescriptor

Exemples

L’exemple de code suivant montre comment récupérer une propriété à partir de la liste de propriétés.

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

On Error GoTo Cleanup
 
' Retrieve the property list.
Set propList = GetObject("LDAP://dc01/DC=Fabrikam,DC=com")
propList.GetInfo
 
' Retrieve a property entry. If you are certain of the property type,
' replace ADSTYPE_UNKNOWN with the actual property type.
Set propEntry = propList.GetPropertyItem("description", ADSTYPE_UNKNOWN)
 
' Print the property entry values.
For Each v In propEntry.Values
    Set propVal = v
    Select Case propVal.ADsType
        Case ADSTYPE_CASE_EXACT_STRING
            Debug.Print propVal.CaseExactString
        Case ADSTYPE_CASE_IGNORE_STRING
            Debug.Print propVal.CaseIgnoreString
        Case Else
            Debug.Print "Unable to handle a property of type: " & propVal.ADsType
    End Select
    
Next

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

Le code suivant montre comment utiliser IADsPropertyValue :: obtenir _ CaseIgnoreString pour récupérer la valeur de la propriété Description dans une liste de propriétés.

#include <activeds.h>
#include <stdio.h>
 
IADsPropertyList *pList = NULL;
IADsPropertyEntry *pEntry = NULL;
IADsPropertyValue *pVal = NULL;
IADs *pObj = NULL;
VARIANT var, varItem;
BSTR valStr;
IEnumVARIANT *pEnum = NULL;
LONG lstart = 0;
LONG lend = 0;
LONG lADsType = ADSTYPE_UNKNOWN;
 
VariantInit(&var);
VariantInit(&varItem);
 
// Bind to the directory object.
HRESULT hr = ADsGetObject(L"LDAP://dc01/DC=Fabrikam,DC=com",
                          IID_IADsPropertyList,
                          (void**)&pList);

if(FAILED(hr)){goto Cleanup;}

// Initialize the property cache.
hr = pList->QueryInterface(IID_IADs,(void**)&pObj);
if(FAILED(hr)){goto Cleanup;}

pObj->GetInfo();
pObj->Release();
 
// Retrieve the property entry.
hr = pList->GetPropertyItem(CComBSTR("description"), ADSTYPE_CASE_IGNORE_STRING, &var);
pList->Release();
if(FAILED(hr)){goto Cleanup;}

hr = V_DISPATCH(&var)->QueryInterface(IID_IADsPropertyEntry,
                                      (void**)&pEntry);
VariantClear(&var);
if(FAILED(hr)){goto Cleanup;}
 
// Retrieve the value array of the property entry.
hr = pEntry->get_Values(&var);
if(FAILED(hr)){goto Cleanup;}

SAFEARRAY *sa = V_ARRAY( &var );
 
// Retrieve the lower and upper bound. Iterate and print the values.
hr = SafeArrayGetLBound( sa, 1, &lstart );
hr = SafeArrayGetUBound( sa, 1, &lend );
printf(" Property value(s) = ");
for ( long idx=lstart; idx < lend+1; idx++ )    {
    hr = SafeArrayGetElement( sa, &idx, &varItem );
    hr = V_DISPATCH(&varItem)->QueryInterface(IID_IADsPropertyValue,
                                              (void**)&pVal);
    if(FAILED(hr)){goto Cleanup;}

    pVal->get_ADsType(&lADsType);

    switch(lADsType)
    {
        case ADSTYPE_CASE_IGNORE_STRING:
        {
            hr = pVal->get_CaseIgnoreString(&valStr);
            break;
        }
        case ADSTYPE_CASE_EXACT_STRING:
        {
            hr = pVal->get_CaseExactString(&valStr);
            break;
        }
        default:
        {
            valStr = SysAllocString(L"Unable to handle a property of this type");
            break;
        }
    }

    if(FAILED(hr)){goto Cleanup;}
    printf(" %S ", valStr);
    SysFreeString(valStr);
    VariantClear(&varItem);
}
printf("\n");

Cleanup:
    if(pList)
        pList = NULL;

    if(pEntry)
        pEntry = NULL;

    if(pVal)
        pVal = NULL;

    if(pObj)
        pObj = NULL;

    if(pEnum)
        pEnum = NULL;

    SysFreeString(valStr);
    VariantClear(&varItem);
    VariantClear(&var);

Configuration requise

Condition requise Valeur
Client minimal pris en charge
Windows Vista
Serveur minimal pris en charge
Windows Server 2008
En-tête
IADs. h
DLL
Activeds.dll
IID
IID _ IADsPropertyValue est défini en tant que 79FA9AD0-A97C-11D0-8534-00C04FD8D503

Voir aussi

IADsPropertyValue

ADSTYPEENUM

IADsPropertyEntry

IADsPropertyList

IADsPropertyValue2

IADsSecurityDescriptor

IDispatch