Platform SDK: Active Directory, ADSI, and Directory Services |
The IADsDeleteOps::DeleteObject method deletes an ADSI object.
HRESULT DeleteObject( Long lnFlags );
This method supports the standard return values, including S_OK for a successful operation. For error code information, see ADSI Error Codes.
The following Visual Basic® code snippet shows how to delete an object and all its children using this method.
Dim cont As IADsContainer Dim ops As IADsDeleteOps Set cont = GetObject("LDAP://OU=sales,DC=Microsoft,DC=com") Set ops = cont ops.DeleteObject (0)
The following C++ code snippet deletes an object and all its children.
IADsContainer *pCont; LPWSTR adsPath = L"LDAP://OU=Sales,DC=Microsoft,DC=com"; HRESULT hr = ADsGetObject(adsPath, IID_IADsContainer, (void**)&pCont); if (FAILED(hr)) exit(hr); IADsDeleteOps *pOps; hr = pCont->QueryInterface(IID_IADsDeleteOps,(void**)&pOps); pCont->Release(); if(FAILED(hr) exit(hr); pOps->DeleteObject(0); pOps-Release();
Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with DSClient).
Windows 95/98: Requires Windows 95 or later (with DSClient).
Header: Declared in Iads.h.
Access Control and Object Deletion, ADSI Error Codes, IADsContainer::Delete, IADsDeleteOps, IADsDeleteOps Interface, IDirectoryObject::DeleteDSObject