Export (0) Print
Expand All

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.

Members

The IADsNameTranslate interface inherits from the IDispatch interface. IADsNameTranslate also has these types of members:

Methods

The IADsNameTranslate interface has these methods.

MethodDescription
Get

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

GetEx

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

Init

Initializes the IADsNameTranslate object with default credentials.

InitEx

Initializes the IADsNameTranslate object with specified credentials.

Set

Specifies the object name to translate.

SetEx

Sets the names of multiple objects at the same time.

 

Properties

The IADsNameTranslate interface has these properties.

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 client

Windows Vista

Minimum supported server

Windows Server 2003

Header

Iads.h

DLL

Activeds.dll

IID

IID_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

 

 

Show:
© 2014 Microsoft