| Platform SDK: Active Directory, ADSI, and Directory Services |
The IADsNameTranslate::Get method retrieves the name of a directory object in the specified format. The distinguished name must have been set in the appropriate format by the IADsNameTranslate::Set method.
HRESULT IADsNameTranslate::Get( long lnFormatType, BSTR *pbstrADsPath );
This method supports the standard HRESULT return values, including:
This method lets you retrieve the name of a single directory object. To retrieve names of multiple objects use IADsNameTranslate::GetEx.
When referral chasing is on, this method will attempt to chase and resolve the path of a specified object that is not residing on the connected server.
The following C/C++ code snippet illustrates how to translate a distinguished name that is compliant with RFC 1779 to a GUID format. The machine name of the directory server is "myServer".
IADsNameTranslate *pNto;
HRESULT hr;
hr = CoCreateInstance(CLSID_NameTranslate,
NULL,
CLSCTX_INPROC_SERVER,
IID_IADsNameTranslate,
(void**)&pNto);
if(FAILED(hr)) { exit 1;}
hr = pNto->Init(ADS_NAME_INITTYPE_SERVER,
L"myServer");
if (FAILED(hr)) { exit 1;}
hr =pNto->Set(ADS_NAME_TYPE_1779, L"CN=rob,CN=Users,DC=myDomain,DC=Microsoft,DC=COM,O=Internet");
if(FAILED(hr)) {exit 1;}
BSTR bstr;
hr = pNto->Get(ADS_NAME_TYPE_GUID, &bstr);
printf("Translation: %S\n", bstr);
SysFreeString(bstr);
pNto->Release();
The following Visual Basic® code snippet illustrates how to translate a distinguished name that is compliant RFC 1779 to a GUID format. The machine name of the directory server is "myServer".
Dim nto As New NameTranslate Dim result As String dn = "CN=rob,CN=Users,DC=myDomain,DC=Microsoft,DC=COM,O=Internet" nto.Init ADS_NAME_INITTYPE_SERVER, "myServer" nto.Set ADS_NAME_TYPE_1779, dn result = nto.Get ADS_NAME_TYPE_GUID MsgBox result
The following VBScript/ASP code snippet illustrates how to translate a distinguished name that is compliant with RFC 1779 to a GUID format. The machine name of the directory server is "myServer".
<%@ Language=VBScript %>
<html>
<body>
<%
Dim nto
const ADS_NAME_INITTYPE_SERVER = 2
const ADS_NAME_TYPE_1779 = 1
const ADS_NAME_TYPE_NT4 = 3
server = "myServer"
user = "jsmith"
dom = "Microsoft"
passwd = "top secret"
Set nto = Server.CreateObject("NameTranslate")
nto.InitEx ADS_NAME_INITTYPE_SERVER, server, user, dom, passwd
nto.Set ADS_NAME_TYPE_1779, dn
result = nto.Get(ADS_NAME_TYPE_GUID)
Response.Write "<p>Translated name: " & result
%>
</body>
</html>
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.
IADsNameTranslate, IADsNameTranslate::GetEx, IADsNameTranslate::Set, ADS_NAME_TYPE_ENUM