Platform SDK: Active Directory, ADSI, and Directory Services

IADsPathname::RemoveLeafElement

The IADsPathname::RemoveLeafElement method removes the last element from the directory path that has been set on the Pathname object.

HRESULT IADsPathname::RemoveLeafElement();

Parameters

None.

Return Values

This method supports the standard return values, as well as the following:

S_OK
The operation is successful.
E_FAIL
The operation has failed.
E_ADS_BAD_PATHNAME
The pathname set is not supported this retrieval format.

For other return values, see ADSI Error Codes.

Example Code [Visual Basic]

The following Visual Basic® code snippet shows the effect produced by calling this method.

Dim x As New Pathname
x.Set "LDAP://srv1/dc=dom,dc=company,dc=com",ADS_SETTYPE_FULL
x.RemoveLeafElement      ' now x is "LDAP://srv1/dc=company,dc=com".

Example Code [VBScript]

The following VBScript code snippet shows the effect produced by calling this method.

Dim x
Const ADS_SETTYPE_FULL =1 
 
Set x = CreateObject("Pathname")
x.Set "LDAP://srv1/dc=dom,dc=company,dc=com",ADS_SETTYPE_FULL
x.RemoveLeafElement      ' now x is "LDAP://srv1/dc=company,dc=com".

Example Code [C++]

The following C++ code snippet shows the effect produced by calling the IADsPathname::RemoveLeafElement.

LPWSTR adsPath=L"LDAP://server/cn=jsmith,dc=Microsoft,dc=com";
 
IADsPathname *pPath = GetPathnameObject(adsPath);
HRESULT hr = pPath->RemoveLeafElement();
 
pPath->Release();

Now the pathname becomes "LDAP://server/dc=Microsoft,dc=com".

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

IADsPathname, ADSI Error Codes