Directory Services

IADsPathname::AddLeafElement

The IADsPathname::AddLeafElement method adds an element to the end of the directory path already set on the Pathname object.

HRESULT AddLeafElement( 
  BSTR bstrLeafElement
);

Parameters

bstrLeafElement
[in] The name of the leaf element.

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.
E_INVALIDARG The user has supplied an invalid dwFormatType parameter.

Example Code [Visual Basic]

The following Visual Basic code example adds the "com" element to "dc=dom,dc=company".

Dim x As New Pathname
x.Set "LDAP://srv1/dc=dom,dc=company", ADS_SETTYPE_FULL
x.AddLeafElement("dc=com")

Example Code [VBScript]

The following VBScript code example adds the "com" element to "dc=dom,dc=company".

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

Example Code [C++]

The following C++ code example shows the effect produced by calling the IADsPathname::AddLeafElement.

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

Example Code [C++]

The pathname is converted to "LDAP://server/cn=jeffsmith,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