Platform SDK: Active Directory, ADSI, and Directory Services |
The ADS_NAME_INITTYPE_ENUM enumeration specifies the types of initialization to perform on a NameTranslate object. It is used in the IADsNameTranslate interface.
enum { ADS_NAME_INITTYPE_DOMAIN = 1, ADS_NAME_INITTYPE_SERVER = 2, ADS_NAME_INITTYPE_GC = 3 } ADS_NAME_INITTYPE_ENUM;
The IADsNameTranslate::Init method or IADsNameTranslate::InitEx method uses these options to initialize the NameTranslate object. When ADS_NAME_INITTYPE_SERVER is used, you will need to specify the machine name of a directory server. When ADS_NAME_INITTYPE_DOMAIN is set, you must supply the domain name within a directory forest. When ADS_NAME_INITTYPE_GC is issued, the second parameter in IADsNameTranslate::Init or IADsNameTranslate::InitEx is ignored. The Global Catalog server of the domain of the current machine will be used to carry out the name translate operations. The initialization will fail if the host machine is not part of a domain because no global catalog will be found in such a scenario.
Note Because VBScript cannot read information from a type library, VBScript applications do not understand the symbolic constants as defined above. You should use the numerical constants instead to set the appropriate flags in your VBScript applications. If you want to use the symbolic constants as a good programming practice, you should make explicit declarations of such constants, as done here, in your VBScript applications.
The following C/C++ code snippet uses IADsNameTranslate::Init method to initialize a NameTranslate object through the global catalog, assuming the client running the application is within the directory forest. It then renders the distinguished name of a user object in the Windows NT 4 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_GC, L""); 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 IADsNameTranslate::Init method to initialize a NameTranslate object through the global catalog, assuming the client running the application is within the directory forest. It then renders the distinguished name of a user object in the Windows NT 4 format.
Dim nto as New NameTranslate dso="CN=jsmith, CN=users, DC=Microsoft dc=COM" nto.Init ADS_NAME_INITTYPE_GC, "" nto.Set ADS_NAME_TYPE_1779, dso trans = nto.Get(ADS_NAME_TYPE_NT4) MsgBox "Translated name = " & trans
The following VBScript/ASP code snippet uses IADsNameTranslate::Init method to initialize a NameTranslate object through the global catalog, assuming the client running the application is within the directory forest. It then renders the distinguished name of a user object in the Windows NT 4 format.
<%@ Language=VBScript %> <html> <body> <% Dim nto const ADS_NAME_INITTYPE_GC = 3 ' VBScript cannot read const ADS_NAME_TYPE_1779 = 1 ' enumeration definition const ADS_NAME_TYPE_NT4 = 3 dn = "CN=john smith,CN=Users,DC=Microsoft,DC=COM" Set nto = Server.CreateObject("NameTranslate") nto.Init ADS_NAME_INITTYPE_GC, "" 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.