K
kelzhadant
Guest
I tried to invoke Active directory search window from my application with administrative and other extended features. For this purpose Im using such flags:
DSQPF_ENABLEADMINFEATURES | DSQPF_ENABLEADVANCEDFEATURES;
As described in MSDN:
DSQPF_ENABLEADMINFEATURES - Uses features supported by the directory service administration tools, such as Admin Display Specifier for context menus and property pages.
DSQPF_ENABLEADVANCEDFEATURES - Specifies advanced features in the IDataObject instance passed to context menus and property pages.
This two flags perfectly works for tabs. As Domain administrator I can see a lot of tab in properties of user. But This parameters hasnt influence on context menu. Here example:
Application runs from Domain Administrator. UAC is disabled. Tested on Windows Server 2008 R2.
Is there any way to show this context menu?
Here you can see example code that I used for invoking AD search dialog.
#include "stdafx.h"
#include "activeds.h"
#include "cmnquery.h"
#include "dsquery.h"
#include "shlobj.h"
#include "dsclient.h"
#include "windows.h"
#pragma comment(lib, "uuid.lib")
#pragma comment(lib, "activeds.lib")
HRESULT FindADUsers(HWND hwndParent)
{
HRESULT hr;
ICommonQuery *pcq;
hr = CoCreateInstance(CLSID_CommonQuery,
NULL,
CLSCTX_INPROC_SERVER,
IID_ICommonQuery,
(LPVOID*)&pcq);
if (SUCCEEDED(hr))
{
OPENQUERYWINDOW openQueryWindow;
DSQUERYINITPARAMS dqip;
IDataObject *pdo;
ZeroMemory(&openQueryWindow, sizeof(openQueryWindow));
openQueryWindow.cbStruct = sizeof(openQueryWindow);
openQueryWindow.dwFlags = OQWF_DEFAULTFORM | OQWF_SINGLESELECT | OQWF_SHOWOPTIONAL;
openQueryWindow.pHandlerParameters = &dqip;
openQueryWindow.clsidHandler = CLSID_DsQuery;
openQueryWindow.clsidDefaultForm = CLSID_DsFindPeople;
ZeroMemory(&dqip, sizeof(dqip));
dqip.cbStruct = sizeof(dqip);
dqip.dwFlags = DSQPF_NOSAVE | DSQPF_SHOWHIDDENOBJECTS | DSQPF_ENABLEADMINFEATURES | DSQPF_ENABLEADVANCEDFEATURES;
hr = pcq->OpenQueryWindow(hwndParent, &openQueryWindow, &pdo);
if (S_OK == hr)
{
pdo->Release();
}
pcq->Release();
}
return hr;
}
// Entry point for application
int main(int argc, _TCHAR* argv[])
{
HRESULT hr;
CoInitialize(NULL);
hr = FindADUsers(NULL);
CoUninitialize();
return 0;
}
Continue reading...
DSQPF_ENABLEADMINFEATURES | DSQPF_ENABLEADVANCEDFEATURES;
As described in MSDN:
DSQPF_ENABLEADMINFEATURES - Uses features supported by the directory service administration tools, such as Admin Display Specifier for context menus and property pages.
DSQPF_ENABLEADVANCEDFEATURES - Specifies advanced features in the IDataObject instance passed to context menus and property pages.
This two flags perfectly works for tabs. As Domain administrator I can see a lot of tab in properties of user. But This parameters hasnt influence on context menu. Here example:
- Search dialog that was invoked from Server Manager. You can see administrative context menu.

- This is dialog invoked from my application. There is very short contexts menu, but if Ill clickProperties, Ill be able to change everything related to this account with administrative privileges.

Application runs from Domain Administrator. UAC is disabled. Tested on Windows Server 2008 R2.
Is there any way to show this context menu?
Here you can see example code that I used for invoking AD search dialog.
#include "stdafx.h"
#include "activeds.h"
#include "cmnquery.h"
#include "dsquery.h"
#include "shlobj.h"
#include "dsclient.h"
#include "windows.h"
#pragma comment(lib, "uuid.lib")
#pragma comment(lib, "activeds.lib")
HRESULT FindADUsers(HWND hwndParent)
{
HRESULT hr;
ICommonQuery *pcq;
hr = CoCreateInstance(CLSID_CommonQuery,
NULL,
CLSCTX_INPROC_SERVER,
IID_ICommonQuery,
(LPVOID*)&pcq);
if (SUCCEEDED(hr))
{
OPENQUERYWINDOW openQueryWindow;
DSQUERYINITPARAMS dqip;
IDataObject *pdo;
ZeroMemory(&openQueryWindow, sizeof(openQueryWindow));
openQueryWindow.cbStruct = sizeof(openQueryWindow);
openQueryWindow.dwFlags = OQWF_DEFAULTFORM | OQWF_SINGLESELECT | OQWF_SHOWOPTIONAL;
openQueryWindow.pHandlerParameters = &dqip;
openQueryWindow.clsidHandler = CLSID_DsQuery;
openQueryWindow.clsidDefaultForm = CLSID_DsFindPeople;
ZeroMemory(&dqip, sizeof(dqip));
dqip.cbStruct = sizeof(dqip);
dqip.dwFlags = DSQPF_NOSAVE | DSQPF_SHOWHIDDENOBJECTS | DSQPF_ENABLEADMINFEATURES | DSQPF_ENABLEADVANCEDFEATURES;
hr = pcq->OpenQueryWindow(hwndParent, &openQueryWindow, &pdo);
if (S_OK == hr)
{
pdo->Release();
}
pcq->Release();
}
return hr;
}
// Entry point for application
int main(int argc, _TCHAR* argv[])
{
HRESULT hr;
CoInitialize(NULL);
hr = FindADUsers(NULL);
CoUninitialize();
return 0;
}
Continue reading...