Platform SDK: Active Directory, ADSI, and Directory Services

IADsDeleteOps::DeleteObject

The IADsDeleteOps::DeleteObject method deletes an ADSI object.

HRESULT DeleteObject(
  Long lnFlags 
);

Parameters

lnFlags
Reserved for future use.

Return Values

This method supports the standard return values, including S_OK for a successful operation. For error code information, see ADSI Error Codes.

Example Code [Visual Basic]

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)

Example Code [C++]

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();

Requirements

  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.

See Also

Access Control and Object Deletion, ADSI Error Codes, IADsContainer::Delete, IADsDeleteOps, IADsDeleteOps Interface, IDirectoryObject::DeleteDSObject