Directory Services

IADsDeleteOps::DeleteObject

The IADsDeleteOps::DeleteObject method deletes an ADSI object.

HRESULT DeleteObject( 
  Long lnFlags
);

Parameters

lnFlags
Reserved.

Return Values

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

Example Code [Visual Basic]

The following Visual BasicĀ® code shows how to delete an object and its children.

Dim cont As IADsContainer
Dim ops As IADsDeleteOps
 
Set cont = GetObject("LDAP://OU=sales,DC=Fabrikam,DC=com")
Set ops = cont
 
ops.DeleteObject (0)

Example Code [C++]

The following C++ code shows how to delete an object and its children.

IADsContainer *pCont;
LPWSTR adsPath = L"LDAP://OU=Sales,DC=Fabrikam,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

Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Iads.h.

See Also

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