Platform SDK: Active Directory, ADSI, and Directory Services

IADsPathname::Retrieve

The IADsPathname::Retrieve method retrieves the path of the object with different format types.

HRESULT IADsPathname::Retrieve(
  long dwFormatType,
  BSTR *pbstrADsPath
);

Parameters

dwFormatType
[in] A format type of the output path, as defined in ADS_FORMAT_ENUM.
pbstrADsPath
[out] The path of the object returned.

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 path set is not supported in 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 shows how to retrieve the provider name of the "LDAP://serv1/dc=dom, dc=company,dc=com" pathname.

Dim x as New Pathname
x.Set "LDAP://serv1/dc=dom,dc=company,dc=com"
y = x.Retrieve(ADS_FORMAT_PROVIDER)    ' y now equals "LDAP".

Example Code [VBScript]

The following VBScript code snippet shows how to retrieve the provider name of the "LDAP://serv1/dc=dom, dc=company,dc=com" pathname.

Dim x 
const ADS_FORMAT_PROVIDER = 10
Set x = CreateObject("Pathname")
x.Set "LDAP://serv1/dc=dom,dc=company,dc=com"
y = x.Retrieve(ADS_FORMAT_PROVIDER)    ' y now equals "LDAP".

Example Code [C++]

The following C++ code snippet shows how use IADsPathname::Retrieve method to obtain the path name string.

LPWSTR adsPath = L"WinNT://machine/aUser,user";
 
IADsPathname * pPath = GetPathnameObject(adsPath);
if (!pPath) return;
 
HRESULT hr = SetDisplayType(pPath,ADS_DISPLAY_FULL);
BSTR bstr;
hr = pPath->Retrieve(ADS_FORMAT_PROVIDER, &bstr);
printf("Provider of the path retrieved is %S\n",bstr);
SysFreeString(bstr);
 
pPath->Release();

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, ADS_FORMAT_ENUM, ADSI Error Codes