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.

 

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.

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 s 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();

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 s 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)  

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 s 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>

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Iads.h

DLL

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

 

 

Show:
© 2014 Microsoft