show the object picker dialog when clicking the Add button
Modified: trunk/reactos/lib/aclui/aclui.c
Modified: trunk/reactos/lib/aclui/aclui.xml
Modified: trunk/reactos/lib/aclui/acluilib.h
_____
Modified: trunk/reactos/lib/aclui/aclui.c
--- trunk/reactos/lib/aclui/aclui.c 2005-07-26 13:40:31 UTC (rev
16741)
+++ trunk/reactos/lib/aclui/aclui.c 2005-07-26 13:42:15 UTC (rev
16742)
@@ -41,6 +41,8 @@
HeapFree(GetProcessHeap(),
0,
sp);
+
+ CoUninitialize();
}
static VOID
@@ -456,7 +458,7 @@
{
PSECURITY_PAGE sp = (PSECURITY_PAGE)ppsp->lParam;
- switch(uMsg)
+ switch (uMsg)
{
case PSPCB_CREATE:
{
@@ -568,6 +570,82 @@
}
}
+static HRESULT
+InitializeObjectPicker(IN PSECURITY_PAGE sp,
+ OUT IDsObjectPicker **pDsObjectPicker)
+{
+ HRESULT hRet;
+
+ *pDsObjectPicker = NULL;
+
+ hRet = CoCreateInstance(&CLSID_DsObjectPicker,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ &IID_IDsObjectPicker,
+ (LPVOID*)pDsObjectPicker);
+ if (SUCCEEDED(hRet))
+ {
+ DSOP_INIT_INFO InitInfo;
+ UINT i;
+ PCWSTR Attributes[] =
+ {
+ L"ObjectSid",
+ };
+ DSOP_SCOPE_INIT_INFO Scopes[] =
+ {
+ {
+ sizeof(DSOP_SCOPE_INIT_INFO),
+ DSOP_SCOPE_TYPE_TARGET_COMPUTER,
+ DSOP_SCOPE_FLAG_DEFAULT_FILTER_USERS |
DSOP_SCOPE_FLAG_DEFAULT_FILTER_GROUPS |
+ DSOP_SCOPE_FLAG_STARTING_SCOPE,
+ {
+ {
+ 0,
+ 0,
+ 0
+ },
+ DSOP_DOWNLEVEL_FILTER_USERS |
DSOP_DOWNLEVEL_FILTER_LOCAL_GROUPS |
+ DSOP_DOWNLEVEL_FILTER_GLOBAL_GROUPS |
DSOP_DOWNLEVEL_FILTER_ALL_WELLKNOWN_SIDS
+ },
+ NULL,
+ NULL,
+ S_OK
+ },
+ };
+
+ InitInfo.cbSize = sizeof(InitInfo);
+ InitInfo.pwzTargetComputer = (PCWSTR)sp->ServerName;
+ InitInfo.cDsScopeInfos = sizeof(Scopes) / sizeof(Scopes[0]);
+ InitInfo.aDsScopeInfos = Scopes;
+ InitInfo.flOptions = DSOP_FLAG_MULTISELECT |
DSOP_SCOPE_TYPE_TARGET_COMPUTER;
+ InitInfo.cAttributesToFetch = sizeof(Attributes) /
sizeof(Attributes[0]);
+ InitInfo.apwzAttributeNames = Attributes;
+
+ for (i = 0; i < InitInfo.cDsScopeInfos; i++)
+ {
+ if ((sp->ObjectInfo.dwFlags & SI_SERVER_IS_DC) &&
+ (InitInfo.aDsScopeInfos[i].flType &
DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN))
+ {
+ /* only set the domain controller string if we know the
target
+ computer is a domain controller and the scope type
is an
+ up-level domain to which the target computer is
joined */
+ InitInfo.aDsScopeInfos[i].pwzDcName =
InitInfo.pwzTargetComputer;
+ }
+ }
+
+ hRet = (*pDsObjectPicker)->lpVtbl->Initialize(*pDsObjectPicker,
+ &InitInfo);
+
+ if (FAILED(hRet))
+ {
+ /* delete the object picker in case initialization failed!
*/
+ (*pDsObjectPicker)->lpVtbl->Release(*pDsObjectPicker);
+ }
+ }
+
+ return hRet;
+}
+
static INT_PTR CALLBACK
SecurityPageProc(IN HWND hwndDlg,
IN UINT uMsg,
@@ -576,7 +654,7 @@
{
PSECURITY_PAGE sp;
- switch(uMsg)
+ switch (uMsg)
{
case WM_NOTIFY:
{
@@ -587,7 +665,7 @@
{
if (pnmh->hwndFrom == sp->hWndAceList)
{
- switch(pnmh->code)
+ switch (pnmh->code)
{
case LVN_ITEMCHANGED:
{
@@ -605,7 +683,7 @@
}
else if (pnmh->hwndFrom == sp->hAceCheckList)
{
- switch(pnmh->code)
+ switch (pnmh->code)
{
case CLN_CHANGINGITEMCHECKBOX:
{
@@ -625,6 +703,40 @@
break;
}
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDC_ACELIST_ADD:
+ {
+ HRESULT hRet;
+ IDsObjectPicker *pDsObjectPicker = NULL;
+ IDataObject *Selections = NULL;
+
+ sp = (PSECURITY_PAGE)GetWindowLongPtr(hwndDlg,
+ DWL_USER);
+
+ hRet = InitializeObjectPicker(sp,
+ &pDsObjectPicker);
+ if (SUCCEEDED(hRet))
+ {
+ hRet =
pDsObjectPicker->lpVtbl->InvokeDialog(pDsObjectPicker,
+
hwndDlg,
+
&Selections);
+ if (FAILED(hRet))
+ {
+ MessageBox(hwndDlg, L"InvokeDialog
failed!\n", NULL, 0);
+ }
+
+ /* delete the instance */
+
pDsObjectPicker->lpVtbl->Release(pDsObjectPicker);
+ }
+ break;
+ }
+ }
+ break;
+ }
+
case WM_INITDIALOG:
{
sp = (PSECURITY_PAGE)((LPPROPSHEETPAGE)lParam)->lParam;
@@ -751,7 +863,7 @@
SI_OBJECT_INFO ObjectInfo;
HRESULT hRet;
- if(psi == NULL)
+ if (psi == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
@@ -765,7 +877,7 @@
ZeroMemory(&ObjectInfo, sizeof(ObjectInfo));
hRet = psi->lpVtbl->GetObjectInformation(psi, &ObjectInfo);
- if(FAILED(hRet))
+ if (FAILED(hRet))
{
SetLastError(hRet);
@@ -773,6 +885,13 @@
return NULL;
}
+ hRet = CoInitialize(NULL);
+ if (FAILED(hRet))
+ {
+ DPRINT("CoInitialize failed!\n");
+ return NULL;
+ }
+
if (!RegisterCheckListControl(hDllInstance))
{
DPRINT("Registering the CHECKLIST_ACLUI class failed!\n");
@@ -802,7 +921,7 @@
psp.lParam = (LPARAM)sPage;
psp.pfnCallback = SecurityPageCallback;
- if(ObjectInfo.dwFlags & SI_PAGE_TITLE)
+ if (ObjectInfo.dwFlags & SI_PAGE_TITLE)
{
psp.pszTitle = ObjectInfo.pszPageTitle;
@@ -840,7 +959,7 @@
LPWSTR lpCaption;
BOOL Ret;
- if(psi == NULL)
+ if (psi == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
@@ -854,7 +973,7 @@
ZeroMemory(&ObjectInfo, sizeof(ObjectInfo));
hRet = psi->lpVtbl->GetObjectInformation(psi, &ObjectInfo);
- if(FAILED(hRet))
+ if (FAILED(hRet))
{
SetLastError(hRet);
@@ -864,7 +983,7 @@
/* create the page */
hPages[0] = CreateSecurityPage(psi);
- if(hPages[0] == NULL)
+ if (hPages[0] == NULL)
{
DPRINT("CreateSecurityPage(), couldn't create property
sheet!\n");
return FALSE;
@@ -890,7 +1009,7 @@
Ret = (PropertySheet(&psh) != -1);
- if(lpCaption != NULL)
+ if (lpCaption != NULL)
{
LocalFree((HLOCAL)lpCaption);
}
_____
Modified: trunk/reactos/lib/aclui/aclui.xml
--- trunk/reactos/lib/aclui/aclui.xml 2005-07-26 13:40:31 UTC (rev
16741)
+++ trunk/reactos/lib/aclui/aclui.xml 2005-07-26 13:42:15 UTC (rev
16742)
@@ -12,6 +12,7 @@
<library>user32</library>
<library>gdi32</library>
<library>comctl32</library>
+ <library>ole32</library>
<library>uxtheme</library>
<file>aclui.c</file>
<file>checklist.c</file>
_____
Modified: trunk/reactos/lib/aclui/acluilib.h
--- trunk/reactos/lib/aclui/acluilib.h 2005-07-26 13:40:31 UTC (rev
16741)
+++ trunk/reactos/lib/aclui/acluilib.h 2005-07-26 13:42:15 UTC (rev
16742)
@@ -1,5 +1,6 @@
#include <windows.h>
#include <commctrl.h>
+#include <objsel.h>
#include <prsht.h>
#include <aclui.h>
#include <sddl.h>