Platform SDK: Active Directory, ADSI, and Directory Services

DisplaySpecifiers Container

Display specifiers are stored by locale in the DisplaySpecifiers container of the Configuration container. Because the Configuration container is replicated across the entire forest, display specifiers are propagated across all domains in a forest.

The Configuration container stores the DisplaySpecifiers container, which in turn stores containers that correspond to each locale. These locale containers are named using the hexidecimal representation of that locale's LCID. For example, the US/English locale's container is named 409, the German locale's container is named 407, and the Japanese locale's container is named 411.

Each locale container stores objects of the displaySpecifier class.

To list all display specifiers for a locale, simply enumerate all the displaySpecifier objects in the specified locale container within the DisplaySpecifiers container.

The following code fragment contains a function that binds to the display specifier container for the specified locale:

// This function returns a pointer to the display specifier container 
// for the specified locale.
// If locale is NULL, use default system locale and then return the locale in the locale parameter.
HRESULT BindToDisplaySpecifiersContainerByLocale(LCID *locale,
                                        IADs **ppDispSpecCont
                                        )
{
HRESULT hr = E_FAIL;
 
if ((!ppDispSpecCont)||(!locale))
    return E_POINTER;
 
// If no locale is specified, use the default system locale.
if (!(*locale))
{
    *locale = GetSystemDefaultLCID();
    if (!(*locale))
        return E_FAIL;
}
 
// Make sure that it's a valid locale.
if (!IsValidLocale(*locale, LCID_SUPPORTED))
    return E_INVALIDARG;
 
LPOLESTR szPath = new OLECHAR[MAX_PATH*2];
IADs *pObj = NULL;
VARIANT var;
 
hr = ADsOpenObject(L"LDAP://rootDSE",
                     NULL,
                     NULL,
                     ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
                     IID_IADs,
                     (void**)&pObj);
 
if (SUCCEEDED(hr))
{
    // Get the DN to the configuration container.
    hr = pObj->Get(L"configurationNamingContext", &var);
    if (SUCCEEDED(hr))
    {
        // Build the string to bind to the container for the
        // specified locale in the DisplaySpecifiers container.
        wsprintf(szPath, L"LDAP://cn=%x,cn=DisplaySpecifiers,%s", *locale, var.bstrVal);
        // Bind to the container.
        *ppDispSpecCont = NULL;
        hr = ADsOpenObject(szPath,
                     NULL,
                     NULL,
                     ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
                     IID_IADs,
                     (void**)ppDispSpecCont);
 
        if(FAILED(hr))
        {
            if (!(*ppDispSpecCont))
            {
                (*ppDispSpecCont)->Release();
                (*ppDispSpecCont) = NULL;
            }
        }
    }
}
 
// Clean up
VariantClear(&var);
if (pObj)
    pObj->Release();
 
return hr;
}