Platform SDK: Active Directory, ADSI, and Directory Services |
The IADsNameTranslate::Set method asks 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 IADsNameTranslate::Set( long lnSetType, BSTR bstrADsPath );
This method supports the standard HRESULT return values, including:
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 on referral chasing, see IADsNameTranslate Property Methods.
The following C/C++ code snippet 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, L"myServer"); if (FAILED(hr)) { exit 1;} hr =pNto->Set(ADS_NAME_TYPE_1779, L"cn=jsmith,cn=users,dc=Microsoft,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 snippet 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=jsmith, CN=users, DC=Microsoft 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 snippet 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=jsmith,CN=Users,DC=Microsoft,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>
Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with DSClient).
Windows 95/98: Requires Windows 95 or later (with DSClient).
Header: Declared in Iads.h.
IADsNameTranslate, IADsNameTranslate Property Methods, IADsNameTranslate::Init, IADsNameTranslate::InitEx, IADsNameTranslate::SetEx, ADS_NAME_TYPE_ENUM