Directory Services

IADsPathname::GetEscapedElement

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

HRESULT GetEscapedElement( 
  long lnReserved,
  BSTR bstrInStr,
  BSTR* bstrOutStr
);

Parameters

lnReserved
[in] 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:

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

Return Code Description
S_OK The operation is successful.
E_FAIL The operation has failed.
E_NOTIMPL The method is not supported for this particular provider.

Remarks

This method is used to handle a path that contains 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,Jeff".

Example Code [Visual Basic]

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

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

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

Example Code [VBScript]

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

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

Example Code [VBScript]

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

Example Code [C++]

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

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

Example Code [C++]

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

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