Click to Rate and Give Feedback
IADsNameTranslate::Set Method

The IADsNameTranslate::Set method directs the directory service to set up a specified object for name translation. To set the names and format of multiple objects, use IADsnametranslate::SetEx.

Syntax

HRESULT Set(
    long lnSetType,
    BSTR bstrADsPath
);

Parameters

lnSetType

The format of the name of a directory object. For more information, see ADS_NAME_TYPE_ENUM.

bstrADsPath

The object name, for example, "CN=Administrator, CN=users, DC=Fabrikam, DC=com".

Return Value

This method supports the standard HRESULT return values, including:

Return codeDescription

S_OK

The name has been set successfully.

E_FAIL

The operation has 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 uses the IADsNameTranslate::Set method to set an object so that its name can be translated from the RFC 1779 format to the Windows NT 4.0 user name format.

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=jeffsmith,cn=users,dc=Fabrikam,dc=com"));
if(FAILED(hr)) {exit 1;}
 
BSTR bstr;
hr = pNto->Get(ADS_NAME_TYPE_NT4, &bstr);
printf("Name in the translated format: %S\n", bstr);
 
SysFreeString(bstr);
pNto->Release();

Examples - Visual Basic

The following Visual Basic code example uses the IADsNameTranslate::Set method to set an object so that its name can be translated from the RFC 1779 format to the Windows NT 4.0 user name format.

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

Examples - VBScript

The following VBScript/ASP code example uses the IADsNameTranslate::Set method to set an object to have its name translated from the RFC 1779 format to the Windows NT 4.0 user name format.

<%@ Language=VBScript %>
<html>
<body>
<%
  Dim nto
  const ADS_NAME_INITTYPE_SERVER = 2  ' VBScript cannot read 
  const ADS_NAME_TYPE_1779 = 1        ' enumeration definition
  const ADS_NAME_TYPE_NT4 = 3
 
  dn = "CN=jeffsmith,CN=Users,DC=Fabrikam,DC=COM" 
 
  Set nto = Server.CreateObject("NameTranslate")
  nto.Init ADS_NAME_INITTYPE_SERVER, "myServer"
  nto.Set ADS_NAME_TYPE_1779, dn
  result = nto.Get(ADS_NAME_TYPE_NT4)
 
  Response.Write "<p>Name in the translated format: " & result
 
%>
</body>
</html>

Remarks

Before calling this method to set the object name, you should have established a connection to the directory service using either IADsNameTranslate::Init or IADsNameTranslate::InitEx.

You can use the IADsNameTranslate::Set method to set name translation for objects residing on the directory server. When the referral chasing is on, this method will also set any object found on other servers. For more information about referral chasing, see IADsNameTranslate Property Methods.

Requirements

ClientRequires Windows Vista, Windows XP, or Windows 2000 Professional.
ServerRequires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
RedistributableRequires Active Directory Client Extension on Windows NT 4.0 and Windows Me/98/95.
HeaderDeclared in Iads.h.
DLLRequires Activeds.dll.
IID

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

See Also

IADsNameTranslate
IADsNameTranslate Property Methods
IADsNameTranslate::Init
IADsNameTranslate::InitEx
IADsNameTranslate::SetEx
ADS_NAME_TYPE_ENUM


Send comments about this topic to Microsoft

Build date: 9/21/2008

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Why does IADsNameTranslate::Set return ACCESS_DENIED?      ppadmana ... Thomas Lee   |   Edit   |  
I have a service that is running as NETWORK_SERVICE
When I call IADsNameTranslate::Set with ADS_NAME_TYPE_USER_PRINCIPAL_NAME, I get an access denied
(HRESULT=80070005).

Any idea why this is happening? Is it due to permissions/security policy on the Global Catalog?

[tfl] - Hi. You should post this question post questions to the MSDN Forums at http://forums.microsoft.com/msdn. You are likely get a quicker response through the forum than through the Community Content. And if you do find out, why not come back and post a community content article describing the answer?
Flag as ContentBug
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker