Platform SDK: Active Directory, ADSI, and Directory Services |
The property methods of the IADsPathname interface get or set the properties described in the following table. For more information, see Interface Property Methods.
Property | Description |
---|---|
EscapedMode
[Visual Basic] [C++] |
Examine or specify how escaped characters are handled in a pathname. The options are defined in ADS_ESCAPE_MODE_ENUM. |
EscapedMode represents a state. You can turn it on or off, by setting it to ADS_ESCAPEDMODE_ON or ADS_ESCAPEDMODE_OFF/ADS_ESCAPEDMODE_OFF_EX, at any time. Once it is turned on (or off), all subsequent retrievals produce escaped or unescaped path strings.
In ADSI only the IADsPathname is capable of unescaping paths. All other ADSI interfaces always return escaped ones. The default state of EscapedMode is ADS_ESCAPEDMODE_DEFAULT as defined in ADS_ESCAPE_MODE_ENUM.
The following Visual Basic® code snippet shows how to use the EscapedMode property turn on/off escaping of the following three special characters: "=",",", and "/".
Dim path As New Pathname path.Set "CN=foo\=bar\,\/*", ADS_SETTYPE_DN path.EscapedMode = ADS_ESCAPEDMODE_ON MsgBox path.Retrieve(ADS_FORMAT_WINDOWS) ' all escaped, producing ' "LDAP://CN=foo\=bar\,\/*" path.EscapedMode = ADS_ESCAPEMODE_OFF MsgBox path.Retrieve(ADS_FORMAT_WINDOWS) ' only "/" is unescaped: ' "LDAP://CN=foo\=bar\,/*" path.EscapedMode = ADS_ESCAPEDMODE_OFF_EX MsgBox path.Retrieve(ADS_FORMAT_WINDOWS) ' all are unescaped: ' "LDAP://CN=foo=bar,/*" path.Set "LDAP://CN=foo\=bar\,\/*", ADS_SETTYPE_FULL path.EscapedMode = ADS_ESCAPEDMODE_ON MsgBox path.Retrieve(ADS_FORMAT_WINDOWS) ' produces "LDAP://CN=foo\=bar\,\/*" path.EscapedMode = ADS_ESCAPEMODE_OFF MsgBox path.Retrieve(ADS_FORMAT_WINDOWS) ' produces "LDAP://CN=foo\=bar\,/*" path.EscapedMode = ADS_ESCAPEMODE_OFF_EX MsgBox path.Retrieve(ADS_FORMAT_WINDOWS) ' produces "LDAP://CN=foo=bar,/*"
The following VBScript/ASP code snippet shows how to use the EscapedMode property turn on/off escaping of the following three special characters: "=",",", and "/".
<% Dim path const ADS_SETTYPE_FULL = 1 const ADS_SETTYPE_DN = 4 const ADS_FORMAT_WINDOWS = 1 const ADS_ESCAPEDMODE_ON = 2 const ADS_ESCAPEDMODE_OFF = 3 const ADS_ESCAPEDMODE_OFF_EX = 4 Set path = CreateObject("Pathname") path.Set "CN=foo\=bar\,\/*", ADS_SETTYPE_DN path.EscapedMode = ADS_ESCAPEDMODE_ON Response.Write path.Retrieve(ADS_FORMAT_WINDOWS) ' all escaped, producing ' "LDAP://CN=foo\=bar\,\/*" path.EscapedMode = ADS_ESCAPEMODE_OFF Response.Write path.Retrieve(ADS_FORMAT_WINDOWS) ' only "/" is unescaped: ' "LDAP://CN=foo\=bar\,/*" path.EscapedMode = ADS_ESCAPEDMODE_OFF_EX Response.Write path.Retrieve(ADS_FORMAT_WINDOWS) ' all are unescaped: ' "LDAP://CN=foo=bar,/*" path.Set "LDAP://CN=foo\=bar\,\/*", ADS_SETTYPE_FULL path.EscapedMode = ADS_ESCAPEDMODE_ON Response.Write path.Retrieve(ADS_FORMAT_WINDOWS) ' produces "LDAP://CN=foo\=bar\,\/*" path.EscapedMode = ADS_ESCAPEMODE_OFF Response.Write path.Retrieve(ADS_FORMAT_WINDOWS) ' produces "LDAP://CN=foo\=bar\,/*" path.EscapedMode = ADS_ESCAPEMODE_OFF_EX Response.Write path.Retrieve(ADS_FORMAT_WINDOWS) ' produces "LDAP://CN=foo=bar,/*" %>
The following C++ code snippet shows how to work with the EscapedMode property. For brevity, error checking is ignored.
IADsPathname *pPathname=NULL; HRESULT hr; hr = CoCreateInstance(CLSID_Pathname, NULL, CLSCTX_INPROC_SERVER, IID_IADsPathname, (void**)&pPathname); if(FAILED(hr)) { if(pPathname) pPathname->Release(); return NULL; } pPathname->AddRef(); hr = pPathname->Set(L"LDAP://CN=foo/bar\/*",ADS_SETTYPE_FULL); hr = pPathname->put_EscapedMode(ADS_ESCAPEDMODE_OFF); hr = pPathname->Retrieve(ADS_FORMAT_DN,&bstr); printf("Unescaped path: %S\n",bstr); // producing "LDAP://CN=foo/bar/*" SysFreeString(bstr); hr = pPathname->put_EscapedMode(ADS_ESCAPEDMODE_ON); hr = pPathname->Retrieve(ADS_FORMAT_DN,&bstr); printf("Escaped path: %S\n",bstr); // producing "LDAP://CN=foo/bar\/*" SysFreeString(bstr); // //////////// // setting the path using ADS_SETTYPE_DN hr = pPathname->Set(L"CN=foo/bar\/*",ADS_SETTYPE_DN); hr = pPathname->put_EscapedMode(ADS_ESCAPEDMODE_OFF); hr = pPathname->Retrieve(ADS_FORMAT_DN,&bstr); printf("Unescaped path: %S\n",bstr); // producing "LDAP://CN=foo/bar/*" SysFreeString(bstr); hr = pPathname->put_EscapedMode(ADS_ESCAPEDMODE_ON); hr = pPathname->Retrieve(ADS_FORMAT_DN,&bstr); printf("Escaped path: %S\n",bstr); // producing "LDAP://CN=foo\/bar\/*" SysFreeString(bstr); hr = pPathname->Release();