Platform SDK: Active Directory, ADSI, and Directory Services |
The IADsNameTranslate interface is used to translate distinguished names (DN) between various formats. Name translations are carried out on the directory server, and this interface is currently only available to objects in Active Directory.
This example converts an account name from Windows format into LDAP format.
HRESULT TranslateNTNameToLDAPName( BSTR * pNTName, BSTR * pLDAPName ) { IADsNameTranslate *pTrans; HRESULT hr = S_OK; hr = CoCreateInstance(CLSID_NameTranslate, NULL, CLSCTX_INPROC_SERVER, IID_IADsNameTranslate, (void**) &pTrans ); if (FAILED(hr)) { return hr; } hr = pTrans->Init(ADS_NAME_INITTYPE_DOMAIN, L"Microsoft.com"); if (FAILED(hr)) { return hr; } hr = pTrans->Set(ADS_NAME_TYPE_NT4, pNTName); if (FAILED(hr)) { return hr; } hr = pTrans->Get(ADS_NAME_TYPE_1779, pLDAPName); pTrans->Release(); return hr; }