Share via


Metodo IADsAccessControlList::get__NewEnum (iads.h)

Il metodo IADsAccessControlList::get__NewEnum viene usato per ottenere un oggetto enumeratore per l'ACL per enumerare gli ACL.

Sintassi

HRESULT get__NewEnum(
  [out] IUnknown **retval
);

Parametri

[out] retval

Puntatore a puntatore all'interfaccia IUnknown usata per recuperare l'interfaccia IEnumVARIANT in un oggetto enumeratore per l'ACL.

Valore restituito

Questo metodo restituisce i valori restituiti standard, inclusi S_OK e E_FAIL. Per altre informazioni sugli altri valori restituiti, vedere Codici di errore ADSI.

Commenti

Tenere presente che ci sono due caratteri di sottolineatura in get__NewEnum.

Esempio

Nell'esempio di codice seguente viene eseguita una chiamata implicita al metodo get__NewEnum nell'esecuzione del ciclo For Each .

Dim Dacl As IADsAccessControlList
Dim ace As IADsAccessControlEntry

On Error GoTo Cleanup

' Get DACL. Code omitted.

' Display the trustees for each of the ACEs
For Each ace In Dacl 
    Debug.Print ace.trustee
Next ace

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

Nell'esempio di codice seguente viene illustrato come enumerare gli ACL usando IADsAccessControlList::get__NewEnum.

HRESULT ListTrustees(IADsAccessControlList *pACL)
{
    IEnumVARIANT *pEnum = NULL;
    LPUNKNOWN     pUnk = NULL;
    ULONG  lFetch = 0;
    BSTR    bstr = NULL;
    IADsAccessControlEntry *pACE = NULL;
    IDispatch *pDisp = NULL;
    VARIANT var;
    HRESULT hr = S_OK;
    
    VariantInit(&var);
     
    hr = pACL->get__NewEnum(&pUnk);
    if (FAILED(hr)){goto Cleanup;}
    
    hr = pUnk->QueryInterface( IID_IEnumVARIANT, (void**) &pEnum );
    pUnk->Release();
    if (FAILED(hr)){goto Cleanup;}
     
    hr = pEnum->Next( 1, &var, &lFetch );
    if (FAILED(hr)){goto Cleanup;}
     
    while( hr == S_OK )
    {
        if ( lFetch == 1 )
        {
            if ( VT_DISPATCH != V_VT(&var) )
            {
                goto Cleanup;
            }
            pDisp = V_DISPATCH(&var);
            /////////////////////////
            // Get the individual ACE
            /////////////////////////
            hr = pDisp->QueryInterface( IID_IADsAccessControlEntry,(void**)&pACE ); 
            if ( SUCCEEDED(hr) )
            {
                pACE->get_Trustee(&bstr);
                printf("\n %S:\n", bstr);
                //ACE manipulation here
                SysFreeString(bstr);
                pACE->Release();
            }
            pACE->Release();
            pDisp->Release();
            VariantClear(&var);
        }
        hr = pEnum->Next( 1, &var, &lFetch );
    }
    Cleanup:        
        if(pEnum) pEnum->Release();
        if(pUnk) pUnk->Release();
        if(bstr) SysFreeString(bstr);
        if(pACE) pACE->Release();
        VariantClear(&var);
        return hr;
}

Requisiti

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

Vedi anche

IADsAccessControlEntry

IADsAccessControlList

IADsSecurityDescriptor

IEnumVARIANT