Directory Services

IADsPathname::Retrieve

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

HRESULT Retrieve( 
  long lnFormatType,
  BSTR* pbstrADsPath
);

Parameters

lnFormatType
[in] Specifies the format that the path should be retrieved in. This can be one of the values specified in the ADS_FORMAT_ENUM enumeration.
pbstrADsPath
[out] Contains a pointer to a BSTR value the receives the object path. The caller must free this memery with the SysFreeString function when it is no longer required.

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 succeeded.
E_FAIL The operation 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.

Example Code [Visual Basic]

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

Const ADS_SETTYPE_FULL = 1
Const ADS_FORMAT_PROVIDER = 10

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

Example Code [VBScript]

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

const ADS_SETTYPE_FULL = 1
const ADS_FORMAT_PROVIDER = 10

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

Example Code [C++]

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

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

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

ADS_FORMAT_ENUM, SysFreeString, IADsPathname, ADSI Error Codes