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

Parameters

This method has no parameters.

Return Values

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

For more information and other return values, see ADSI Error Codes.

Return Code Description
S_OK The operation succeeded.
E_FAIL The operation failed.
E_ADS_BAD_PATHNAME The path set is not supported by this retrieval format.

Example Code [Visual Basic]

The following Visual Basic code example 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 example 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 example shows the effect produced by calling IADsPathname::RemoveLeafElement.

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

Example Code [C++]

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

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

IADsPathname, ADSI Error Codes