Platform SDK: Active Directory, ADSI, and 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 IADsPathname::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:

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

For other return values, see ADSI Error Codes.

Example Code [Visual Basic]

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

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

Now the pathname becomes "LDAP://server/cn=jsmith,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