aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Util/ca/scagroup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ext/Util/ca/scagroup.cpp')
-rw-r--r--src/ext/Util/ca/scagroup.cpp412
1 files changed, 370 insertions, 42 deletions
diff --git a/src/ext/Util/ca/scagroup.cpp b/src/ext/Util/ca/scagroup.cpp
index c484c1d2..3d2c3beb 100644
--- a/src/ext/Util/ca/scagroup.cpp
+++ b/src/ext/Util/ca/scagroup.cpp
@@ -6,8 +6,11 @@
6LPCWSTR vcsGroupQuery = L"SELECT `Group`, `Component_`, `Name`, `Domain` FROM `Wix4Group` WHERE `Group`=?"; 6LPCWSTR vcsGroupQuery = L"SELECT `Group`, `Component_`, `Name`, `Domain` FROM `Wix4Group` WHERE `Group`=?";
7enum eGroupQuery { vgqGroup = 1, vgqComponent, vgqName, vgqDomain }; 7enum eGroupQuery { vgqGroup = 1, vgqComponent, vgqName, vgqDomain };
8 8
9LPCWSTR vcsGroupGroupQuery = L"SELECT `Parent_`, `Child_` FROM `Wix6GroupGroup` WHERE `Child_`=?"; 9LPCWSTR vcsGroupParentsQuery = L"SELECT `Parent_`,`Component_`,`Name`,`Domain`,`Child_` FROM `Wix6GroupGroup`,`Wix4Group` WHERE `Wix6GroupGroup`.`Parent_`=`Wix4Group`.`Group` AND `Wix6GroupGroup`.`Child_`=?";
10enum eGroupGroupQuery { vggqParent = 1, vggqChild }; 10enum eGroupParentsQuery { vgpqParent = 1, vgpqParentComponent, vgpqParentName, vgpqParentDomain, vgpqChild };
11
12LPCWSTR vcsGroupChildrenQuery = L"SELECT `Parent_`,`Child_`,`Component_`,`Name`,`Domain` FROM `Wix6GroupGroup`,`Wix4Group` WHERE `Wix6GroupGroup`.`Child_`=`Wix4Group`.`Group` AND `Wix6GroupGroup`.`Parent_`=?";
13enum eGroupChildrenQuery { vgcqParent = 1, vgcqChild, vgcqChildComponent, vgcqChildName, vgcqChildDomain };
11 14
12LPCWSTR vActionableGroupQuery = L"SELECT `Group`,`Component_`,`Name`,`Domain`,`Comment`,`Attributes` FROM `Wix4Group`,`Wix6Group` WHERE `Component_` IS NOT NULL AND `Group`=`Group_`"; 15LPCWSTR vActionableGroupQuery = L"SELECT `Group`,`Component_`,`Name`,`Domain`,`Comment`,`Attributes` FROM `Wix4Group`,`Wix6Group` WHERE `Component_` IS NOT NULL AND `Group`=`Group_`";
13enum eActionableGroupQuery { vagqGroup = 1, vagqComponent, vagqName, vagqDomain, vagqComment, vagqAttributes }; 16enum eActionableGroupQuery { vagqGroup = 1, vagqComponent, vagqName, vagqDomain, vagqComment, vagqAttributes };
@@ -16,7 +19,6 @@ static HRESULT AddGroupToList(
16 __inout SCA_GROUP** ppsgList 19 __inout SCA_GROUP** ppsgList
17 ); 20 );
18 21
19
20HRESULT __stdcall ScaGetGroup( 22HRESULT __stdcall ScaGetGroup(
21 __in LPCWSTR wzGroup, 23 __in LPCWSTR wzGroup,
22 __out SCA_GROUP* pscag 24 __out SCA_GROUP* pscag
@@ -160,11 +162,149 @@ void ScaGroupFreeList(
160 { 162 {
161 psgDelete = psgList; 163 psgDelete = psgList;
162 psgList = psgList->psgNext; 164 psgList = psgList->psgNext;
165 ScaGroupFreeList(psgDelete->psgParents);
166 ScaGroupFreeList(psgDelete->psgChildren);
163 167
164 MemFree(psgDelete); 168 MemFree(psgDelete);
165 } 169 }
166} 170}
167 171
172HRESULT ScaGroupGetParents(
173 __inout SCA_GROUP* psg
174)
175{
176 HRESULT hr = S_OK;
177 UINT er = ERROR_SUCCESS;
178 SCA_GROUP* psgParent = NULL;
179 PMSIHANDLE hView, hParamRec, hRec;
180 LPWSTR pwzTempStr = NULL;
181
182 if (S_OK != WcaTableExists(L"Wix6GroupGroup"))
183 {
184 WcaLog(LOGMSG_VERBOSE, "Wix6GroupGroup Table does not exist, exiting");
185 ExitFunction1(hr = S_FALSE);
186 }
187
188 // setup the query parameter record
189 hParamRec = ::MsiCreateRecord(1);
190 hr = WcaSetRecordString(hParamRec, 1, psg->wzKey);
191
192 //
193 // loop through all the groups
194 //
195 hr = WcaOpenView(vcsGroupParentsQuery, &hView);
196 ExitOnFailure(hr, "failed to open view on Wix6GroupGroup,Wix4Group table(s)");
197 hr = WcaExecuteView(hView, hParamRec);
198 ExitOnFailure(hr, "failed to open view on Wix4Group,Wix6Group table(s)");
199 while (S_OK == (hr = WcaFetchRecord(hView, &hRec)))
200 {
201 hr = AddGroupToList(&psg->psgParents);
202 ExitOnFailure(hr, "failed to add group to list");
203
204 psgParent = psg->psgParents;
205
206 if (::MsiRecordIsNull(hRec, vgcqChildComponent))
207 {
208 psgParent->isInstalled = INSTALLSTATE_NOTUSED;
209 psgParent->isAction = INSTALLSTATE_NOTUSED;
210 }
211 else
212 {
213 hr = WcaGetRecordString(hRec, vgpqParentComponent, &pwzTempStr);
214 ExitOnFailure(hr, "failed to get Wix4Group.Component");
215 wcsncpy_s(psgParent->wzComponent, pwzTempStr, MAX_DARWIN_KEY);
216 ReleaseNullStr(pwzTempStr);
217
218 er = ::MsiGetComponentStateW(WcaGetInstallHandle(), psgParent->wzComponent, &psgParent->isInstalled, &psgParent->isAction);
219 hr = HRESULT_FROM_WIN32(er);
220 ExitOnFailure(hr, "failed to get Component state for Wix4Group");
221 }
222
223 hr = WcaGetRecordString(hRec, vgpqParentName, &pwzTempStr);
224 ExitOnFailure(hr, "failed to get Wix4Group.Name");
225 wcsncpy_s(psgParent->wzName, pwzTempStr, MAX_DARWIN_COLUMN);
226 ReleaseNullStr(pwzTempStr);
227
228
229 hr = WcaGetRecordString(hRec, vgpqParentDomain, &pwzTempStr);
230 ExitOnFailure(hr, "failed to get Wix4Group.Domain");
231 wcsncpy_s(psgParent->wzDomain, pwzTempStr, MAX_DARWIN_COLUMN);
232 ReleaseNullStr(pwzTempStr);
233 }
234
235LExit:
236 ReleaseNullStr(pwzTempStr);
237 return hr;
238}
239
240HRESULT ScaGroupGetChildren(
241 __inout SCA_GROUP* psg
242)
243{
244 HRESULT hr = S_OK;
245 UINT er = ERROR_SUCCESS;
246 SCA_GROUP* psgChild = NULL;
247 PMSIHANDLE hView, hParamRec, hRec;
248 LPWSTR pwzTempStr = NULL;
249
250 if (S_OK != WcaTableExists(L"Wix6GroupGroup"))
251 {
252 WcaLog(LOGMSG_VERBOSE, "Wix6GroupGroup Table does not exist, exiting");
253 ExitFunction1(hr = S_FALSE);
254 }
255
256 // setup the query parameter record
257 hParamRec = ::MsiCreateRecord(1);
258 hr = WcaSetRecordString(hParamRec, 1, psg->wzKey);
259
260 //
261 // loop through all the groups
262 //
263 hr = WcaOpenView(vcsGroupChildrenQuery, &hView);
264 ExitOnFailure(hr, "failed to open view on Wix6GroupGroup,Wix4Group table(s)");
265 hr = WcaExecuteView(hView, hParamRec);
266 ExitOnFailure(hr, "failed to open view on Wix4Group,Wix6Group table(s)");
267 while (S_OK == (hr = WcaFetchRecord(hView, &hRec)))
268 {
269 hr = AddGroupToList(&psg->psgChildren);
270 ExitOnFailure(hr, "failed to add group to list");
271
272 psgChild = psg->psgChildren;
273
274 if (::MsiRecordIsNull(hRec, vgcqChildComponent))
275 {
276 psgChild->isInstalled = INSTALLSTATE_NOTUSED;
277 psgChild->isAction = INSTALLSTATE_NOTUSED;
278 }
279 else
280 {
281 hr = WcaGetRecordString(hRec, vgcqChildComponent, &pwzTempStr);
282 ExitOnFailure(hr, "failed to get Wix4Group.Component");
283 wcsncpy_s(psgChild->wzComponent, pwzTempStr, MAX_DARWIN_KEY);
284 ReleaseNullStr(pwzTempStr);
285
286 er = ::MsiGetComponentStateW(WcaGetInstallHandle(), psgChild->wzComponent, &psgChild->isInstalled, &psgChild->isAction);
287 hr = HRESULT_FROM_WIN32(er);
288 ExitOnFailure(hr, "failed to get Component state for Wix4Group");
289 }
290
291 hr = WcaGetRecordString(hRec, vgcqChildName, &pwzTempStr);
292 ExitOnFailure(hr, "failed to get Wix4Group.Name");
293 wcsncpy_s(psgChild->wzName, pwzTempStr, MAX_DARWIN_COLUMN);
294 ReleaseNullStr(pwzTempStr);
295
296
297 hr = WcaGetRecordString(hRec, vgcqChildDomain, &pwzTempStr);
298 ExitOnFailure(hr, "failed to get Wix4Group.Domain");
299 wcsncpy_s(psgChild->wzDomain, pwzTempStr, MAX_DARWIN_COLUMN);
300 ReleaseNullStr(pwzTempStr);
301 }
302
303LExit:
304 ReleaseNullStr(pwzTempStr);
305 return hr;
306}
307
168 308
169HRESULT ScaGroupRead( 309HRESULT ScaGroupRead(
170 __out SCA_GROUP** ppsgList 310 __out SCA_GROUP** ppsgList
@@ -179,7 +319,7 @@ HRESULT ScaGroupRead(
179 319
180 LPWSTR pwzData = NULL; 320 LPWSTR pwzData = NULL;
181 321
182 BOOL fGroupGroupExists = FALSE; 322 //BOOL fGroupGroupExists = FALSE;
183 323
184 SCA_GROUP *psg = NULL; 324 SCA_GROUP *psg = NULL;
185 325
@@ -196,11 +336,6 @@ HRESULT ScaGroupRead(
196 ExitFunction1(hr = S_FALSE); 336 ExitFunction1(hr = S_FALSE);
197 } 337 }
198 338
199 if (S_OK == WcaTableExists(L"Wix6GroupGroup"))
200 {
201 fGroupGroupExists = TRUE;
202 }
203
204 // 339 //
205 // loop through all the groups 340 // loop through all the groups
206 // 341 //
@@ -230,21 +365,26 @@ HRESULT ScaGroupRead(
230 psg->isAction = isAction; 365 psg->isAction = isAction;
231 hr = ::StringCchCopyW(psg->wzComponent, countof(psg->wzComponent), pwzData); 366 hr = ::StringCchCopyW(psg->wzComponent, countof(psg->wzComponent), pwzData);
232 ExitOnFailure(hr, "failed to copy component name: %ls", pwzData); 367 ExitOnFailure(hr, "failed to copy component name: %ls", pwzData);
368 ReleaseNullStr(pwzData);
233 369
234 hr = WcaGetRecordString(hRec, vagqGroup, &pwzData); 370 hr = WcaGetRecordString(hRec, vagqGroup, &pwzData);
235 ExitOnFailure(hr, "failed to get Wix4Group.Group"); 371 ExitOnFailure(hr, "failed to get Wix4Group.Group");
236 hr = ::StringCchCopyW(psg->wzKey, countof(psg->wzKey), pwzData); 372 hr = ::StringCchCopyW(psg->wzKey, countof(psg->wzKey), pwzData);
237 ExitOnFailure(hr, "failed to copy group key: %ls", pwzData); 373 ExitOnFailure(hr, "failed to copy group key: %ls", pwzData);
374 ReleaseNullStr(pwzData);
238 375
239 hr = WcaGetRecordFormattedString(hRec, vagqName, &pwzData); 376 hr = WcaGetRecordFormattedString(hRec, vagqName, &pwzData);
240 ExitOnFailure(hr, "failed to get Wix4Group.Name"); 377 ExitOnFailure(hr, "failed to get Wix4Group.Name");
241 hr = ::StringCchCopyW(psg->wzName, countof(psg->wzName), pwzData); 378 hr = ::StringCchCopyW(psg->wzName, countof(psg->wzName), pwzData);
242 ExitOnFailure(hr, "failed to copy group name: %ls", pwzData); 379 ExitOnFailure(hr, "failed to copy group name: %ls", pwzData);
380 ReleaseNullStr(pwzData);
243 381
244 hr = WcaGetRecordFormattedString(hRec, vagqDomain, &pwzData); 382 hr = WcaGetRecordFormattedString(hRec, vagqDomain, &pwzData);
245 ExitOnFailure(hr, "failed to get Wix4Group.Domain"); 383 ExitOnFailure(hr, "failed to get Wix4Group.Domain");
246 hr = ::StringCchCopyW(psg->wzDomain, countof(psg->wzDomain), pwzData); 384 hr = ::StringCchCopyW(psg->wzDomain, countof(psg->wzDomain), pwzData);
247 ExitOnFailure(hr, "failed to copy group domain: %ls", pwzData); 385 ExitOnFailure(hr, "failed to copy group domain: %ls", pwzData);
386 ReleaseNullStr(pwzData);
387
248 hr = WcaGetRecordFormattedString(hRec, vagqComment, &pwzData); 388 hr = WcaGetRecordFormattedString(hRec, vagqComment, &pwzData);
249 ExitOnFailure(hr, "failed to get Wix6Group.Comment"); 389 ExitOnFailure(hr, "failed to get Wix6Group.Comment");
250 hr = ::StringCchCopyW(psg->wzComment, countof(psg->wzComment), pwzData); 390 hr = ::StringCchCopyW(psg->wzComment, countof(psg->wzComment), pwzData);
@@ -253,36 +393,9 @@ HRESULT ScaGroupRead(
253 hr = WcaGetRecordInteger(hRec, vagqAttributes, &psg->iAttributes); 393 hr = WcaGetRecordInteger(hRec, vagqAttributes, &psg->iAttributes);
254 ExitOnFailure(hr, "failed to get Wix6Group.Attributes"); 394 ExitOnFailure(hr, "failed to get Wix6Group.Attributes");
255 395
256 // Check if this group is to be added to any other groups 396 ScaGroupGetParents(psg);
257 if (fGroupGroupExists)
258 {
259 hGroupRec = ::MsiCreateRecord(1);
260 hr = WcaSetRecordString(hGroupRec, 1, psg->wzKey);
261 ExitOnFailure(hr, "Failed to create group record for querying Wix6GroupGroup table");
262
263 hr = WcaOpenExecuteView(vcsGroupGroupQuery, &hGroupGroupView);
264 ExitOnFailure(hr, "Failed to open view on Wix6GroupGroup table for group %ls", psg->wzKey);/*
265 hr = WcaExecuteView(hGroupGroupView, hGroupRec);
266 ExitOnFailure(hr, "Failed to execute view on Wix6GroupGroup table for group: %ls", psg->wzKey);*/
267 397
268 while (S_OK == (hr = WcaFetchRecord(hGroupGroupView, &hRec))) 398 ScaGroupGetChildren(psg);
269 {
270 hr = WcaGetRecordString(hRec, vggqParent, &pwzData);
271 ExitOnFailure(hr, "failed to get Wix6GroupGroup.Parent");
272
273 hr = AddGroupToList(&(psg->psgGroups));
274 ExitOnFailure(hr, "failed to add group to list");
275
276 hr = ScaGetGroup(pwzData, psg->psgGroups);
277 ExitOnFailure(hr, "failed to get information for group: %ls", pwzData);
278 }
279
280 if (E_NOMOREITEMS == hr)
281 {
282 hr = S_OK;
283 }
284 ExitOnFailure(hr, "failed to enumerate selected rows from Wix4UserGroup table");
285 }
286 } 399 }
287 } 400 }
288 401
@@ -301,7 +414,6 @@ LExit:
301/* **************************************************************** 414/* ****************************************************************
302ScaGroupExecute - Schedules group account creation or removal based on 415ScaGroupExecute - Schedules group account creation or removal based on
303component state. 416component state.
304
305******************************************************************/ 417******************************************************************/
306HRESULT ScaGroupExecute( 418HRESULT ScaGroupExecute(
307 __in SCA_GROUP *psgList 419 __in SCA_GROUP *psgList
@@ -428,7 +540,7 @@ HRESULT ScaGroupExecute(
428 hr = WcaWriteIntegerToCaData(iRollbackUserAttributes, &pwzRollbackData); 540 hr = WcaWriteIntegerToCaData(iRollbackUserAttributes, &pwzRollbackData);
429 ExitOnFailure(hr, "failed to add group attributes to rollback custom action data for group: %ls", psg->wzKey); 541 ExitOnFailure(hr, "failed to add group attributes to rollback custom action data for group: %ls", psg->wzKey);
430 542
431 hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"CreateGroupRollback"), pwzRollbackData, COST_GROUP_DELETE); 543 hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION6(L"CreateGroupRollback"), pwzRollbackData, COST_GROUP_DELETE);
432 ExitOnFailure(hr, "failed to schedule CreateGroupRollback"); 544 ExitOnFailure(hr, "failed to schedule CreateGroupRollback");
433 } 545 }
434 else 546 else
@@ -441,7 +553,7 @@ HRESULT ScaGroupExecute(
441 // 553 //
442 // Schedule the creation now. 554 // Schedule the creation now.
443 // 555 //
444 hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"CreateGroup"), pwzActionData, COST_GROUP_ADD); 556 hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION6(L"CreateGroup"), pwzActionData, COST_GROUP_ADD);
445 ExitOnFailure(hr, "failed to schedule CreateGroup"); 557 ExitOnFailure(hr, "failed to schedule CreateGroup");
446 } 558 }
447 else if (((GROUP_EXISTS_YES == geGroupExists) 559 else if (((GROUP_EXISTS_YES == geGroupExists)
@@ -457,7 +569,7 @@ HRESULT ScaGroupExecute(
457 // 569 //
458 // Note: We can't rollback the removal of a group which is why RemoveGroup is a commit 570 // Note: We can't rollback the removal of a group which is why RemoveGroup is a commit
459 // CustomAction. 571 // CustomAction.
460 hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RemoveGroup"), pwzActionData, COST_GROUP_DELETE); 572 hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION6(L"RemoveGroup"), pwzActionData, COST_GROUP_DELETE);
461 ExitOnFailure(hr, "failed to schedule RemoveGroup"); 573 ExitOnFailure(hr, "failed to schedule RemoveGroup");
462 } 574 }
463 575
@@ -501,3 +613,219 @@ static HRESULT AddGroupToList(
501LExit: 613LExit:
502 return hr; 614 return hr;
503} 615}
616
617/* ****************************************************************
618ScaGroupMembershipRemoveParentsExecute - Schedules group membership removal
619based on parent/child component state
620******************************************************************/
621HRESULT ScaGroupMembershipRemoveParentsExecute(
622 __in SCA_GROUP* psg
623)
624{
625 HRESULT hr = S_OK;
626 LPWSTR pwzActionData = NULL;
627
628 for (SCA_GROUP* psgp = psg->psgParents; psgp; psgp = psgp->psgNext)
629 {
630 Assert(psgp->wzName);
631 if (WcaIsUninstalling(psg->isInstalled, psg->isAction)
632 || WcaIsUninstalling(psgp->isInstalled, psgp->isAction))
633 {
634 hr = WcaWriteStringToCaData(psgp->wzName, &pwzActionData);
635 ExitOnFailure(hr, "Failed to add parent group name to custom action data: %ls", psgp->wzName);
636 hr = WcaWriteStringToCaData(psgp->wzDomain, &pwzActionData);
637 ExitOnFailure(hr, "Failed to add parent group domain to custom action data: %ls", psgp->wzDomain);
638 hr = WcaWriteStringToCaData(psg->wzName, &pwzActionData);
639 ExitOnFailure(hr, "Failed to add child group name to custom action data: %ls", psg->wzName);
640 hr = WcaWriteStringToCaData(psg->wzDomain, &pwzActionData);
641 ExitOnFailure(hr, "Failed to add child group domain to custom action data: %ls", psg->wzDomain);
642 hr = WcaWriteIntegerToCaData(psg->iAttributes, &pwzActionData);
643 ExitOnFailure(hr, "Failed to add group attributes to custom action data: %i", psg->iAttributes);
644 hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION6(L"RemoveGroupMembership"), pwzActionData, COST_GROUPMEMBERSHIP_DELETE);
645
646 LExit:
647 ReleaseNullStr(pwzActionData);
648 if (hr != S_OK && !(psg->iAttributes & SCAG_NON_VITAL))
649 {
650 return hr;
651 }
652 }
653 }
654 return S_OK;
655}
656
657/* ****************************************************************
658ScaGroupMembershipRemoveChildrenExecute -
659******************************************************************/
660HRESULT ScaGroupMembershipRemoveChildrenExecute(
661 __in SCA_GROUP* psg
662)
663{
664 HRESULT hr = S_OK;
665 LPWSTR pwzActionData = NULL;
666
667 for (SCA_GROUP* psgc = psg->psgChildren; psgc; psgc = psgc->psgNext)
668 {
669 Assert(psgc->wzName);
670 if (WcaIsUninstalling(psg->isInstalled, psg->isAction)
671 || WcaIsUninstalling(psgc->isInstalled, psgc->isAction))
672 {
673 hr = WcaWriteStringToCaData(psg->wzName, &pwzActionData);
674 ExitOnFailure(hr, "Failed to add parent group name to custom action data: %ls", psg->wzName);
675 hr = WcaWriteStringToCaData(psg->wzDomain, &pwzActionData);
676 ExitOnFailure(hr, "Failed to add parent group domain to custom action data: %ls", psg->wzDomain);
677 hr = WcaWriteStringToCaData(psgc->wzName, &pwzActionData);
678 ExitOnFailure(hr, "Failed to add child group name to custom action data: %ls", psgc->wzName);
679 hr = WcaWriteStringToCaData(psgc->wzDomain, &pwzActionData);
680 ExitOnFailure(hr, "Failed to add child group domain to custom action data: %ls", psgc->wzDomain);
681 hr = WcaWriteIntegerToCaData(psg->iAttributes, &pwzActionData);
682 ExitOnFailure(hr, "Failed to add group attributes to custom action data: %i", psg->iAttributes);
683 hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION6(L"RemoveGroupMembership"), pwzActionData, COST_GROUPMEMBERSHIP_DELETE);
684
685 LExit:
686 ReleaseNullStr(pwzActionData);
687
688 if (hr != S_OK && !(psg->iAttributes & SCAG_NON_VITAL))
689 {
690 return hr;
691 }
692 }
693 }
694 return S_OK;
695}
696
697/* ****************************************************************
698ScaGroupMembershipRemoveExecute - Schedules group membership removal
699based on parent/child component state
700******************************************************************/
701HRESULT ScaGroupMembershipRemoveExecute(
702 __in SCA_GROUP* psgList
703)
704{
705 HRESULT hr = S_OK;
706
707 // Loop through all the users to be configured.
708 for (SCA_GROUP* psg = psgList; psg; psg = psg->psgNext)
709 {
710 Assert(psg->wzName);
711 // first we loop through the Parents
712 hr = ScaGroupMembershipRemoveParentsExecute(psg);
713 ExitOnFailure(hr, "Failed to remove parent membership for vital group: %ls", psg->wzKey);
714
715 // then through the Children
716 hr = ScaGroupMembershipRemoveChildrenExecute(psg);
717 ExitOnFailure(hr, "Failed to remove child membership for vital group: %ls", psg->wzKey);
718 }
719
720LExit:
721 return hr;
722}
723
724/* ****************************************************************
725ScaGroupMembershipAddParentsExecute - Schedules group membership removal
726based on parent/child component state
727******************************************************************/
728HRESULT ScaGroupMembershipAddParentsExecute(
729 __in SCA_GROUP* psg
730)
731{
732 HRESULT hr = S_OK;
733 LPWSTR pwzActionData = NULL;
734
735 for (SCA_GROUP* psgp = psg->psgParents; psgp; psgp = psgp->psgNext)
736 {
737 Assert(psgp->wzName);
738 if (WcaIsInstalling(psg->isInstalled, psg->isAction)
739 || WcaIsInstalling(psgp->isInstalled, psgp->isAction))
740 {
741 hr = WcaWriteStringToCaData(psgp->wzName, &pwzActionData);
742 ExitOnFailure(hr, "Failed to add parent group domain to custom action data: %ls", psgp->wzName);
743 hr = WcaWriteStringToCaData(psgp->wzDomain, &pwzActionData);
744 ExitOnFailure(hr, "Failed to add parent group domain to custom action data: %ls", psgp->wzDomain);
745 hr = WcaWriteStringToCaData(psg->wzName, &pwzActionData);
746 ExitOnFailure(hr, "Failed to add child group name to custom action data: %ls", psg->wzName);
747 hr = WcaWriteStringToCaData(psg->wzDomain, &pwzActionData);
748 ExitOnFailure(hr, "Failed to add child group domain to custom action data: %ls", psg->wzDomain);
749 hr = WcaWriteIntegerToCaData(psg->iAttributes, &pwzActionData);
750 ExitOnFailure(hr, "Failed to add group attributes to custom action data: %i", psg->iAttributes);
751 hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION6(L"AddGroupMembership"), pwzActionData, COST_GROUPMEMBERSHIP_ADD);
752
753 LExit:
754 ReleaseNullStr(pwzActionData);
755
756 if (hr != S_OK && !(psg->iAttributes & SCAG_NON_VITAL))
757 {
758 return hr;
759 }
760 }
761 }
762 return S_OK;
763}
764
765/* ****************************************************************
766ScaGroupMembershipAddChildrenExecute - Schedules group membership removal
767based on parent/child component state
768******************************************************************/
769HRESULT ScaGroupMembershipAddChildrenExecute(
770 __in SCA_GROUP* psg
771)
772{
773 HRESULT hr = S_OK;
774 LPWSTR pwzActionData = NULL;
775
776 // then through the Children
777 for (SCA_GROUP* psgc = psg->psgChildren; psgc; psgc = psgc->psgNext)
778 {
779 Assert(psgc->wzName);
780 if (WcaIsInstalling(psg->isInstalled, psg->isAction)
781 || WcaIsInstalling(psgc->isInstalled, psgc->isAction))
782 {
783 hr = WcaWriteStringToCaData(psg->wzName, &pwzActionData);
784 ExitOnFailure(hr, "Failed to add child group name to custom action data: %ls", psg->wzName);
785 hr = WcaWriteStringToCaData(psg->wzDomain, &pwzActionData);
786 ExitOnFailure(hr, "Failed to add child group domain to custom action data: %ls", psg->wzDomain);
787 hr = WcaWriteStringToCaData(psgc->wzName, &pwzActionData);
788 ExitOnFailure(hr, "Failed to add parent group domain to custom action data: %ls", psgc->wzName);
789 hr = WcaWriteStringToCaData(psgc->wzDomain, &pwzActionData);
790 ExitOnFailure(hr, "Failed to add parent group domain to custom action data: %ls", psgc->wzDomain);
791 hr = WcaWriteIntegerToCaData(psg->iAttributes, &pwzActionData);
792 ExitOnFailure(hr, "Failed to add group attributes to custom action data: %i", psg->iAttributes);
793 hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION6(L"AddGroupMembership"), pwzActionData, COST_GROUPMEMBERSHIP_ADD);
794
795 LExit:
796 ReleaseNullStr(pwzActionData);
797 if (hr != S_OK && !(psg->iAttributes & SCAG_NON_VITAL))
798 {
799 return hr;
800 }
801 }
802 }
803 return S_OK;
804}
805
806/* ****************************************************************
807ScaGroupMembershipAddExecute - Schedules group membership addition
808based on parent/child component state
809******************************************************************/
810HRESULT ScaGroupMembershipAddExecute(
811 __in SCA_GROUP* psgList
812)
813{
814 HRESULT hr = S_OK;
815
816 // Loop through all the users to be configured.
817 for (SCA_GROUP* psg = psgList; psg; psg = psg->psgNext)
818 {
819 Assert(psg->wzName);
820 // first we loop through the Parents
821 hr = ScaGroupMembershipAddParentsExecute(psg);
822 ExitOnFailure(hr, "Failed to add parent membership for vital group: %ls", psg->wzKey);
823
824 // then through the Children
825 hr = ScaGroupMembershipAddChildrenExecute(psg);
826 ExitOnFailure(hr, "Failed to add child membership for vital group: %ls", psg->wzKey);
827 }
828
829LExit:
830 return hr;
831}