2 * ReactOS Access Control List Editor
3 * Copyright (C) 2004 ReactOS Team
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * PROJECT: ReactOS Access Control List Editor
22 * FILE: lib/aclui/aclui.c
23 * PURPOSE: Access Control List Editor
24 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
31 HINSTANCE hDllInstance
;
34 DestroySecurityPage(IN PSECURITY_PAGE sp
)
36 if(sp
->hiPrincipals
!= NULL
)
38 ImageList_Destroy(sp
->hiPrincipals
);
41 HeapFree(GetProcessHeap(),
49 FreePrincipalsList(IN PPRINCIPAL_LISTITEM
*PrincipalsListHead
)
51 PPRINCIPAL_LISTITEM CurItem
, NextItem
;
53 CurItem
= *PrincipalsListHead
;
54 while (CurItem
!= NULL
)
56 /* free the SID string if present */
57 if (CurItem
->DisplayString
!= NULL
)
59 LocalFree((HLOCAL
)CurItem
->DisplayString
);
62 /* free the ACE list item */
63 NextItem
= CurItem
->Next
;
64 HeapFree(GetProcessHeap(),
70 *PrincipalsListHead
= NULL
;
73 static PPRINCIPAL_LISTITEM
74 FindSidInPrincipalsList(IN PPRINCIPAL_LISTITEM PrincipalsListHead
,
77 PPRINCIPAL_LISTITEM CurItem
;
79 for (CurItem
= PrincipalsListHead
;
81 CurItem
= CurItem
->Next
)
83 if (EqualSid((PSID
)(CurItem
+ 1),
94 AddPrincipalToList(IN PSECURITY_PAGE sp
,
97 if (!FindSidInPrincipalsList(sp
->PrincipalsListHead
,
100 DWORD SidLength
, AccountNameSize
, DomainNameSize
;
101 SID_NAME_USE SidNameUse
;
103 PPRINCIPAL_LISTITEM AceListItem
, *NextAcePtr
;
105 NextAcePtr
= &sp
->PrincipalsListHead
;
106 for (AceListItem
= sp
->PrincipalsListHead
; AceListItem
!= NULL
; AceListItem
= AceListItem
->Next
)
108 NextAcePtr
= &AceListItem
->Next
;
111 SidLength
= GetLengthSid(Sid
);
116 /* calculate the size of the buffer we need to calculate */
117 LookupAccountSid(sp
->ServerName
,
125 /* allocate the ace */
126 AceListItem
= HeapAlloc(GetProcessHeap(),
128 sizeof(PRINCIPAL_LISTITEM
) +
130 ((AccountNameSize
+ DomainNameSize
) * sizeof(WCHAR
)));
131 if (AceListItem
!= NULL
)
133 AceListItem
->AccountName
= (LPWSTR
)((ULONG_PTR
)(AceListItem
+ 1) + SidLength
);
134 AceListItem
->DomainName
= AceListItem
->AccountName
+ AccountNameSize
;
137 (PSID
)(AceListItem
+ 1),
140 LookupResult
= ERROR_SUCCESS
;
141 if (!LookupAccountSid(sp
->ServerName
,
143 AceListItem
->AccountName
,
145 AceListItem
->DomainName
,
149 LookupResult
= GetLastError();
150 if (LookupResult
!= ERROR_NONE_MAPPED
)
152 HeapFree(GetProcessHeap(),
159 if (AccountNameSize
== 0)
161 AceListItem
->AccountName
= NULL
;
163 if (DomainNameSize
== 0)
165 AceListItem
->DomainName
= NULL
;
168 AceListItem
->Next
= NULL
;
169 if (LookupResult
== ERROR_NONE_MAPPED
)
171 if (!ConvertSidToStringSid(Sid
,
172 &AceListItem
->DisplayString
))
174 AceListItem
->DisplayString
= NULL
;
179 LSA_HANDLE LsaHandle
;
182 AceListItem
->DisplayString
= NULL
;
184 /* read the domain of the SID */
185 if (OpenLSAPolicyHandle(sp
->ServerName
,
186 POLICY_LOOKUP_NAMES
| POLICY_VIEW_LOCAL_INFORMATION
,
189 PLSA_REFERENCED_DOMAIN_LIST ReferencedDomain
;
190 PLSA_TRANSLATED_NAME Names
;
191 PLSA_TRUST_INFORMATION Domain
;
192 PLSA_UNICODE_STRING DomainName
;
193 PPOLICY_ACCOUNT_DOMAIN_INFO PolicyAccountDomainInfo
= NULL
;
195 Status
= LsaLookupSids(LsaHandle
,
200 if (NT_SUCCESS(Status
))
202 if (ReferencedDomain
!= NULL
&&
203 Names
->DomainIndex
>= 0)
205 Domain
= &ReferencedDomain
->Domains
[Names
->DomainIndex
];
206 DomainName
= &Domain
->Name
;
214 AceListItem
->SidNameUse
= Names
->Use
;
221 /* query the domain name for BUILTIN accounts */
222 Status
= LsaQueryInformationPolicy(LsaHandle
,
223 PolicyAccountDomainInformation
,
224 (PVOID
*)&PolicyAccountDomainInfo
);
225 if (NT_SUCCESS(Status
))
227 DomainName
= &PolicyAccountDomainInfo
->DomainName
;
229 /* make the user believe this is a group */
230 AceListItem
->SidNameUse
= SidTypeGroup
;
239 AceListItem
->DisplayString
= (LPWSTR
)LocalAlloc(LMEM_FIXED
,
240 (AccountNameSize
* sizeof(WCHAR
)) +
241 (DomainName
->Length
+ sizeof(WCHAR
)) +
242 (Names
->Name
.Length
+ sizeof(WCHAR
)) +
243 (4 * sizeof(WCHAR
)));
244 if (AceListItem
->DisplayString
!= NULL
)
248 /* NOTE: LSA_UNICODE_STRINGs are not always NULL-terminated! */
250 wcscpy(AceListItem
->DisplayString
,
251 AceListItem
->AccountName
);
252 wcscat(AceListItem
->DisplayString
,
254 s
= AceListItem
->DisplayString
+ wcslen(AceListItem
->DisplayString
);
258 s
+= DomainName
->Length
/ sizeof(WCHAR
);
263 s
+= Names
->Name
.Length
/ sizeof(WCHAR
);
268 /* mark the ace as a user unless it's a
270 if (PolicyAccountDomainInfo
== NULL
)
272 AceListItem
->SidNameUse
= SidTypeUser
;
278 case SidTypeWellKnownGroup
:
280 /* make the user believe this is a group */
281 AceListItem
->SidNameUse
= SidTypeGroup
;
287 DPRINT("Unhandled SID type: 0x%x\n", Names
->Use
);
292 if (PolicyAccountDomainInfo
!= NULL
)
294 LsaFreeMemory(PolicyAccountDomainInfo
);
297 LsaFreeMemory(ReferencedDomain
);
298 LsaFreeMemory(Names
);
304 /* append item to the cached ACL */
305 *NextAcePtr
= AceListItem
;
313 ReloadPrincipalsList(IN PSECURITY_PAGE sp
)
315 PSECURITY_DESCRIPTOR SecurityDescriptor
;
316 BOOL DaclPresent
, DaclDefaulted
;
320 /* delete the cached ACL */
321 FreePrincipalsList(&sp
->PrincipalsListHead
);
324 hRet
= sp
->psi
->lpVtbl
->GetSecurity(sp
->psi
,
325 DACL_SECURITY_INFORMATION
,
328 if (SUCCEEDED(hRet
) && SecurityDescriptor
!= NULL
)
330 if (GetSecurityDescriptorDacl(SecurityDescriptor
,
340 AceIndex
< Dacl
->AceCount
;
347 Sid
= (PSID
)&((PACCESS_ALLOWED_ACE
)Ace
)->SidStart
;
349 AddPrincipalToList(sp
,
353 LocalFree((HLOCAL
)SecurityDescriptor
);
358 AddPrincipalListEntry(IN PSECURITY_PAGE sp
,
359 IN PPRINCIPAL_LISTITEM PrincipalListItem
,
365 li
.mask
= LVIF_IMAGE
| LVIF_PARAM
| LVIF_STATE
| LVIF_TEXT
;
368 li
.state
= (Selected
? LVIS_SELECTED
: 0);
369 li
.stateMask
= LVIS_SELECTED
;
370 li
.pszText
= (PrincipalListItem
->DisplayString
!= NULL
? PrincipalListItem
->DisplayString
: PrincipalListItem
->AccountName
);
371 switch (PrincipalListItem
->SidNameUse
)
383 li
.lParam
= (LPARAM
)PrincipalListItem
;
385 return ListView_InsertItem(sp
->hWndPrincipalsList
,
390 FillPrincipalsList(IN PSECURITY_PAGE sp
)
393 PPRINCIPAL_LISTITEM CurItem
;
396 SelLParam
= ListViewGetSelectedItemData(sp
->hWndPrincipalsList
);
398 DisableRedrawWindow(sp
->hWndPrincipalsList
);
400 ListView_DeleteAllItems(sp
->hWndPrincipalsList
);
402 for (CurItem
= sp
->PrincipalsListHead
;
404 CurItem
= CurItem
->Next
)
406 AddPrincipalListEntry(sp
,
409 (SelLParam
== (LPARAM
)CurItem
));
412 EnableRedrawWindow(sp
->hWndPrincipalsList
);
414 GetClientRect(sp
->hWndPrincipalsList
, &rcLvClient
);
416 ListView_SetColumnWidth(sp
->hWndPrincipalsList
,
422 UpdateControlStates(IN PSECURITY_PAGE sp
)
424 PPRINCIPAL_LISTITEM Selected
= (PPRINCIPAL_LISTITEM
)ListViewGetSelectedItemData(sp
->hWndPrincipalsList
);
426 EnableWindow(sp
->hBtnRemove
, Selected
!= NULL
);
427 EnableWindow(sp
->hAceCheckList
, Selected
!= NULL
);
429 if (Selected
!= NULL
)
433 if (LoadAndFormatString(hDllInstance
,
436 Selected
->AccountName
))
438 SetWindowText(sp
->hPermissionsForLabel
,
441 LocalFree((HLOCAL
)szLabel
);
444 /* FIXME - update the checkboxes */
448 WCHAR szPermissions
[255];
450 if (LoadString(hDllInstance
,
453 sizeof(szPermissions
) / sizeof(szPermissions
[0])))
455 SetWindowText(sp
->hPermissionsForLabel
,
459 SendMessage(sp
->hAceCheckList
,
467 SecurityPageCallback(IN HWND hwnd
,
469 IN LPPROPSHEETPAGE ppsp
)
471 PSECURITY_PAGE sp
= (PSECURITY_PAGE
)ppsp
->lParam
;
481 DestroySecurityPage(sp
);
482 UnregisterCheckListControl();
491 SetAceCheckListColumns(IN HWND hAceCheckList
,
498 GetWindowRect(hLabel
,
501 pt
.x
= (rcLabel
.right
- rcLabel
.left
) / 2;
502 MapWindowPoints(hLabel
,
507 SendMessage(hAceCheckList
,
508 CLM_SETCHECKBOXCOLUMN
,
514 LoadPermissionsList(IN PSECURITY_PAGE sp
,
515 IN GUID
*GuidObjectType
,
517 OUT SI_ACCESS
*DefaultAccess
)
520 PSI_ACCESS AccessList
;
521 ULONG nAccessList
, DefaultAccessIndex
;
523 /* clear the permissions list */
525 SendMessage(sp
->hAceCheckList
,
530 /* query the access rights from the server */
531 hRet
= sp
->psi
->lpVtbl
->GetAccessRights(sp
->psi
,
536 &DefaultAccessIndex
);
537 if (SUCCEEDED(hRet
) && nAccessList
!= 0)
540 PSI_ACCESS CurAccess
, LastAccess
;
541 WCHAR NameBuffer
[MAX_PATH
];
543 /* save the default access rights to be used when adding ACEs later */
544 if (DefaultAccess
!= NULL
)
546 *DefaultAccess
= AccessList
[DefaultAccessIndex
];
549 LastAccess
= AccessList
+ nAccessList
;
550 for (CurAccess
= &AccessList
[0];
551 CurAccess
!= LastAccess
;
554 if (CurAccess
->dwFlags
& dwFlags
)
556 /* get the permission name, load it from a string table if necessary */
557 if (IS_INTRESOURCE(CurAccess
->pszName
))
559 if (!LoadString(sp
->ObjectInfo
.hInstance
,
560 (UINT
)((ULONG_PTR
)CurAccess
->pszName
),
562 sizeof(NameBuffer
) / sizeof(NameBuffer
[0])))
564 LoadString(hDllInstance
,
567 sizeof(NameBuffer
) / sizeof(NameBuffer
[0]));
569 NameStr
= NameBuffer
;
573 NameStr
= CurAccess
->pszName
;
576 SendMessage(sp
->hAceCheckList
,
586 ResizeControls(IN PSECURITY_PAGE sp
,
590 HWND hWndAllow
, hWndDeny
;
591 RECT rcControl
, rcControl2
, rcControl3
, rcWnd
;
592 INT cxWidth
, cxEdge
, btnSpacing
;
598 hWndAllow
= GetDlgItem(sp
->hWnd
,
600 hWndDeny
= GetDlgItem(sp
->hWnd
,
603 GetWindowRect(sp
->hWnd
,
606 cxEdge
= GetSystemMetrics(SM_CXEDGE
);
608 /* use the left margin of the principal list view control for all control
612 MapWindowPoints(sp
->hWndPrincipalsList
,
616 cxWidth
= Width
- (2 * pt
.x
);
618 if (sp
->ObjectInfo
.dwFlags
& SI_ADVANCED
)
623 if (!(dwp
= BeginDeferWindowPos(nControls
)))
628 /* resize the Principal list view */
629 GetWindowRect(sp
->hWndPrincipalsList
,
631 if (!(dwp
= DeferWindowPos(dwp
,
632 sp
->hWndPrincipalsList
,
637 rcControl
.bottom
- rcControl
.top
,
638 SWP_NOMOVE
| SWP_NOZORDER
)))
643 /* move the Add Principal button */
644 GetWindowRect(sp
->hBtnAdd
,
646 GetWindowRect(sp
->hBtnRemove
,
648 btnSpacing
= rcControl2
.left
- rcControl
.right
;
651 MapWindowPoints(sp
->hBtnAdd
,
655 if (!(dwp
= DeferWindowPos(dwp
,
658 pt
.x
+ cxWidth
- (rcControl2
.right
- rcControl2
.left
) -
659 (rcControl
.right
- rcControl
.left
) -
664 SWP_NOSIZE
| SWP_NOZORDER
)))
669 /* move the Delete Principal button */
672 MapWindowPoints(sp
->hBtnRemove
,
676 if (!(dwp
= DeferWindowPos(dwp
,
679 pt
.x
+ cxWidth
- (rcControl2
.right
- rcControl2
.left
) - cxEdge
,
683 SWP_NOSIZE
| SWP_NOZORDER
)))
688 /* move the Permissions For label */
689 GetWindowRect(hWndAllow
,
691 GetWindowRect(hWndDeny
,
693 GetWindowRect(sp
->hPermissionsForLabel
,
697 MapWindowPoints(sp
->hPermissionsForLabel
,
701 if (!(dwp
= DeferWindowPos(dwp
,
702 sp
->hPermissionsForLabel
,
706 cxWidth
- (rcControl2
.right
- rcControl2
.left
) -
707 (rcControl
.right
- rcControl
.left
) -
708 (2 * btnSpacing
) - cxEdge
,
709 rcControl3
.bottom
- rcControl3
.top
,
710 SWP_NOMOVE
| SWP_NOZORDER
)))
715 /* move the Allow label */
718 MapWindowPoints(hWndAllow
,
722 if (!(dwp
= DeferWindowPos(dwp
,
725 cxWidth
- (rcControl2
.right
- rcControl2
.left
) -
726 (rcControl
.right
- rcControl
.left
) -
731 SWP_NOSIZE
| SWP_NOZORDER
)))
736 /* move the Deny label */
739 MapWindowPoints(hWndDeny
,
743 if (!(dwp
= DeferWindowPos(dwp
,
746 cxWidth
- (rcControl2
.right
- rcControl2
.left
) - cxEdge
,
750 SWP_NOSIZE
| SWP_NOZORDER
)))
755 /* resize the Permissions check list box */
756 GetWindowRect(sp
->hAceCheckList
,
758 GetWindowRect(sp
->hBtnAdvanced
,
760 GetWindowRect(GetDlgItem(sp
->hWnd
,
763 if (!(dwp
= DeferWindowPos(dwp
,
769 ((sp
->ObjectInfo
.dwFlags
& SI_ADVANCED
) ?
770 Height
- (rcControl
.top
- rcWnd
.top
) - (rcControl3
.bottom
- rcControl3
.top
) - pt
.x
- btnSpacing
:
771 Height
- (rcControl
.top
- rcWnd
.top
) - pt
.x
),
772 SWP_NOMOVE
| SWP_NOZORDER
)))
777 if (sp
->ObjectInfo
.dwFlags
& SI_ADVANCED
)
779 /* move and resize the Advanced label */
780 if (!(dwp
= DeferWindowPos(dwp
,
785 Height
- (rcControl3
.bottom
- rcControl3
.top
) - pt
.x
,
786 cxWidth
- (rcControl2
.right
- rcControl2
.left
) - cxEdge
,
787 rcControl3
.bottom
- rcControl3
.top
,
793 /* move and resize the Advanced button */
794 if (!(dwp
= DeferWindowPos(dwp
,
797 cxWidth
- (rcControl2
.right
- rcControl2
.left
) + pt
.x
,
798 Height
- (rcControl2
.bottom
- rcControl2
.top
) - pt
.x
,
801 SWP_NOSIZE
| SWP_NOZORDER
)))
807 EndDeferWindowPos(dwp
);
809 /* update the width of the principal list view column */
810 GetClientRect(sp
->hWndPrincipalsList
,
812 lvc
.mask
= LVCF_WIDTH
;
813 lvc
.cx
= rcControl
.right
;
814 ListView_SetColumn(sp
->hWndPrincipalsList
,
818 /* calculate the columns of the allow/deny checkboxes */
819 SetAceCheckListColumns(sp
->hAceCheckList
,
822 SetAceCheckListColumns(sp
->hAceCheckList
,
828 AddSelectedPrincipal(IN IDsObjectPicker
*pDsObjectPicker
,
829 IN HWND hwndParent OPTIONAL
,
831 IN PVOID Context OPTIONAL
)
833 PSECURITY_PAGE sp
= (PSECURITY_PAGE
)Context
;
835 AddPrincipalToList(sp
,
841 static INT_PTR CALLBACK
842 SecurityPageProc(IN HWND hwndDlg
,
853 NMHDR
*pnmh
= (NMHDR
*)lParam
;
854 sp
= (PSECURITY_PAGE
)GetWindowLongPtr(hwndDlg
,
858 if (pnmh
->hwndFrom
== sp
->hWndPrincipalsList
)
862 case LVN_ITEMCHANGED
:
864 LPNMLISTVIEW pnmv
= (LPNMLISTVIEW
)lParam
;
866 if ((pnmv
->uChanged
& LVIF_STATE
) &&
867 ((pnmv
->uOldState
& (LVIS_FOCUSED
| LVIS_SELECTED
)) ||
868 (pnmv
->uNewState
& (LVIS_FOCUSED
| LVIS_SELECTED
))))
870 UpdateControlStates(sp
);
876 else if (pnmh
->hwndFrom
== sp
->hAceCheckList
)
880 case CLN_CHANGINGITEMCHECKBOX
:
882 PNMCHANGEITEMCHECKBOX pcicb
= (PNMCHANGEITEMCHECKBOX
)lParam
;
884 /* make sure only one of both checkboxes is only checked
888 pcicb
->NewState
&= ~((pcicb
->CheckBox
!= CLB_DENY
) ? CIS_DENY
: CIS_ALLOW
);
900 switch (LOWORD(wParam
))
902 case IDC_ADD_PRINCIPAL
:
906 sp
= (PSECURITY_PAGE
)GetWindowLongPtr(hwndDlg
,
909 hRet
= InitializeObjectPicker(sp
->ServerName
,
911 &sp
->pDsObjectPicker
);
914 hRet
= InvokeObjectPickerDialog(sp
->pDsObjectPicker
,
916 AddSelectedPrincipal
,
920 MessageBox(hwndDlg
, L
"InvokeObjectPickerDialog failed!\n", NULL
, 0);
923 /* delete the instance */
924 FreeObjectPicker(sp
->pDsObjectPicker
);
926 /* reload the principal list */
927 FillPrincipalsList(sp
);
931 MessageBox(hwndDlg
, L
"InitializeObjectPicker failed!\n", NULL
, 0);
941 sp
= (PSECURITY_PAGE
)GetWindowLongPtr(hwndDlg
,
946 (INT
)HIWORD(lParam
));
952 sp
= (PSECURITY_PAGE
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
959 sp
->hWndPrincipalsList
= GetDlgItem(hwndDlg
, IDC_PRINCIPALS
);
960 sp
->hBtnAdd
= GetDlgItem(hwndDlg
, IDC_ADD_PRINCIPAL
);
961 sp
->hBtnRemove
= GetDlgItem(hwndDlg
, IDC_REMOVE_PRINCIPAL
);
962 sp
->hBtnAdvanced
= GetDlgItem(hwndDlg
, IDC_ADVANCED
);
963 sp
->hAceCheckList
= GetDlgItem(hwndDlg
, IDC_ACE_CHECKLIST
);
964 sp
->hPermissionsForLabel
= GetDlgItem(hwndDlg
, IDC_LABEL_PERMISSIONS_FOR
);
966 sp
->SpecialPermCheckIndex
= -1;
968 if ((sp
->ObjectInfo
.dwFlags
& SI_SERVER_IS_DC
) &&
969 sp
->ObjectInfo
.pszServerName
!= NULL
&&
970 sp
->ObjectInfo
.pszServerName
[0] != L
'\0')
972 sp
->ServerName
= sp
->ObjectInfo
.pszServerName
;
975 /* save the pointer to the structure */
976 SetWindowLongPtr(hwndDlg
,
980 sp
->hiPrincipals
= ImageList_LoadBitmap(hDllInstance
,
981 MAKEINTRESOURCE(IDB_USRGRPIMAGES
),
986 /* setup the listview control */
987 ListView_SetExtendedListViewStyleEx(sp
->hWndPrincipalsList
,
988 LVS_EX_FULLROWSELECT
,
989 LVS_EX_FULLROWSELECT
);
990 ListView_SetImageList(sp
->hWndPrincipalsList
,
994 GetClientRect(sp
->hWndPrincipalsList
, &rcLvClient
);
996 /* add a column to the list view */
997 lvc
.mask
= LVCF_FMT
| LVCF_WIDTH
;
998 lvc
.fmt
= LVCFMT_LEFT
;
999 lvc
.cx
= rcLvClient
.right
;
1000 ListView_InsertColumn(sp
->hWndPrincipalsList
, 0, &lvc
);
1002 ReloadPrincipalsList(sp
);
1004 FillPrincipalsList(sp
);
1006 ListViewSelectItem(sp
->hWndPrincipalsList
,
1009 /* calculate the columns of the allow/deny checkboxes */
1010 SetAceCheckListColumns(sp
->hAceCheckList
,
1012 GetDlgItem(hwndDlg
, IDC_LABEL_ALLOW
));
1013 SetAceCheckListColumns(sp
->hAceCheckList
,
1015 GetDlgItem(hwndDlg
, IDC_LABEL_DENY
));
1017 LoadPermissionsList(sp
,
1020 ((sp
->ObjectInfo
.dwFlags
& SI_CONTAINER
) ? SI_ACCESS_CONTAINER
: 0),
1021 &sp
->DefaultAccess
);
1023 /* hide controls in case the flags aren't present */
1024 if (sp
->ObjectInfo
.dwFlags
& SI_ADVANCED
)
1026 WCHAR szSpecialPermissions
[255];
1028 /* editing the permissions is least the user can do when
1029 the advanced button is showed */
1030 sp
->ObjectInfo
.dwFlags
|= SI_EDIT_PERMS
;
1032 if (LoadString(hDllInstance
,
1033 IDS_SPECIAL_PERMISSIONS
,
1034 szSpecialPermissions
,
1035 sizeof(szSpecialPermissions
) / sizeof(szSpecialPermissions
[0])))
1037 /* add the special permissions check item */
1038 sp
->SpecialPermCheckIndex
= (INT
)SendMessage(sp
->hAceCheckList
,
1040 CIS_ALLOWDISABLED
| CIS_DENYDISABLED
| CIS_NONE
,
1041 (LPARAM
)szSpecialPermissions
);
1046 ShowWindow(sp
->hBtnAdvanced
,
1048 ShowWindow(GetDlgItem(hwndDlg
, IDC_LABEL_ADVANCED
),
1052 /* enable quicksearch for the permissions checklist control */
1053 SendMessage(sp
->hAceCheckList
,
1054 CLM_ENABLEQUICKSEARCH
,
1058 UpdateControlStates(sp
);
1068 * CreateSecurityPage EXPORTED
1074 CreateSecurityPage(IN LPSECURITYINFO psi
)
1077 PSECURITY_PAGE sPage
;
1078 SI_OBJECT_INFO ObjectInfo
;
1083 SetLastError(ERROR_INVALID_PARAMETER
);
1085 DPRINT("No ISecurityInformation class passed!\n");
1089 /* get the object information from the server. Zero the structure before
1090 because some applications seem to return SUCCESS but only seem to set the
1091 fields they care about. */
1092 ZeroMemory(&ObjectInfo
, sizeof(ObjectInfo
));
1093 hRet
= psi
->lpVtbl
->GetObjectInformation(psi
, &ObjectInfo
);
1099 DPRINT("CreateSecurityPage() failed! Failed to query the object information!\n");
1103 hRet
= CoInitialize(NULL
);
1106 DPRINT("CoInitialize failed!\n");
1110 if (!RegisterCheckListControl(hDllInstance
))
1112 DPRINT("Registering the CHECKLIST_ACLUI class failed!\n");
1116 sPage
= HeapAlloc(GetProcessHeap(),
1118 sizeof(SECURITY_PAGE
));
1121 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1123 DPRINT("Not enough memory to allocate a SECURITY_PAGE!\n");
1127 sPage
->ObjectInfo
= ObjectInfo
;
1129 ZeroMemory(&psp
, sizeof(psp
));
1131 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1132 psp
.dwFlags
= PSP_USECALLBACK
;
1133 psp
.hInstance
= hDllInstance
;
1134 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_SECPAGE
);
1135 psp
.pfnDlgProc
= SecurityPageProc
;
1136 psp
.lParam
= (LPARAM
)sPage
;
1137 psp
.pfnCallback
= SecurityPageCallback
;
1139 if (ObjectInfo
.dwFlags
& SI_PAGE_TITLE
)
1141 psp
.pszTitle
= ObjectInfo
.pszPageTitle
;
1143 if (psp
.pszTitle
!= NULL
)
1145 psp
.dwFlags
|= PSP_USETITLE
;
1150 psp
.pszTitle
= NULL
;
1153 /* NOTE: the SECURITY_PAGE structure will be freed by the property page
1156 return CreatePropertySheetPage(&psp
);
1161 * EditSecurity EXPORTED
1167 EditSecurity(IN HWND hwndOwner
,
1168 IN LPSECURITYINFO psi
)
1171 SI_OBJECT_INFO ObjectInfo
;
1172 PROPSHEETHEADER psh
;
1173 HPROPSHEETPAGE hPages
[1];
1179 SetLastError(ERROR_INVALID_PARAMETER
);
1181 DPRINT("No ISecurityInformation class passed!\n");
1185 /* get the object information from the server. Zero the structure before
1186 because some applications seem to return SUCCESS but only seem to set the
1187 fields they care about. */
1188 ZeroMemory(&ObjectInfo
, sizeof(ObjectInfo
));
1189 hRet
= psi
->lpVtbl
->GetObjectInformation(psi
, &ObjectInfo
);
1195 DPRINT("GetObjectInformation() failed!\n");
1199 /* create the page */
1200 hPages
[0] = CreateSecurityPage(psi
);
1201 if (hPages
[0] == NULL
)
1203 DPRINT("CreateSecurityPage(), couldn't create property sheet!\n");
1207 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
1208 psh
.dwFlags
= PSH_DEFAULT
;
1209 psh
.hwndParent
= hwndOwner
;
1210 psh
.hInstance
= hDllInstance
;
1212 /* Set the page title to the object name, make sure the format string
1213 has "%1" NOT "%s" because it uses FormatMessage() to automatically
1214 allocate the right amount of memory. */
1215 LoadAndFormatString(hDllInstance
,
1218 ObjectInfo
.pszObjectName
);
1219 psh
.pszCaption
= lpCaption
;
1221 psh
.nPages
= sizeof(hPages
) / sizeof(HPROPSHEETPAGE
);
1223 psh
.phpage
= hPages
;
1225 Ret
= (PropertySheet(&psh
) != -1);
1227 if (lpCaption
!= NULL
)
1229 LocalFree((HLOCAL
)lpCaption
);
1236 DllMain(IN HINSTANCE hinstDLL
,
1238 IN LPVOID lpvReserved
)
1242 case DLL_PROCESS_ATTACH
:
1243 hDllInstance
= hinstDLL
;
1245 case DLL_THREAD_ATTACH
:
1246 case DLL_THREAD_DETACH
:
1247 case DLL_PROCESS_DETACH
: