IADsNameTranslate Interface

The IADsNameTranslate interface translates distinguished names (DNs) among various formats as defined in the ADS_NAME_TYPE_ENUM enumeration. The feature is available to objects in Active Directory.

Name translations are performed on the directory server. To translate a DN, communicate with the server by means of an IADsNameTranslate object, and specify which object is of interest and what format is desired. The following is the general process for using the IADsNameTranslate interface.

First, create an instance of the IADsNameTranslate object.

Second, initialize the IADsNameTranslate object by specifying the directory server using the IADsNameTranslate::Init or IADsNameTranslate::InitEx methods.

Third, set the directory object on the server by specifying the name with the IADsNameTranslate::Set method and the format with the IADsNameTranslate::SetEx method.

Fourth, retrieve the object name in the specified format with the IADsNameTranslate::Get or IADsNameTranslate::GetEx method.

The following code example shows how to create an IADsNameTranslate object in Visual C++, Visual Basic, and VBScript/Active Server Pages.

Note  The format elements as defined in the ADS_NAME_TYPE_ENUM enumeration and used by IADsNameTranslate are not equivalent and are non-interchangeable with the format elements used by the DsCrackName function. Do not confuse the proper use of these similarly named but non-interchangeable element formats.

Methods

The IADsNameTranslate interface inherits the methods of the IDispatch interface.

In addition, IADsNameTranslate defines the following methods.

MethodDescription

put_ChaseReferral

Toggle referral chasing ON or OFF.

Init

Initializes the IADsNameTranslate object with default credentials.

InitEx

Initializes the IADsNameTranslate object with specified credentials.

Set

Specifies the object name to translate.

Get

Gets the object name, set by Set, in a specified format.

SetEx

Sets the names of multiple objects at the same time.

GetEx

Gets the names of the objects, set by SetEx, in a specified format.

 

Properties

The IADsNameTranslate interface defines the following property. The preceding table includes an access method for this property.

PropertyAccess typeDescription

ChaseReferral

Write-only

Toggles referral chasing ON or OFF.

 

Examples

The following code example shows how to create an instance of an IADsNameTranslate object.

IADsNameTranslate *pNto;
HRESULT hr;
hr = CoCreateInstance(CLSID_NameTranslate,
                      NULL,
                      CLSCTX_INPROC_SERVER,
                      IID_IADsNameTranslate,
                      (void**)&pNto);
if(FAILED(hr)) { exit 1;}
 
hr = pNto->InitEx(ADS_NAME_INITTYPE_SERVER,
                  CComBSTR("aDsServer"),
                  CComBSTR("aUser"),
                  CComBSTR("userDomain"),
                  CComBSTR("passwd"));
if (FAILED(hr)) { exit 1;}
 
hr =pNto->Set(ADS_NAME_TYPE_1779,
             CComBSTR("cn=jeffsmith,cn=users,dc=Fabrikam,dc=com"));
if(FAILED(hr)) {exit 1;}
 
BSTR bstr;
hr = pNto->Get(ADS_NAME_TYPE_NT4, &bstr);
printf("Translation: %S\n", bstr);
 
SysFreeString(bstr);
pNto->Release();

The following code example shows how to create an instance of an IADsNameTranslate object.

Dim nto As New IADsNameTranslate
dso="CN=jeffsmith, CN=users, DC=Fabrikam dc=COM"
 
nto.Init  ADS_NAME_INITTYPE_SERVER, "aDsServer"
nto.Set ADS_NAME_TYPE_1779, dso
trans = nto.Get(ADS_NAME_TYPE_NT4)   ' trans="Fabrikam\jeffsmith"

The following code example shows how to create an instance of an IADsNameTranslate object.

<%@ 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 = "aDsServer"
  user   = "jeffsmith"
  dom    = "Fabrikam"
  passwd = "top secret" 
  dn = "CN=jeffsmith,CN=Users,DC=Fabrikam,DC=COM" 
 
  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_NT4)
 
  Response.Write "<p>Translated name: " & result
 
%>
</body>
</html>

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderIads.h
DLLActiveds.dll
IIDIID_IADsNameTranslate is defined as B1B272A3-3625-11D1-A3A4-00C04FB950DC

See Also

ADS_NAME_TYPE_ENUM
CoCreateInstance
IADsNameTranslate Property Methods
IADsNameTranslate::Get
IADsNameTranslate::GetEx
IADsNameTranslate::Init
IADsNameTranslate::InitEx
IADsNameTranslate::Set
IADsNameTranslate::SetEx
IADsNameTranslate Interface

Send comments about this topic to Microsoft

Build date: 11/12/2009

Tags :


Community Content

John A - MSFT
Please let developers know which libraries and headers to include to use this interface

Please let developers know which libraries and headers to include to use this interface

You can reference this article:

http://support.microsoft.com/kb/171723

There is a "Requirements" section on every SDK reference page. If you look above this community section, you'll find that for this Interface it lists Iads.h and Activeds.dll.

Tags :

Page view tracker