Click to Rate and Give Feedback
IADsNameTranslate::Get Method

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.

Syntax

HRESULT Get(
    long lnFormatType,
    BSTR *pbstrADsPath
);

Parameters

lnFormatType

The format type of the output name. For more information, see ADS_NAME_TYPE_ENUM. This method does not support the ADS_NAME_TYPE_SID_OR_SID_HISTORY_NAME element in ADS_NAME_TYPE_ENUM.

pbstrADsPath

The name of the returned object.

Return Value

This method supports the standard HRESULT return values, including:

Return code Description

S_OK

The name has been set successfully.

E_FAIL

The operation failed.

E_OUTOFMEMORY

A memory allocation failure occurred.

E_ADS_BAD_PARAMETER

One or more parameters are invalid.

HRESULT_FROM_WIN32(ERROR_DS_NAME_ERROR_RESOLVING)

Cannot resolve the name.

HRESULT_FROM_WIN32(ERROR_DS_NAME_ERROR_NOT_FOUND)

The name cannot be found or the caller does not have permission to access the name.

HRESULT_FROM_WIN32(ERROR_DS_NAME_ERROR_NOT_UNIQUE)

The input name is mapped to more than one output name or the desired format did not have a single, unique value for the object found.

HRESULT_FROM_WIN32(ERROR_DS_NAME_ERROR_NO_MAPPING)

The input name was found, but the associated output format cannot be found.

HRESULT_FROM_WIN32(ERROR_DS_NAME_ERROR_DOMAIN_ONLY)

Unable to resolve the entire name, but the domain in which the object resides could be determined.

HRESULT_FROM_WIN32(ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING)

A syntactical mapping cannot be performed on the client without going out over the network.

HRESULT_FROM_WIN32(ERROR_DS_NAME_ERROR_TRUST_REFERRAL)

The name is from an external trusted forest.

Examples

The following C/C++ code example shows how to translate a distinguished name that is compliant with RFC 1779 to a GUID format. The computer 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,
                  CComBSTR("myServer"));
if (FAILED(hr)) { exit 1;}
 
hr =pNto->Set(ADS_NAME_TYPE_1779, CComBSTR
  ("CN=jeff,CN=Users,DC=myDomain,DC=Fabrikam,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();

Examples [Visual Basic]

The following Visual Basic code example shows how to translate a distinguished name that is compliant RFC 1779 to a GUID format. The computer name of the directory server is "myServer".

 Dim nto As New NameTranslate
Dim result As String
 
dn = "CN=rob,CN=Users,DC=myDomain,DC=Fabrikam,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

Examples [VBScript]

The following VBScript/ASP code example shows 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   = "jeffsmith"
  dom    = "Fabrikam"
  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>

Remarks

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.

Requirements

Client Requires Windows Vista, Windows XP, or Windows 2000 Professional.
Server Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
Redistributable Requires Active Directory Client Extension on Windows NT 4.0 and Windows Me/98/95.
Header

Declared in Iads.h.

DLL

Requires Activeds.dll.

IID

IID_IADsNameTranslate is defined as B1B272A3-3625-11D1-A3A4-00C04FB950DC.

See Also

IADsNameTranslate
IADsNameTranslate::GetEx
IADsNameTranslate::Set
ADS_NAME_TYPE_ENUM


Send comments about this topic to Microsoft

Build date: 8/12/2008

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker