Directory Services |
The IADsPathname interface parses the X.500 and Windows path in ADSI.
The IADsPathname interface can be used to:
The IADsPathname interface is implemented on a Pathname object. You must instantiate the Pathname object to use the methods defined in the IADsPathname interface. This requirement is similar to calling the CoCreateInstance() function in C++.
[C++]
IADsPathname *pPathname=NULL;
HRESULT hr;
hr = CoCreateInstance(CLSID_Pathname,
NULL,
CLSCTX_INPROC_SERVER,
IID_IADsPathname,
(void**)&pPathname);
You can also invoke the New operator in Visual Basic:
[Visual Basic]
Dim path As New Pathname
Or use the CreateObject function in VBScript, supplying "Pathname" as the ProgID.
[VBScript]
Dim path
Set path = CreateObject("Pathname")
The IADsPathname interface uses two enumeration types: ADS_SETTYPE_ENUM, and ADS_FORMAT_ENUM.
The IADsPathname interface inherits the methods of the standard COM interfaces:
In addition, IADsPathname defines the following methods.
Method | Description |
---|---|
get_EscapedMode | Retrieves the mode for escaping a path. |
put_EscapedMode | Specifies the mode for escaping a path. |
Set | Sets an object path with an ADS_SETTYPE_ENUM option. |
SetDisplayType | Specifies how a path is to be displayed. |
Retrieve | Retrieves an object path with an ADS_FORMAT_ENUM type. |
GetNumElements | Gets the number of elements in the path. |
GetElement | Gets elements stored in the object with its index. |
GetEscapedElement | Escapes an RDN string and returns the output. |
AddLeafElement | Adds an element to the end of the path. |
RemoveLeafElement | Removes the last element from the object. |
CopyPath | Generates an object with the same path. |
The IADsPathname interface defines the following property. The preceding table includes access methods for this property.
Property | Description |
---|---|
EscapedMode | Retrieves the mode for escaping a path. |
The following Visual Basic code example shows how to create an ADsPathname object.
Dim x As New Pathname x.Set "LDAP", ADS_SETTYPE_PROVIDER
or
x.Set "LDAP://server/dc=domain1,dc=Fabrikam,dc=com", ADS_SETTYPE_FULL MsgBox "Path in Windows Format: " & x.Retrieve(ADS_FORMAT_WINDOWS)
The following VBScript/ASP code example shows how to create an ADsPathname object.
<% Dim x Set x = CreateObject("Pathname") x.Set "LDAP://server/dc=domain1,dc=Fabrikam,dc=com", ADS_SETTYPE_FULL winPath = x.Retrieve(ADS_FORMAT_WINDOWS) Response.Write "Path in Windows Format: " & winPath %>
The following C++ code example shows how to create an ADsPathname object.
IADsPathname *GetPathnameObject(LPWSTR adsPath) { if(!adsPath) return NULL; 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(CComBSTR(adsPath), ADS_SETTYPE_FULL); return pPathname; }
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.
IADsPathname Property Methods, ADS_FORMAT_ENUM, ADS_SETTYPE_ENUM, CoCreateInstance()