Directory Services |
The IDirectoryObject::DeleteDSObject method deletes a leaf object in a directory tree.
HRESULT DeleteDSObject( LPWSTR pszRDNName );
This method returns the standard return values, including S_OK for a successful operation. For more information and other return values, see ADSI Error Codes.
To delete a container object and its children, use the IADsDeleteOps::DeleteObject method.
The following C/C++ code example shows how to delete a user object.
HRESULT hr; IDirectoryObject *pDirObject=NULL; hr = ADsGetObject(L"LDAP://OU=Sales,DC=Fabrikam,DC=com", IID_IDirectoryObject, (void**) &pDirObject ); if ( SUCCEEDED(hr) ) { hr = pDirObject->DeleteDSObject( L"CN=Jeff Smith" ); pDirObject->Release(); }
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.
IDirectoryObject, IADsDeleteOps::DeleteObject, ADSI Error Codes