Platform SDK: Active Directory, ADSI, and Directory Services

IADsPathname::GetEscapedElement

The IADsPathname::GetEscapedElement method is used to escape special characters in the input pathname.

HRESULT IADsPathname::GetEscapedElement(
  LONG lnReserved,
  BSTR bstrInStr,
  BSTR bstrOutStr
);

Parameters

lnReserved
Reserved for future use.
bstrInStr
[in] An input string.
bstrOutStr
[out] An output string.

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_NOTIMPL
The method is not supported for this particular provider.

For other return values, see ADSI Error Codes.

Remarks

This method is useful to handle pathname containing special characters in a unescaped string as input from a user interface. The input string must be a single element (name-value pair) of the path, that is, "CN=Smith,John".

Example Code [Visual Basic]

The following Visual Basic® code snippet shows the effect produced by IADsPathname::GetEscapedElement.

Dim x As New Pathname
 
rdn = x.GetEscapedElement(0, "cn=smith,john")

Now, rdn becomes "cn=smith\,john".

Example Code [VBScript]

The following VBScript code snippet shows the effect produced by IADsPathname::GetEscapedElement.

Dim x 
Set x = CreateObject("Pathname")
rdn = x.GetEscapedElement(0, "cn=smith,john")

Now, rdn becomes "cn=smith\,john".

Example Code [C++]

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

LPWSTR adsPath=L"LDAP://server/cn=jsmith,dc=Microsoft,dc=com";
 
IADsPathname *pPath = GetPathnameObject(adsPath);
BSTR rdn;
HRESULT hr = pPath->GetEscapedElement(0,L"cn=smith,john",&rdn);
 
pPath->Release();

Now rdn become "cn=smith\,john".

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