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
,
334 DaclPresent
&& Dacl
!= NULL
)
341 AceIndex
< Dacl
->AceCount
;
348 Sid
= (PSID
)&((PACCESS_ALLOWED_ACE
)Ace
)->SidStart
;
350 AddPrincipalToList(sp
,
354 LocalFree((HLOCAL
)SecurityDescriptor
);
359 AddPrincipalListEntry(IN PSECURITY_PAGE sp
,
360 IN PPRINCIPAL_LISTITEM PrincipalListItem
,
366 li
.mask
= LVIF_IMAGE
| LVIF_PARAM
| LVIF_STATE
| LVIF_TEXT
;
369 li
.state
= (Selected
? LVIS_SELECTED
: 0);
370 li
.stateMask
= LVIS_SELECTED
;
371 li
.pszText
= (PrincipalListItem
->DisplayString
!= NULL
? PrincipalListItem
->DisplayString
: PrincipalListItem
->AccountName
);
372 switch (PrincipalListItem
->SidNameUse
)
384 li
.lParam
= (LPARAM
)PrincipalListItem
;
386 return ListView_InsertItem(sp
->hWndPrincipalsList
,
391 FillPrincipalsList(IN PSECURITY_PAGE sp
)
394 PPRINCIPAL_LISTITEM CurItem
;
397 SelLParam
= ListViewGetSelectedItemData(sp
->hWndPrincipalsList
);
399 DisableRedrawWindow(sp
->hWndPrincipalsList
);
401 ListView_DeleteAllItems(sp
->hWndPrincipalsList
);
403 for (CurItem
= sp
->PrincipalsListHead
;
405 CurItem
= CurItem
->Next
)
407 AddPrincipalListEntry(sp
,
410 (SelLParam
== (LPARAM
)CurItem
));
413 EnableRedrawWindow(sp
->hWndPrincipalsList
);
415 GetClientRect(sp
->hWndPrincipalsList
, &rcLvClient
);
417 ListView_SetColumnWidth(sp
->hWndPrincipalsList
,
423 UpdateControlStates(IN PSECURITY_PAGE sp
)
425 PPRINCIPAL_LISTITEM Selected
= (PPRINCIPAL_LISTITEM
)ListViewGetSelectedItemData(sp
->hWndPrincipalsList
);
427 EnableWindow(sp
->hBtnRemove
, Selected
!= NULL
);
428 EnableWindow(sp
->hAceCheckList
, Selected
!= NULL
);
430 if (Selected
!= NULL
)
434 if (LoadAndFormatString(hDllInstance
,
437 Selected
->AccountName
))
439 SetWindowText(sp
->hPermissionsForLabel
,
442 LocalFree((HLOCAL
)szLabel
);
445 /* FIXME - update the checkboxes */
449 WCHAR szPermissions
[255];
451 if (LoadString(hDllInstance
,
454 sizeof(szPermissions
) / sizeof(szPermissions
[0])))
456 SetWindowText(sp
->hPermissionsForLabel
,
460 SendMessage(sp
->hAceCheckList
,
468 SecurityPageCallback(IN HWND hwnd
,
470 IN LPPROPSHEETPAGE ppsp
)
472 PSECURITY_PAGE sp
= (PSECURITY_PAGE
)ppsp
->lParam
;
482 DestroySecurityPage(sp
);
483 UnregisterCheckListControl();
492 SetAceCheckListColumns(IN HWND hAceCheckList
,
499 GetWindowRect(hLabel
,
502 pt
.x
= (rcLabel
.right
- rcLabel
.left
) / 2;
503 MapWindowPoints(hLabel
,
508 SendMessage(hAceCheckList
,
509 CLM_SETCHECKBOXCOLUMN
,
515 LoadPermissionsList(IN PSECURITY_PAGE sp
,
516 IN GUID
*GuidObjectType
,
518 OUT SI_ACCESS
*DefaultAccess
)
521 PSI_ACCESS AccessList
;
522 ULONG nAccessList
, DefaultAccessIndex
;
524 /* clear the permissions list */
526 SendMessage(sp
->hAceCheckList
,
531 /* query the access rights from the server */
532 hRet
= sp
->psi
->lpVtbl
->GetAccessRights(sp
->psi
,
537 &DefaultAccessIndex
);
538 if (SUCCEEDED(hRet
) && nAccessList
!= 0)
541 PSI_ACCESS CurAccess
, LastAccess
;
542 WCHAR NameBuffer
[MAX_PATH
];
544 /* save the default access rights to be used when adding ACEs later */
545 if (DefaultAccess
!= NULL
)
547 *DefaultAccess
= AccessList
[DefaultAccessIndex
];
550 LastAccess
= AccessList
+ nAccessList
;
551 for (CurAccess
= &AccessList
[0];
552 CurAccess
!= LastAccess
;
555 if (CurAccess
->dwFlags
& dwFlags
)
557 /* get the permission name, load it from a string table if necessary */
558 if (IS_INTRESOURCE(CurAccess
->pszName
))
560 if (!LoadString(sp
->ObjectInfo
.hInstance
,
561 (UINT
)((ULONG_PTR
)CurAccess
->pszName
),
563 sizeof(NameBuffer
) / sizeof(NameBuffer
[0])))
565 LoadString(hDllInstance
,
568 sizeof(NameBuffer
) / sizeof(NameBuffer
[0]));
570 NameStr
= NameBuffer
;
574 NameStr
= CurAccess
->pszName
;
577 SendMessage(sp
->hAceCheckList
,
587 ResizeControls(IN PSECURITY_PAGE sp
,
591 HWND hWndAllow
, hWndDeny
;
592 RECT rcControl
, rcControl2
, rcControl3
, rcWnd
;
593 INT cxWidth
, cxEdge
, btnSpacing
;
599 hWndAllow
= GetDlgItem(sp
->hWnd
,
601 hWndDeny
= GetDlgItem(sp
->hWnd
,
604 GetWindowRect(sp
->hWnd
,
607 cxEdge
= GetSystemMetrics(SM_CXEDGE
);
609 /* use the left margin of the principal list view control for all control
613 MapWindowPoints(sp
->hWndPrincipalsList
,
617 cxWidth
= Width
- (2 * pt
.x
);
619 if (sp
->ObjectInfo
.dwFlags
& SI_ADVANCED
)
624 if (!(dwp
= BeginDeferWindowPos(nControls
)))
629 /* resize the Principal list view */
630 GetWindowRect(sp
->hWndPrincipalsList
,
632 if (!(dwp
= DeferWindowPos(dwp
,
633 sp
->hWndPrincipalsList
,
638 rcControl
.bottom
- rcControl
.top
,
639 SWP_NOMOVE
| SWP_NOZORDER
)))
644 /* move the Add Principal button */
645 GetWindowRect(sp
->hBtnAdd
,
647 GetWindowRect(sp
->hBtnRemove
,
649 btnSpacing
= rcControl2
.left
- rcControl
.right
;
652 MapWindowPoints(sp
->hBtnAdd
,
656 if (!(dwp
= DeferWindowPos(dwp
,
659 pt
.x
+ cxWidth
- (rcControl2
.right
- rcControl2
.left
) -
660 (rcControl
.right
- rcControl
.left
) -
665 SWP_NOSIZE
| SWP_NOZORDER
)))
670 /* move the Delete Principal button */
673 MapWindowPoints(sp
->hBtnRemove
,
677 if (!(dwp
= DeferWindowPos(dwp
,
680 pt
.x
+ cxWidth
- (rcControl2
.right
- rcControl2
.left
) - cxEdge
,
684 SWP_NOSIZE
| SWP_NOZORDER
)))
689 /* move the Permissions For label */
690 GetWindowRect(hWndAllow
,
692 GetWindowRect(hWndDeny
,
694 GetWindowRect(sp
->hPermissionsForLabel
,
698 MapWindowPoints(sp
->hPermissionsForLabel
,
702 if (!(dwp
= DeferWindowPos(dwp
,
703 sp
->hPermissionsForLabel
,
707 cxWidth
- (rcControl2
.right
- rcControl2
.left
) -
708 (rcControl
.right
- rcControl
.left
) -
709 (2 * btnSpacing
) - cxEdge
,
710 rcControl3
.bottom
- rcControl3
.top
,
711 SWP_NOMOVE
| SWP_NOZORDER
)))
716 /* move the Allow label */
719 MapWindowPoints(hWndAllow
,
723 if (!(dwp
= DeferWindowPos(dwp
,
726 cxWidth
- (rcControl2
.right
- rcControl2
.left
) -
727 (rcControl
.right
- rcControl
.left
) -
732 SWP_NOSIZE
| SWP_NOZORDER
)))
737 /* move the Deny label */
740 MapWindowPoints(hWndDeny
,
744 if (!(dwp
= DeferWindowPos(dwp
,
747 cxWidth
- (rcControl2
.right
- rcControl2
.left
) - cxEdge
,
751 SWP_NOSIZE
| SWP_NOZORDER
)))
756 /* resize the Permissions check list box */
757 GetWindowRect(sp
->hAceCheckList
,
759 GetWindowRect(sp
->hBtnAdvanced
,
761 GetWindowRect(GetDlgItem(sp
->hWnd
,
764 if (!(dwp
= DeferWindowPos(dwp
,
770 ((sp
->ObjectInfo
.dwFlags
& SI_ADVANCED
) ?
771 Height
- (rcControl
.top
- rcWnd
.top
) - (rcControl3
.bottom
- rcControl3
.top
) - pt
.x
- btnSpacing
:
772 Height
- (rcControl
.top
- rcWnd
.top
) - pt
.x
),
773 SWP_NOMOVE
| SWP_NOZORDER
)))
778 if (sp
->ObjectInfo
.dwFlags
& SI_ADVANCED
)
780 /* move and resize the Advanced label */
781 if (!(dwp
= DeferWindowPos(dwp
,
786 Height
- (rcControl3
.bottom
- rcControl3
.top
) - pt
.x
,
787 cxWidth
- (rcControl2
.right
- rcControl2
.left
) - cxEdge
,
788 rcControl3
.bottom
- rcControl3
.top
,
794 /* move and resize the Advanced button */
795 if (!(dwp
= DeferWindowPos(dwp
,
798 cxWidth
- (rcControl2
.right
- rcControl2
.left
) + pt
.x
,
799 Height
- (rcControl2
.bottom
- rcControl2
.top
) - pt
.x
,
802 SWP_NOSIZE
| SWP_NOZORDER
)))
808 EndDeferWindowPos(dwp
);
810 /* update the width of the principal list view column */
811 GetClientRect(sp
->hWndPrincipalsList
,
813 lvc
.mask
= LVCF_WIDTH
;
814 lvc
.cx
= rcControl
.right
;
815 ListView_SetColumn(sp
->hWndPrincipalsList
,
819 /* calculate the columns of the allow/deny checkboxes */
820 SetAceCheckListColumns(sp
->hAceCheckList
,
823 SetAceCheckListColumns(sp
->hAceCheckList
,
829 AddSelectedPrincipal(IN IDsObjectPicker
*pDsObjectPicker
,
830 IN HWND hwndParent OPTIONAL
,
832 IN PVOID Context OPTIONAL
)
834 PSECURITY_PAGE sp
= (PSECURITY_PAGE
)Context
;
836 AddPrincipalToList(sp
,
842 static INT_PTR CALLBACK
843 SecurityPageProc(IN HWND hwndDlg
,
854 NMHDR
*pnmh
= (NMHDR
*)lParam
;
855 sp
= (PSECURITY_PAGE
)GetWindowLongPtr(hwndDlg
,
859 if (pnmh
->hwndFrom
== sp
->hWndPrincipalsList
)
863 case LVN_ITEMCHANGED
:
865 LPNMLISTVIEW pnmv
= (LPNMLISTVIEW
)lParam
;
867 if ((pnmv
->uChanged
& LVIF_STATE
) &&
868 ((pnmv
->uOldState
& (LVIS_FOCUSED
| LVIS_SELECTED
)) ||
869 (pnmv
->uNewState
& (LVIS_FOCUSED
| LVIS_SELECTED
))))
871 UpdateControlStates(sp
);
877 else if (pnmh
->hwndFrom
== sp
->hAceCheckList
)
881 case CLN_CHANGINGITEMCHECKBOX
:
883 PNMCHANGEITEMCHECKBOX pcicb
= (PNMCHANGEITEMCHECKBOX
)lParam
;
885 /* make sure only one of both checkboxes is only checked
889 pcicb
->NewState
&= ~((pcicb
->CheckBox
!= CLB_DENY
) ? CIS_DENY
: CIS_ALLOW
);
901 switch (LOWORD(wParam
))
903 case IDC_ADD_PRINCIPAL
:
907 sp
= (PSECURITY_PAGE
)GetWindowLongPtr(hwndDlg
,
910 hRet
= InitializeObjectPicker(sp
->ServerName
,
912 &sp
->pDsObjectPicker
);
915 hRet
= InvokeObjectPickerDialog(sp
->pDsObjectPicker
,
917 AddSelectedPrincipal
,
921 MessageBox(hwndDlg
, L
"InvokeObjectPickerDialog failed!\n", NULL
, 0);
924 /* delete the instance */
925 FreeObjectPicker(sp
->pDsObjectPicker
);
927 /* reload the principal list */
928 FillPrincipalsList(sp
);
932 MessageBox(hwndDlg
, L
"InitializeObjectPicker failed!\n", NULL
, 0);
942 sp
= (PSECURITY_PAGE
)GetWindowLongPtr(hwndDlg
,
947 (INT
)HIWORD(lParam
));
953 sp
= (PSECURITY_PAGE
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
960 sp
->hWndPrincipalsList
= GetDlgItem(hwndDlg
, IDC_PRINCIPALS
);
961 sp
->hBtnAdd
= GetDlgItem(hwndDlg
, IDC_ADD_PRINCIPAL
);
962 sp
->hBtnRemove
= GetDlgItem(hwndDlg
, IDC_REMOVE_PRINCIPAL
);
963 sp
->hBtnAdvanced
= GetDlgItem(hwndDlg
, IDC_ADVANCED
);
964 sp
->hAceCheckList
= GetDlgItem(hwndDlg
, IDC_ACE_CHECKLIST
);
965 sp
->hPermissionsForLabel
= GetDlgItem(hwndDlg
, IDC_LABEL_PERMISSIONS_FOR
);
967 sp
->SpecialPermCheckIndex
= -1;
969 if ((sp
->ObjectInfo
.dwFlags
& SI_SERVER_IS_DC
) &&
970 sp
->ObjectInfo
.pszServerName
!= NULL
&&
971 sp
->ObjectInfo
.pszServerName
[0] != L
'\0')
973 sp
->ServerName
= sp
->ObjectInfo
.pszServerName
;
976 /* save the pointer to the structure */
977 SetWindowLongPtr(hwndDlg
,
981 sp
->hiPrincipals
= ImageList_LoadBitmap(hDllInstance
,
982 MAKEINTRESOURCE(IDB_USRGRPIMAGES
),
987 /* setup the listview control */
988 ListView_SetExtendedListViewStyleEx(sp
->hWndPrincipalsList
,
989 LVS_EX_FULLROWSELECT
,
990 LVS_EX_FULLROWSELECT
);
991 ListView_SetImageList(sp
->hWndPrincipalsList
,
995 GetClientRect(sp
->hWndPrincipalsList
, &rcLvClient
);
997 /* add a column to the list view */
998 lvc
.mask
= LVCF_FMT
| LVCF_WIDTH
;
999 lvc
.fmt
= LVCFMT_LEFT
;
1000 lvc
.cx
= rcLvClient
.right
;
1001 ListView_InsertColumn(sp
->hWndPrincipalsList
, 0, &lvc
);
1003 ReloadPrincipalsList(sp
);
1005 FillPrincipalsList(sp
);
1007 ListViewSelectItem(sp
->hWndPrincipalsList
,
1010 /* calculate the columns of the allow/deny checkboxes */
1011 SetAceCheckListColumns(sp
->hAceCheckList
,
1013 GetDlgItem(hwndDlg
, IDC_LABEL_ALLOW
));
1014 SetAceCheckListColumns(sp
->hAceCheckList
,
1016 GetDlgItem(hwndDlg
, IDC_LABEL_DENY
));
1018 LoadPermissionsList(sp
,
1021 ((sp
->ObjectInfo
.dwFlags
& SI_CONTAINER
) ? SI_ACCESS_CONTAINER
: 0),
1022 &sp
->DefaultAccess
);
1024 /* hide controls in case the flags aren't present */
1025 if (sp
->ObjectInfo
.dwFlags
& SI_ADVANCED
)
1027 WCHAR szSpecialPermissions
[255];
1029 /* editing the permissions is least the user can do when
1030 the advanced button is showed */
1031 sp
->ObjectInfo
.dwFlags
|= SI_EDIT_PERMS
;
1033 if (LoadString(hDllInstance
,
1034 IDS_SPECIAL_PERMISSIONS
,
1035 szSpecialPermissions
,
1036 sizeof(szSpecialPermissions
) / sizeof(szSpecialPermissions
[0])))
1038 /* add the special permissions check item */
1039 sp
->SpecialPermCheckIndex
= (INT
)SendMessage(sp
->hAceCheckList
,
1041 CIS_ALLOWDISABLED
| CIS_DENYDISABLED
| CIS_NONE
,
1042 (LPARAM
)szSpecialPermissions
);
1047 ShowWindow(sp
->hBtnAdvanced
,
1049 ShowWindow(GetDlgItem(hwndDlg
, IDC_LABEL_ADVANCED
),
1053 /* enable quicksearch for the permissions checklist control */
1054 SendMessage(sp
->hAceCheckList
,
1055 CLM_ENABLEQUICKSEARCH
,
1059 UpdateControlStates(sp
);
1069 * CreateSecurityPage EXPORTED
1075 CreateSecurityPage(IN LPSECURITYINFO psi
)
1078 PSECURITY_PAGE sPage
;
1079 SI_OBJECT_INFO ObjectInfo
;
1084 SetLastError(ERROR_INVALID_PARAMETER
);
1086 DPRINT("No ISecurityInformation class passed!\n");
1090 /* get the object information from the server. Zero the structure before
1091 because some applications seem to return SUCCESS but only seem to set the
1092 fields they care about. */
1093 ZeroMemory(&ObjectInfo
, sizeof(ObjectInfo
));
1094 hRet
= psi
->lpVtbl
->GetObjectInformation(psi
, &ObjectInfo
);
1100 DPRINT("CreateSecurityPage() failed! Failed to query the object information!\n");
1104 hRet
= CoInitialize(NULL
);
1107 DPRINT("CoInitialize failed!\n");
1111 if (!RegisterCheckListControl(hDllInstance
))
1113 DPRINT("Registering the CHECKLIST_ACLUI class failed!\n");
1117 sPage
= HeapAlloc(GetProcessHeap(),
1119 sizeof(SECURITY_PAGE
));
1122 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1124 DPRINT("Not enough memory to allocate a SECURITY_PAGE!\n");
1128 sPage
->ObjectInfo
= ObjectInfo
;
1130 ZeroMemory(&psp
, sizeof(psp
));
1132 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1133 psp
.dwFlags
= PSP_USECALLBACK
;
1134 psp
.hInstance
= hDllInstance
;
1135 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_SECPAGE
);
1136 psp
.pfnDlgProc
= SecurityPageProc
;
1137 psp
.lParam
= (LPARAM
)sPage
;
1138 psp
.pfnCallback
= SecurityPageCallback
;
1140 if (ObjectInfo
.dwFlags
& SI_PAGE_TITLE
)
1142 psp
.pszTitle
= ObjectInfo
.pszPageTitle
;
1144 if (psp
.pszTitle
!= NULL
)
1146 psp
.dwFlags
|= PSP_USETITLE
;
1151 psp
.pszTitle
= NULL
;
1154 /* NOTE: the SECURITY_PAGE structure will be freed by the property page
1157 return CreatePropertySheetPage(&psp
);
1162 * EditSecurity EXPORTED
1168 EditSecurity(IN HWND hwndOwner
,
1169 IN LPSECURITYINFO psi
)
1172 SI_OBJECT_INFO ObjectInfo
;
1173 PROPSHEETHEADER psh
;
1174 HPROPSHEETPAGE hPages
[1];
1180 SetLastError(ERROR_INVALID_PARAMETER
);
1182 DPRINT("No ISecurityInformation class passed!\n");
1186 /* get the object information from the server. Zero the structure before
1187 because some applications seem to return SUCCESS but only seem to set the
1188 fields they care about. */
1189 ZeroMemory(&ObjectInfo
, sizeof(ObjectInfo
));
1190 hRet
= psi
->lpVtbl
->GetObjectInformation(psi
, &ObjectInfo
);
1196 DPRINT("GetObjectInformation() failed!\n");
1200 /* create the page */
1201 hPages
[0] = CreateSecurityPage(psi
);
1202 if (hPages
[0] == NULL
)
1204 DPRINT("CreateSecurityPage(), couldn't create property sheet!\n");
1208 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
1209 psh
.dwFlags
= PSH_DEFAULT
;
1210 psh
.hwndParent
= hwndOwner
;
1211 psh
.hInstance
= hDllInstance
;
1213 /* Set the page title to the object name, make sure the format string
1214 has "%1" NOT "%s" because it uses FormatMessage() to automatically
1215 allocate the right amount of memory. */
1216 LoadAndFormatString(hDllInstance
,
1219 ObjectInfo
.pszObjectName
);
1220 psh
.pszCaption
= lpCaption
;
1222 psh
.nPages
= sizeof(hPages
) / sizeof(HPROPSHEETPAGE
);
1224 psh
.phpage
= hPages
;
1226 Ret
= (PropertySheet(&psh
) != -1);
1228 if (lpCaption
!= NULL
)
1230 LocalFree((HLOCAL
)lpCaption
);
1237 DllMain(IN HINSTANCE hinstDLL
,
1239 IN LPVOID lpvReserved
)
1243 case DLL_PROCESS_ATTACH
:
1244 hDllInstance
= hinstDLL
;
1246 case DLL_THREAD_ATTACH
:
1247 case DLL_THREAD_DETACH
:
1248 case DLL_PROCESS_DETACH
: