Metodo IADs::P ut (iads.h)

Il metodo IADs::P ut imposta i valori di un attributo nella cache degli attributi ADSI.

Sintassi

HRESULT Put(
  [in] BSTR    bstrName,
  [in] VARIANT vProp
);

Parametri

[in] bstrName

Contiene un BSTR che specifica il nome della proprietà.

[in] vProp

Contiene un valore VARIANT che specifica i nuovi valori della proprietà.

Valore restituito

Questo metodo supporta i valori restituiti standard, nonché i seguenti.

Per altre informazioni e altri valori restituiti, vedere Codici di errore ADSI.

Commenti

L'assegnazione dei nuovi valori di proprietà, eseguita da Put viene eseguita solo nella cache delle proprietà. Per propagare le modifiche all'archivio directory, chiamare IADs::SetInfo nell'oggetto dopo aver chiamato Put.

Per modificare i valori delle proprietà oltre un'assegnazione semplice, usare Put per aggiungere o rimuovere un valore da una matrice esistente di valori di attributo.

Esempio

Nell'esempio di codice seguente viene illustrato come usare il metodo IADs::P ut .

Dim x As IADs
On Error GoTo Cleanup

Set x = GetObject("LDAP://CN=JeffSmith,CN=Users,DC=Fabrikam, DC=Com") 
x.Put "givenName", "Jeff"
x.Put "sn", "Smith"
x.SetInfo    ' Commit to the directory.

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

Nell'esempio di codice seguente viene illustrato come usare il metodo IADs::P ut .

HRESULT hr;
IADs *pADs = NULL;
LPWSTR pszADsPath = L"LDAP://CN=JeffSmith,CN=Users,DC=Fabrikam,DC=com";
 
CoInitialize(NULL);
 
//////////////////////////////////
// Modifying attributes using IADs
//////////////////////////////////
hr = ADsGetObject(pszADsPath, IID_IADs, (void**) &pADs);
 
if(SUCCEEDED(hr))
{ 
    VARIANT var;
    VariantInit(&var);
     
    // Set the first name.
    V_BSTR(&var) = SysAllocString(L"Jeff");
    V_VT(&var) = VT_BSTR;
    hr = pADs->Put(CComBSTR("givenName"), var);
     
    // Set the last name.
    VariantClear(&var);
    V_BSTR(&var) = SysAllocString(L"Smith");
    V_VT(&var) = VT_BSTR;
    hr = pADs->Put(CComBSTR("sn"), var); 
    VariantClear(&var);

    // Other Telephones.
    LPWSTR pszPhones[] = { L"425-707-9790", L"425-707-9791" };
    DWORD dwNumber = sizeof(pszPhones)/sizeof(LPWSTR);
    hr = ADsBuildVarArrayStr(pszPhones, dwNumber, &var);
    hr = pADs->Put(CComBSTR("otherTelephone"), var); 
    VariantClear(&var);
     
    // Commit the change to the directory.
    hr = pADs->SetInfo();
    pADs->Release();
}

CoUninitialize();

Requisiti

   
Client minimo supportato Windows Vista
Server minimo supportato Windows Server 2008
Piattaforma di destinazione Windows
Intestazione iads.h
DLL Activeds.dll

Vedi anche

ID

ID::Get

ID::GetEx

ID::P utEx

Cache delle proprietà