Directory Services |
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.
HRESULT Set( long lnSetType, BSTR bstrADsPath );
Return Code | Description |
---|---|
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. |
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.
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();
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)
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>
Client: Included in Windows XP and
Windows 2000 Professional.
Server: Included in Windows Server 2003 and
Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension
on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Iads.h.
IADsNameTranslate, IADsNameTranslate Property Methods, IADsNameTranslate::Init, IADsNameTranslate::InitEx, IADsNameTranslate::SetEx, ADS_NAME_TYPE_ENUM