Bagikan melalui


Antarmuka IADsDeleteOps

AntarmukaIADsDeleteOpsdigunakan dalam rutinitas pengawasan dan pemeliharaan untuk penyimpanan direktori yang mendasar. Ini dapat menghapus objek daun dan seluruh subtree dalam satu operasi.

Jika antarmuka ini tidak didukung, menghapus objek dari Direktori Aktif akan mengharuskan setiap objek yang terkandung dijumlahkan dan dihapus secara rekursif. Dengan antarmuka ini, objek kontainer apa pun, dengan semua objek dan subobjek yang terkandung, dapat dihapus dengan satu operasi.

Contoh kode berikut menghapus kontainer "Eng" dan semua objek anak.

HRESULT hr;
IADsDeleteOps *pDeleteOps;
LPWSTR pwszUsername = NULL;
LPWSTR pwszPassword = NULL;

// Insert code to securely retrieve the pwszUsername and pwszPassword
// or leave as NULL to use the default security context of the 
// calling application.
 
// Bind to the LDAP provider.
hr = ADsOpenObject(L"LDAP://CN=Eng,CN=Users,DC=Fabrikam,DC=Com", 
    pwszUsername,
    pwszPassword,
    0,
    ADS_SECURE_AUTHENTICATION,
    IID_IADsDeleteOps, 
    (void**)&pDeleteOps);
if(S_OK == hr)
{
    // Delete the container and all child objects.
    pDeleteOps->DeleteObject(0);

    // Release the interface.
    pDeleteOps->Release();
}

if(pwszUsername)
{
    SecureZeroMemory(pwszUsername, lstrlen(pwszUsername) * sizeof(TCHAR));
}
if(pwszPassword)
{
    SecureZeroMemory(pwszPassword, lstrlen(pwszPassword) * sizeof(TCHAR));
}

Contoh kode berikut menghapus kontainer "Eng" dan semua objek anak.

Dim DeleteOps As IADsDeleteOps

' Bind to the LDAP provider.
Set DeleteOps = GetObject("LDAP://CN=Eng,CN=Users,DC=Fabrikam,DC=Com")

' Delete the container and all child objects.
DeleteOps.DeleteObject (0)