Platform SDK: Active Directory, ADSI, and Directory Services

IADsPathname::CopyPath

The IADsPathname::CopyPath method makes a copy of the Pathname object.

HRESULT IADsPathname::CopyPath(
  IDispatch *pDisp)
);

Parameters

pDisp
[out] The IDispatch interface pointer on the returned ADsPathname object.

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_INVALIDARG
The user has supplied an undefined parameter.

For other return values, see ADSI Error Codes.

Remarks

This method is useful when you want to modify the object path and retain the original object path.

Example Code [Visual Basic]

The following Visual Basic® code snippet shows how to make a copy of a pathname.

Dim x, y As New Pathname
x.Set "LDAP://srv1/dc=dom,dc=company,dc=com",ADS_SETTYPE_FULL
set y = x.CopyPath
MsgBox y.Retrieve(ADS_FORMAT_WINDOWS)

Example Code [VBScript]

The following VBScript/ASP code snippet shows how to make a copy of a pathname.

<%
Dim x, y
Const ADS_SETTYPE_FULL = 1
Const ADS_FORMAT_WINDOWS = 1
Set x = CreateObject("Pathname")
x.Set "LDAP://srv1/dc=dom,dc=company,dc=com",ADS_SETTYPE_FULL
 
set y = x.CopyPath
Response.Write y.Retrieve(ADS_FORMAT_WINDOWS)
%>

Example Code [C++]

The following C++ code snippet makes a copy of a pathname object. The code of GetPathnameObject function used below are given in IADsPathname.

IADsPathname *pPath;
LPWSTR adsPath;
adsPath = L"LDAP://server/cn=john smith,dc=Microsoft,dc=com";
 
IADsPathname *pPath = GetPathnameObject(adsPath)
if (!pPath) exit(0);
 
IDispatch *pDisp;
HRESULT hr;
hr = pPath->CopyPath(&pDisp);
if(FAILED(hr)) exit(hr);
 
IADsPathname *pPathCopy;
hr = pDisp->QueryInterface(IID_IADsPathname,(void**)&pPathCopy);
 
// …

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