IADsDeleteOps 接口
IADsDeleteOps 接口用于基础目录存储的监督和维护例程。 它可以在单个作中删除叶对象和整个子树。
如果不支持此接口,则从 Active Directory 中删除对象需要以递归方式枚举和删除每个包含的对象。 使用此接口,可以使用单个作删除包含的所有对象和子对象的任何容器对象。
下面的代码示例删除“Eng”容器和所有子对象。
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));
}
下面的代码示例删除“Eng”容器和所有子对象。
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)