2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 #include <afs/param.h>
15 #include "TaAfsUsrMgr.h"
24 * DEFINITIONS ________________________________________________________________
28 #define cdayPWEXPIRATION_MAX 254
30 #define cFAILLOCKCOUNT_MAX 254
32 #define csecFAILLOCK_MAX (csec1HOUR * 36L)
34 #define GWD_ASIDLIST_MEMBER TEXT("AsidList - Members")
35 #define GWD_ASIDLIST_OWNER TEXT("AsidList - Owned")
39 * PROTOTYPES _________________________________________________________________
43 BOOL CALLBACK UserProp_General_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
44 void UserProp_General_OnInitDialog (HWND hDlg);
45 void UserProp_General_OnDestroy (HWND hDlg);
46 void UserProp_General_OnUnlock (HWND hDlg);
47 void UserProp_General_OnChangePwNow (HWND hDlg);
48 void UserProp_General_OnChangePw (HWND hDlg);
49 void UserProp_General_OnPwExpires (HWND hDlg);
50 void UserProp_General_OnFailLock (HWND hDlg);
51 void UserProp_General_OnFailLockTime (HWND hDlg);
52 void UserProp_General_OnApply (HWND hDlg);
53 void UserProp_General_UpdateDialog (HWND hDlg);
54 void UserProp_General_OnExpiration (HWND hDlg);
56 BOOL CALLBACK UserProp_Advanced_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
57 void UserProp_Advanced_OnInitDialog (HWND hDlg);
58 void UserProp_Advanced_OnDestroy (HWND hDlg);
59 void UserProp_Advanced_OnGrantTickets (HWND hDlg);
60 void UserProp_Advanced_OnHasGroupQuota (HWND hDlg);
61 void UserProp_Advanced_OnAdmin (HWND hDlg);
62 void UserProp_Advanced_OnApply (HWND hDlg);
63 void UserProp_Advanced_UpdateDialog (HWND hDlg);
64 void UserProp_Advanced_UpdateDialog_Perm (HWND hDlg, int idc, ACCOUNTACCESS aa, BOOL fMixed);
66 BOOL CALLBACK UserProp_Member_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
67 void UserProp_Member_OnInitDialog (HWND hDlg);
68 void UserProp_Member_OnDestroy (HWND hDlg);
69 void UserProp_Member_OnShowType (HWND hDlg);
70 void UserProp_Member_OnSelect (HWND hDlg);
71 void UserProp_Member_OnApply (HWND hDlg);
72 void UserProp_Member_OnAdd (HWND hDlg);
73 void UserProp_Member_OnRemove (HWND hDlg);
74 void UserProp_Member_OnEndTask_GroupSearch (HWND hDlg, LPTASKPACKET ptp);
75 void UserProp_Member_PopulateList (HWND hDlg);
77 void UserProp_UpdateName (HWND hDlg);
81 * ROUTINES ___________________________________________________________________
85 void User_FreeProperties (LPUSERPROPINFO lpp)
89 if ((lpp->fApplyAdvanced || lpp->fApplyGeneral) && lpp->pUserList)
92 // See if we have anything to scare the user about. If the
93 // "afs", "authserver" or "krbtgt" accounts have any modified
94 // properties, there may be reason for concern.
96 BOOL fMakeChanges = TRUE;
98 if (lpp->fApplyGeneral || lpp->fApplyAdvanced)
100 for (size_t ii = 0; ii < lpp->pUserList->cEntries; ++ii)
102 TCHAR szUser[ cchRESOURCE ];
103 asc_ObjectNameGet_Fast (g.idClient, g.idCell, lpp->pUserList->aEntries[ ii ].idObject, szUser);
105 if ( (!lstrcmpi (szUser, TEXT("afs"))) ||
106 (!lstrcmpi (szUser, TEXT("AuthServer"))) ||
107 (!lstrcmpi (szUser, TEXT("krbtgt"))) )
109 if (Message (MB_ICONASTERISK | MB_YESNO | MB_DEFBUTTON2, IDS_WARNING_TITLE, IDS_WARNING_SYSTEM_ACCOUNT, TEXT("%s"), szUser) != IDYES)
111 fMakeChanges = FALSE;
120 for (size_t ii = 0; ii < lpp->pUserList->cEntries; ++ii)
123 ASOBJPROP Properties;
124 if (!asc_ObjectPropertiesGet_Fast (g.idClient, g.idCell, lpp->pUserList->aEntries[ ii ].idObject, &Properties, &status))
127 LPUSER_CHANGE_PARAMS pTask = New (USER_CHANGE_PARAMS);
128 memset (pTask, 0x00, sizeof(USER_CHANGE_PARAMS));
129 pTask->idUser = lpp->pUserList->aEntries[ ii ].idObject;
131 // From Advanced tab:
133 if (!lpp->fApplyAdvanced || lpp->fSeal_Mixed)
134 pTask->NewProperties.fEncrypt = Properties.u.UserProperties.KASINFO.fEncrypt;
136 pTask->NewProperties.fEncrypt = lpp->fSeal;
138 if (!lpp->fApplyAdvanced || lpp->fAdmin_Mixed)
139 pTask->NewProperties.fIsAdmin = Properties.u.UserProperties.KASINFO.fIsAdmin;
141 pTask->NewProperties.fIsAdmin = lpp->fAdmin;
143 if (!lpp->fApplyAdvanced || lpp->fGrantTickets_Mixed)
144 pTask->NewProperties.fCanGetTickets = Properties.u.UserProperties.KASINFO.fCanGetTickets;
146 pTask->NewProperties.fCanGetTickets = lpp->fGrantTickets;
148 if (!lpp->fApplyAdvanced || lpp->fGrantTickets_Mixed)
149 pTask->NewProperties.csecTicketLifetime = Properties.u.UserProperties.KASINFO.csecTicketLifetime;
150 else if (!lpp->fGrantTickets)
151 pTask->NewProperties.csecTicketLifetime = 0;
153 pTask->NewProperties.csecTicketLifetime = lpp->csecLifetime;
155 if (!lpp->fApplyAdvanced || lpp->fGroupQuota_Mixed)
156 pTask->NewProperties.cgroupCreationQuota = Properties.u.UserProperties.PTSINFO.cgroupCreationQuota;
158 pTask->NewProperties.cgroupCreationQuota = lpp->cGroupQuota;
160 if (!lpp->fApplyAdvanced || lpp->fStatus_Mixed)
161 pTask->NewProperties.aaListStatus = Properties.u.UserProperties.PTSINFO.aaListStatus;
163 pTask->NewProperties.aaListStatus = lpp->aaStatus;
165 if (!lpp->fApplyAdvanced || lpp->fOwned_Mixed)
166 pTask->NewProperties.aaGroupsOwned = Properties.u.UserProperties.PTSINFO.aaGroupsOwned;
168 pTask->NewProperties.aaGroupsOwned = lpp->aaOwned;
170 if (!lpp->fApplyAdvanced || lpp->fMember_Mixed)
171 pTask->NewProperties.aaMembership = Properties.u.UserProperties.PTSINFO.aaMembership;
173 pTask->NewProperties.aaMembership = lpp->aaMember;
177 if (!lpp->fApplyGeneral || lpp->fCanChangePw_Mixed)
178 pTask->NewProperties.fCanChangePassword = Properties.u.UserProperties.KASINFO.fCanChangePassword;
180 pTask->NewProperties.fCanChangePassword = lpp->fCanChangePw;
182 if (!lpp->fApplyGeneral || lpp->fCanReusePw_Mixed)
183 pTask->NewProperties.fCanReusePasswords = Properties.u.UserProperties.KASINFO.fCanReusePasswords;
185 pTask->NewProperties.fCanReusePasswords = lpp->fCanReusePw;
187 if (!lpp->fApplyGeneral || lpp->fPwExpires_Mixed)
188 pTask->NewProperties.cdayPwExpire = Properties.u.UserProperties.KASINFO.cdayPwExpire;
190 pTask->NewProperties.cdayPwExpire = lpp->cdayPwExpires;
192 if (!lpp->fApplyGeneral || lpp->fExpires_Mixed)
193 memcpy (&pTask->NewProperties.timeExpires, &Properties.u.UserProperties.KASINFO.timeExpires, sizeof(SYSTEMTIME));
194 else if (!lpp->fExpires)
195 memset (&pTask->NewProperties.timeExpires, 0x00, sizeof(SYSTEMTIME));
196 else // (lpp->fExpires)
197 memcpy (&pTask->NewProperties.timeExpires, &lpp->stExpires, sizeof(SYSTEMTIME));
199 if (!lpp->fApplyGeneral || lpp->fFailLock_Mixed)
200 pTask->NewProperties.cFailLogin = Properties.u.UserProperties.KASINFO.cFailLogin;
202 pTask->NewProperties.cFailLogin = lpp->cFailLock;
204 if (!lpp->fApplyGeneral || lpp->fFailLock_Mixed)
205 pTask->NewProperties.csecFailLoginLock = Properties.u.UserProperties.KASINFO.csecFailLoginLock;
207 pTask->NewProperties.csecFailLoginLock = lpp->csecFailLock;
209 StartTask (taskUSER_CHANGE, NULL, pTask);
214 if (lpp->pGroupsMember)
215 asc_AsidListFree (&lpp->pGroupsMember);
216 if (lpp->pGroupsOwner)
217 asc_AsidListFree (&lpp->pGroupsOwner);
219 asc_AsidListFree (&lpp->pUserList);
220 memset (lpp, 0x00, sizeof(USERPROPINFO));
226 void User_ShowProperties (LPASIDLIST pUserList, USERPROPTAB uptTarget)
228 LPUSERPROPINFO lpp = New (USERPROPINFO);
229 memset (lpp, 0x00, sizeof(USERPROPINFO));
230 lpp->pUserList = pUserList;
231 lpp->fDeleteMeOnClose = TRUE;
232 lpp->fShowModal = FALSE;
234 if (pUserList && pUserList->cEntries)
235 lpp->fMachine = fIsMachineAccount (pUserList->aEntries[0].idObject);
237 User_ShowProperties (lpp, uptTarget);
241 void User_ShowProperties (LPUSERPROPINFO lpp, USERPROPTAB uptTarget)
245 // If we've been asked to view properties for only one user, and there is
246 // already a window open for that user, switch to it.
250 if (lpp->pUserList->cEntries == 1)
252 ASID idUser = lpp->pUserList->aEntries[0].idObject;
254 if ((hSheet = WindowList_Search (wltUSER_PROPERTIES, idUser)) != NULL)
256 SetForegroundWindow (hSheet);
257 if (uptTarget != uptANY)
259 HWND hTab = GetDlgItem (hSheet, IDC_PROPSHEET_TABCTRL);
260 int nTabs = TabCtrl_GetItemCount (hTab);
261 if (nTabs < nUSERPROPTAB_MAX)
262 uptTarget = (USERPROPTAB)( ((int)uptTarget-1) );
263 TabCtrl_SwitchToTab (hTab, uptTarget);
269 // Otherwise, make sure there are no Properties windows open for any
270 // of the selected users
272 for (size_t iUser = 0; iUser < lpp->pUserList->cEntries; ++iUser)
274 ASID idUser = lpp->pUserList->aEntries[ iUser ].idObject;
276 // See if there's a Properties window open that is dedicated to
279 if ((hSheet = WindowList_Search (wltUSER_PROPERTIES, idUser)) != NULL)
281 ErrorDialog (0, IDS_ERROR_USER_MULTIPROP);
285 // See if there is a multiple-user properties window open; if so,
286 // test it to see if it covers this user
288 if ((hSheet = WindowList_Search (wltUSER_PROPERTIES, 0)) != NULL)
290 LPUSERPROPINFO pInfo = (LPUSERPROPINFO)PropSheet_FindTabParam (hSheet);
291 if (pInfo && pInfo->pUserList && asc_AsidListTest (&pInfo->pUserList, idUser))
293 ErrorDialog (0, IDS_ERROR_USER_MULTIPROP);
300 // Okay, we're clear to create the new properties window.
306 pszTitle = FormatString (IDS_NEWMACHINE_PROPERTIES_TITLE);
308 pszTitle = FormatString (IDS_NEWUSER_PROPERTIES_TITLE);
310 else if (lpp->pUserList->cEntries > 1)
313 pszTitle = FormatString (IDS_MACHINE_PROPERTIES_TITLE_MULTIPLE);
315 pszTitle = FormatString (IDS_USER_PROPERTIES_TITLE_MULTIPLE);
319 TCHAR szUser[ cchRESOURCE ];
320 User_GetDisplayName (szUser, lpp->pUserList->aEntries[0].idObject);
322 pszTitle = FormatString (IDS_MACHINE_PROPERTIES_TITLE, TEXT("%s"), szUser);
324 pszTitle = FormatString (IDS_USER_PROPERTIES_TITLE, TEXT("%s"), szUser);
327 if (lpp->fMachine && (uptTarget == uptGENERAL))
328 uptTarget = uptADVANCED;
330 LPPROPSHEET psh = PropSheet_Create (pszTitle, TRUE, lpp->hParent, (LPARAM)lpp);
332 PropSheet_AddTab (psh, 0, (lpp->pUserList) ? IDD_USER_GENERAL : IDD_NEWUSER_GENERAL, (DLGPROC)UserProp_General_DlgProc, (LPARAM)lpp, TRUE, (uptTarget == uptGENERAL) ? TRUE : FALSE);
333 PropSheet_AddTab (psh, 0, (lpp->pUserList) ? (lpp->fMachine ? IDD_MACHINE_ADVANCED : IDD_USER_ADVANCED) : (lpp->fMachine ? IDD_NEWMACHINE_ADVANCED : IDD_NEWUSER_ADVANCED), (DLGPROC)UserProp_Advanced_DlgProc, (LPARAM)lpp, TRUE, (uptTarget == uptADVANCED) ? TRUE : FALSE);
334 PropSheet_AddTab (psh, 0, (lpp->pUserList) ? (lpp->fMachine ? IDD_MACHINE_MEMBER : IDD_USER_MEMBER) : (lpp->fMachine ? IDD_NEWMACHINE_MEMBER : IDD_NEWUSER_MEMBER), (DLGPROC)UserProp_Member_DlgProc, (LPARAM)lpp, TRUE, (uptTarget == uptMEMBERSHIP) ? TRUE : FALSE);
337 PropSheet_ShowModal (psh, PumpMessage);
339 PropSheet_ShowModeless (psh, SW_SHOW);
343 BOOL CALLBACK UserProp_General_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
345 if (AfsAppLib_HandleHelp (IDD_USER_GENERAL, hDlg, msg, wp, lp))
351 UserProp_General_OnInitDialog (hDlg);
355 UserProp_General_OnDestroy (hDlg);
358 case WM_ASC_NOTIFY_OBJECT:
359 UserProp_General_UpdateDialog (hDlg);
366 UserProp_General_OnApply (hDlg);
369 case IDC_USER_UNLOCK:
370 UserProp_General_OnUnlock (hDlg);
373 case IDC_USER_CPW_NOW:
374 UserProp_General_OnChangePwNow (hDlg);
378 UserProp_General_OnChangePw (hDlg);
379 PropSheetChanged (hDlg);
382 case IDC_USER_PWEXPIRES:
383 UserProp_General_OnPwExpires (hDlg);
384 PropSheetChanged (hDlg);
387 case IDC_USER_EXPIRES:
388 UserProp_General_OnExpiration (hDlg);
389 PropSheetChanged (hDlg);
392 case IDC_USER_FAILLOCK:
393 UserProp_General_OnFailLock (hDlg);
394 PropSheetChanged (hDlg);
397 case IDC_USER_FAILLOCK_INFINITE:
398 case IDC_USER_FAILLOCK_FINITE:
399 UserProp_General_OnFailLockTime (hDlg);
400 PropSheetChanged (hDlg);
404 case IDC_USER_PWEXPIRATION:
405 case IDC_USER_EXPIRE_DATE:
406 case IDC_USER_EXPIRE_TIME:
407 case IDC_USER_FAILLOCK_COUNT:
408 case IDC_USER_FAILLOCK_DURATION:
409 PropSheetChanged (hDlg);
419 void UserProp_General_OnInitDialog (HWND hDlg)
421 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
423 // Indicate we want to know if anything changes with these users
427 LPOBJECT_LISTEN_PARAMS pTask = New (OBJECT_LISTEN_PARAMS);
428 memset (pTask, 0x00, sizeof(OBJECT_LISTEN_PARAMS));
429 pTask->hNotify = hDlg;
430 asc_AsidListCopy (&pTask->pAsidList, &lpp->pUserList);
431 StartTask (taskOBJECT_LISTEN, NULL, pTask);
434 // Fix the name shown on the dialog
436 UserProp_UpdateName (hDlg);
438 // Update the dialog's display
440 if (lpp->pUserList && (lpp->pUserList->cEntries > 1))
441 EnableWindow (GetDlgItem (hDlg, IDC_USER_CPW_NOW), FALSE);
443 UserProp_General_UpdateDialog (hDlg);
447 void UserProp_General_OnDestroy (HWND hDlg)
449 // Indicate we no longer care if anything changes with these users
451 LPOBJECT_LISTEN_PARAMS pTask = New (OBJECT_LISTEN_PARAMS);
452 memset (pTask, 0x00, sizeof(OBJECT_LISTEN_PARAMS));
453 pTask->hNotify = hDlg;
454 StartTask (taskOBJECT_LISTEN, NULL, pTask);
458 void UserProp_General_UpdateDialog (HWND hDlg)
460 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
462 // Most of the controls on the dialog can be gathered by looping
463 // through our pUserList.
465 BOOL fGotAnyData = FALSE;
467 for (size_t ii = 0; lpp->pUserList && (ii < lpp->pUserList->cEntries); ++ii)
470 ASOBJPROP Properties;
471 if (!asc_ObjectPropertiesGet_Fast (g.idClient, g.idCell, lpp->pUserList->aEntries[ ii ].idObject, &Properties, &status))
476 lpp->fCanChangePw = Properties.u.UserProperties.KASINFO.fCanChangePassword;
477 lpp->fCanReusePw = Properties.u.UserProperties.KASINFO.fCanReusePasswords;
478 lpp->cdayPwExpires = Properties.u.UserProperties.KASINFO.cdayPwExpire;
479 lpp->cFailLock = Properties.u.UserProperties.KASINFO.cFailLogin;
480 lpp->csecFailLock = Properties.u.UserProperties.KASINFO.csecFailLoginLock;
481 lpp->fExpires = fIsValidDate (&Properties.u.UserProperties.KASINFO.timeExpires);
483 lpp->stExpires = Properties.u.UserProperties.KASINFO.timeExpires;
485 GetLocalSystemTime (&lpp->stExpires);
490 if (lpp->fCanChangePw != Properties.u.UserProperties.KASINFO.fCanChangePassword)
491 lpp->fCanChangePw_Mixed = TRUE;
492 if (lpp->fCanReusePw != Properties.u.UserProperties.KASINFO.fCanReusePasswords)
493 lpp->fCanReusePw_Mixed = TRUE;
494 if (lpp->cdayPwExpires != Properties.u.UserProperties.KASINFO.cdayPwExpire)
495 lpp->fPwExpires_Mixed = TRUE;
496 if (lpp->cFailLock != Properties.u.UserProperties.KASINFO.cFailLogin)
497 lpp->fFailLock_Mixed = TRUE;
498 if (lpp->csecFailLock != Properties.u.UserProperties.KASINFO.csecFailLoginLock)
499 lpp->fFailLock_Mixed = TRUE;
500 if (lpp->fExpires != fIsValidDate (&Properties.u.UserProperties.KASINFO.timeExpires))
501 lpp->fExpires_Mixed = TRUE;
502 if (memcmp (&lpp->stExpires, &Properties.u.UserProperties.KASINFO.timeExpires, sizeof(SYSTEMTIME)))
503 lpp->fExpires_Mixed = TRUE;
507 // Set up the dialog controls to reflect what we just learned
509 if (lpp->fCanChangePw_Mixed)
510 Set3State (hDlg, IDC_USER_CPW);
512 Set2State (hDlg, IDC_USER_CPW);
513 CheckDlgButton (hDlg, IDC_USER_CPW, (lpp->fCanChangePw_Mixed) ? BST_INDETERMINATE : lpp->fCanChangePw);
515 if (lpp->fCanReusePw_Mixed)
516 Set3State (hDlg, IDC_USER_RPW);
518 Set2State (hDlg, IDC_USER_RPW);
519 CheckDlgButton (hDlg, IDC_USER_RPW, (lpp->fCanReusePw_Mixed) ? BST_INDETERMINATE : lpp->fCanReusePw);
521 if (lpp->fPwExpires_Mixed)
522 Set3State (hDlg, IDC_USER_PWEXPIRES);
524 Set2State (hDlg, IDC_USER_PWEXPIRES);
525 CheckDlgButton (hDlg, IDC_USER_PWEXPIRES, (lpp->fPwExpires_Mixed) ? BST_INDETERMINATE : (lpp->cdayPwExpires == 0) ? BST_UNCHECKED : BST_CHECKED);
527 if (fHasSpinner (GetDlgItem (hDlg, IDC_USER_PWEXPIRATION)))
528 SP_SetPos (GetDlgItem (hDlg, IDC_USER_PWEXPIRATION), lpp->cdayPwExpires);
530 CreateSpinner (GetDlgItem (hDlg, IDC_USER_PWEXPIRATION), 10, FALSE, 1, lpp->cdayPwExpires, cdayPWEXPIRATION_MAX);
532 if (lpp->fExpires_Mixed)
533 Set3State (hDlg, IDC_USER_EXPIRES);
535 Set2State (hDlg, IDC_USER_EXPIRES);
536 CheckDlgButton (hDlg, IDC_USER_EXPIRES, (lpp->fExpires_Mixed) ? BST_INDETERMINATE : lpp->fExpires);
538 SYSTEMTIME stExpires;
539 if (fIsValidDate (&lpp->stExpires))
540 memcpy (&stExpires, &lpp->stExpires, sizeof(SYSTEMTIME));
543 GetSystemTime (&stExpires);
547 // Our controls use local time, not GMT--so translate the account expiration
548 // date before we display it
551 SystemTimeToFileTime (&stExpires, &ftGMT);
553 FileTimeToLocalFileTime (&ftGMT, &ftLocal);
555 FileTimeToSystemTime (&ftLocal, &stLocal);
557 DA_SetDate (GetDlgItem (hDlg, IDC_USER_EXPIRE_DATE), &stLocal);
558 TI_SetTime (GetDlgItem (hDlg, IDC_USER_EXPIRE_TIME), &stLocal);
560 if (lpp->fFailLock_Mixed)
561 Set3State (hDlg, IDC_USER_FAILLOCK);
563 Set2State (hDlg, IDC_USER_FAILLOCK);
564 CheckDlgButton (hDlg, IDC_USER_FAILLOCK, (lpp->fFailLock_Mixed) ? BST_INDETERMINATE : (lpp->cFailLock == 0) ? BST_UNCHECKED : BST_CHECKED);
566 if (fHasSpinner (GetDlgItem (hDlg, IDC_USER_FAILLOCK_COUNT)))
567 SP_SetPos (GetDlgItem (hDlg, IDC_USER_FAILLOCK_COUNT), lpp->cFailLock);
569 CreateSpinner (GetDlgItem (hDlg, IDC_USER_FAILLOCK_COUNT), 10, FALSE, 1, lpp->cFailLock, cFAILLOCKCOUNT_MAX);
571 CheckDlgButton (hDlg, IDC_USER_FAILLOCK_INFINITE, (lpp->csecFailLock == 0) ? TRUE : FALSE);
572 CheckDlgButton (hDlg, IDC_USER_FAILLOCK_FINITE, (lpp->csecFailLock != 0) ? TRUE : FALSE);
578 ULONG csecNow = lpp->csecFailLock;
579 ULONG csecMax = csecFAILLOCK_MAX;
580 SET_ELAPSED_TIME_FROM_SECONDS (&stMin, csecMin);
581 SET_ELAPSED_TIME_FROM_SECONDS (&stNow, csecNow);
582 SET_ELAPSED_TIME_FROM_SECONDS (&stMax, csecMax);
583 EL_SetRange (GetDlgItem (hDlg, IDC_USER_FAILLOCK_DURATION), &stMin, &stMax);
584 EL_SetTime (GetDlgItem (hDlg, IDC_USER_FAILLOCK_DURATION), &stNow);
586 UserProp_General_OnChangePw (hDlg);
587 UserProp_General_OnPwExpires (hDlg);
588 UserProp_General_OnFailLock (hDlg);
589 UserProp_General_OnFailLockTime (hDlg);
590 UserProp_General_OnExpiration (hDlg);
594 void UserProp_General_OnChangePw (HWND hDlg)
596 BOOL fEnable = (IsDlgButtonChecked (hDlg, IDC_USER_CPW) == BST_CHECKED);
597 EnableWindow (GetDlgItem (hDlg, IDC_USER_RPW), fEnable);
598 EnableWindow (GetDlgItem (hDlg, IDC_USER_PWEXPIRES), fEnable);
599 UserProp_General_OnPwExpires (hDlg);
603 void UserProp_General_OnPwExpires (HWND hDlg)
605 BOOL fEnable = IsWindowEnabled (GetDlgItem (hDlg, IDC_USER_PWEXPIRES)) && (IsDlgButtonChecked (hDlg, IDC_USER_PWEXPIRES) == BST_CHECKED);
606 EnableWindow (GetDlgItem (hDlg, IDC_USER_PWEXPIRATION), fEnable);
610 void UserProp_General_OnExpiration (HWND hDlg)
612 BOOL fEnable = (IsDlgButtonChecked (hDlg, IDC_USER_EXPIRES) == BST_CHECKED);
613 EnableWindow (GetDlgItem (hDlg, IDC_USER_EXPIRE_DATE), fEnable);
614 EnableWindow (GetDlgItem (hDlg, IDC_USER_EXPIRE_AT), fEnable);
615 EnableWindow (GetDlgItem (hDlg, IDC_USER_EXPIRE_TIME), fEnable);
619 void UserProp_General_OnFailLock (HWND hDlg)
621 BOOL fEnable = (IsDlgButtonChecked (hDlg, IDC_USER_FAILLOCK) == BST_CHECKED);
622 EnableWindow (GetDlgItem (hDlg, IDC_USER_FAILLOCK_COUNT), fEnable);
623 EnableWindow (GetDlgItem (hDlg, IDC_USER_FAILLOCK_INFINITE), fEnable);
624 EnableWindow (GetDlgItem (hDlg, IDC_USER_FAILLOCK_FINITE), fEnable);
625 UserProp_General_OnFailLockTime (hDlg);
629 void UserProp_General_OnFailLockTime (HWND hDlg)
631 BOOL fEnable = IsWindowEnabled (GetDlgItem (hDlg, IDC_USER_FAILLOCK_FINITE)) && (IsDlgButtonChecked (hDlg, IDC_USER_FAILLOCK_FINITE) == BST_CHECKED);
632 EnableWindow (GetDlgItem (hDlg, IDC_USER_FAILLOCK_DURATION), fEnable);
636 void UserProp_General_OnApply (HWND hDlg)
638 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
640 lpp->fApplyGeneral = TRUE;
642 lpp->fCanChangePw = IsDlgButtonChecked (hDlg, IDC_USER_CPW);
643 lpp->fCanChangePw_Mixed = (IsDlgButtonChecked (hDlg, IDC_USER_CPW) == BST_INDETERMINATE);
644 lpp->fCanReusePw = IsDlgButtonChecked (hDlg, IDC_USER_RPW);
645 lpp->fCanReusePw_Mixed = (IsDlgButtonChecked (hDlg, IDC_USER_RPW) == BST_INDETERMINATE);
647 lpp->fExpires = IsDlgButtonChecked (hDlg, IDC_USER_EXPIRES);
648 lpp->fExpires_Mixed = (IsDlgButtonChecked (hDlg, IDC_USER_EXPIRES) == BST_INDETERMINATE);
650 // Our controls use local time, not GMT--so translate the account expiration
651 // date after we read it from the controls
654 memset (&stLocal, 0x00, sizeof(SYSTEMTIME));
655 DA_GetDate (GetDlgItem (hDlg, IDC_USER_EXPIRE_DATE), &stLocal);
656 TI_GetTime (GetDlgItem (hDlg, IDC_USER_EXPIRE_TIME), &stLocal);
659 SystemTimeToFileTime (&stLocal, &ftLocal);
661 LocalFileTimeToFileTime (&ftLocal, &ftGMT);
662 FileTimeToSystemTime (&ftGMT, &lpp->stExpires);
664 if (!IsDlgButtonChecked (hDlg, IDC_USER_PWEXPIRES))
665 lpp->cdayPwExpires = 0;
667 lpp->cdayPwExpires = SP_GetPos (GetDlgItem (hDlg, IDC_USER_PWEXPIRATION));
668 lpp->fPwExpires_Mixed = (IsDlgButtonChecked (hDlg, IDC_USER_PWEXPIRES) == BST_INDETERMINATE);
670 if (!IsDlgButtonChecked (hDlg, IDC_USER_FAILLOCK))
673 lpp->cFailLock = SP_GetPos (GetDlgItem (hDlg, IDC_USER_FAILLOCK_COUNT));
674 lpp->fFailLock_Mixed = (IsDlgButtonChecked (hDlg, IDC_USER_FAILLOCK) == BST_INDETERMINATE);
676 if (!IsDlgButtonChecked (hDlg, IDC_USER_FAILLOCK_FINITE))
677 lpp->csecFailLock = 0;
680 SYSTEMTIME stFailLock;
681 EL_GetTime (GetDlgItem (hDlg, IDC_USER_FAILLOCK_DURATION), &stFailLock);
682 lpp->csecFailLock = GET_SECONDS_FROM_ELAPSED_TIME (&stFailLock);
687 void UserProp_General_OnUnlock (HWND hDlg)
689 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
693 asc_AsidListCopy (&pCopy, &lpp->pUserList);
694 StartTask (taskUSER_UNLOCK, NULL, pCopy);
699 void UserProp_General_OnChangePwNow (HWND hDlg)
701 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
702 if (lpp->pUserList && (lpp->pUserList->cEntries == 1))
704 User_ShowChangePassword (hDlg, lpp->pUserList->aEntries[0].idObject);
709 BOOL CALLBACK UserProp_Advanced_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
711 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
713 if (AfsAppLib_HandleHelp ((lpp && lpp->fMachine) ? IDD_MACHINE_ADVANCED : IDD_USER_ADVANCED, hDlg, msg, wp, lp))
718 case WM_INITDIALOG_SHEET:
719 if (lpp && lpp->pUserList && !lpp->fShowModal)
721 if (lpp->pUserList->cEntries == 1)
722 WindowList_Add (hDlg, wltUSER_PROPERTIES, lpp->pUserList->aEntries[0].idObject);
723 else // (lpp->pUserList->cEntries > 1)
724 WindowList_Add (hDlg, wltUSER_PROPERTIES, 0);
728 case WM_DESTROY_SHEET:
729 WindowList_Remove (hDlg);
730 if (lpp && lpp->fDeleteMeOnClose)
731 User_FreeProperties (lpp);
735 UserProp_Advanced_OnInitDialog (hDlg);
739 UserProp_Advanced_OnDestroy (hDlg);
742 case WM_ASC_NOTIFY_OBJECT:
743 UserProp_Advanced_UpdateDialog (hDlg);
750 UserProp_Advanced_OnApply (hDlg);
754 UserProp_Advanced_OnGrantTickets (hDlg);
755 PropSheetChanged (hDlg);
758 case IDC_USER_GROUP_HASQUOTA:
759 UserProp_Advanced_OnHasGroupQuota (hDlg);
760 PropSheetChanged (hDlg);
764 UserProp_Advanced_OnAdmin (hDlg);
765 PropSheetChanged (hDlg);
768 case IDC_USER_NOSEAL:
769 case IDC_USER_LIFETIME:
770 case IDC_USER_GROUP_QUOTA:
771 case IDC_USER_PERM_STATUS:
772 case IDC_USER_PERM_OWNED:
773 case IDC_USER_PERM_MEMBER:
774 PropSheetChanged (hDlg);
784 void UserProp_Advanced_OnInitDialog (HWND hDlg)
786 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
788 // Indicate we want to know if anything changes with these users
792 LPOBJECT_LISTEN_PARAMS pTask = New (OBJECT_LISTEN_PARAMS);
793 memset (pTask, 0x00, sizeof(OBJECT_LISTEN_PARAMS));
794 pTask->hNotify = hDlg;
795 asc_AsidListCopy (&pTask->pAsidList, &lpp->pUserList);
796 StartTask (taskOBJECT_LISTEN, NULL, pTask);
799 // Fix the name shown on the dialog
801 UserProp_UpdateName (hDlg);
803 // Fill in the information about the selected users
805 UserProp_Advanced_UpdateDialog (hDlg);
809 void UserProp_Advanced_OnDestroy (HWND hDlg)
811 // Indicate we no longer care if anything changes with these users
813 LPOBJECT_LISTEN_PARAMS pTask = New (OBJECT_LISTEN_PARAMS);
814 memset (pTask, 0x00, sizeof(OBJECT_LISTEN_PARAMS));
815 pTask->hNotify = hDlg;
816 StartTask (taskOBJECT_LISTEN, NULL, pTask);
820 void UserProp_Advanced_OnGrantTickets (HWND hDlg)
822 BOOL fEnable = (IsDlgButtonChecked (hDlg, IDC_USER_TGS) == BST_CHECKED);
823 EnableWindow (GetDlgItem (hDlg, IDC_USER_LIFETIME), fEnable);
827 void UserProp_Advanced_OnHasGroupQuota (HWND hDlg)
829 BOOL fEnable = (IsDlgButtonChecked (hDlg, IDC_USER_GROUP_HASQUOTA) == BST_CHECKED);
830 if (!IsWindowEnabled (GetDlgItem (hDlg, IDC_USER_GROUP_HASQUOTA)))
832 EnableWindow (GetDlgItem (hDlg, IDC_USER_GROUP_QUOTA), fEnable);
836 void UserProp_Advanced_OnAdmin (HWND hDlg)
838 BOOL fAdmin = (IsDlgButtonChecked (hDlg, IDC_USER_ADMIN) == BST_CHECKED);
839 EnableWindow (GetDlgItem (hDlg, IDC_USER_GROUP_HASQUOTA), !fAdmin);
843 CheckDlgButton (hDlg, IDC_USER_GROUP_HASQUOTA, TRUE);
844 SP_SetPos (GetDlgItem (hDlg, IDC_USER_GROUP_QUOTA), 9999);
847 UserProp_Advanced_OnHasGroupQuota (hDlg);
851 void UserProp_Advanced_UpdateDialog (HWND hDlg)
853 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
855 // Fill in the user's key. If this dialog represents more than one
856 // user, put in some stock text instead.
858 if ((lpp->pUserList) && (lpp->pUserList->cEntries > 1))
860 TCHAR szText[ cchRESOURCE ];
861 GetString (szText, IDS_USER_KEY_MULTIPLE);
862 SetDlgItemText (hDlg, IDC_USER_KEY, szText);
864 else if (lpp->pUserList && (lpp->pUserList->cEntries == 1))
867 ASOBJPROP Properties;
868 if (!asc_ObjectPropertiesGet_Fast (g.idClient, g.idCell, lpp->pUserList->aEntries[ 0 ].idObject, &Properties, &status))
870 TCHAR szText[ cchRESOURCE ];
871 GetString (szText, IDS_USER_KEY_UNKNOWN);
872 SetDlgItemText (hDlg, IDC_USER_KEY, szText);
874 else if (!Properties.u.UserProperties.fHaveKasInfo)
876 TCHAR szText[ cchRESOURCE ];
877 GetString (szText, IDS_USER_KEY_UNKNOWN);
878 SetDlgItemText (hDlg, IDC_USER_KEY, szText);
882 TCHAR szReadableKey[ cchRESOURCE ];
883 FormatServerKey (szReadableKey, Properties.u.UserProperties.KASINFO.keyData);
885 LPTSTR pszText = FormatString (IDS_USER_KEY, TEXT("%s%lu%lu"), szReadableKey, Properties.u.UserProperties.KASINFO.keyVersion, Properties.u.UserProperties.KASINFO.dwKeyChecksum);
886 SetDlgItemText (hDlg, IDC_USER_KEY, pszText);
887 FreeString (pszText);
891 // Fill in the other fields
893 BOOL fGotAnyData = FALSE;
895 for (size_t ii = 0; lpp->pUserList && (ii < lpp->pUserList->cEntries); ++ii)
898 ASOBJPROP Properties;
899 if (!asc_ObjectPropertiesGet_Fast (g.idClient, g.idCell, lpp->pUserList->aEntries[ ii ].idObject, &Properties, &status))
904 lpp->fSeal = Properties.u.UserProperties.KASINFO.fEncrypt;
905 lpp->fAdmin = Properties.u.UserProperties.KASINFO.fIsAdmin;
906 lpp->fGrantTickets = Properties.u.UserProperties.KASINFO.fCanGetTickets;
907 lpp->csecLifetime = Properties.u.UserProperties.KASINFO.csecTicketLifetime;
908 lpp->cGroupQuota = Properties.u.UserProperties.PTSINFO.cgroupCreationQuota;
909 lpp->aaStatus = Properties.u.UserProperties.PTSINFO.aaListStatus;
910 lpp->aaOwned = Properties.u.UserProperties.PTSINFO.aaGroupsOwned;
911 lpp->aaMember = Properties.u.UserProperties.PTSINFO.aaMembership;
914 else // (fGotAnyData)
916 if (lpp->fSeal != Properties.u.UserProperties.KASINFO.fEncrypt)
917 lpp->fSeal_Mixed = TRUE;
918 if (lpp->fAdmin != Properties.u.UserProperties.KASINFO.fIsAdmin)
919 lpp->fAdmin_Mixed = TRUE;
920 if (lpp->fGrantTickets != Properties.u.UserProperties.KASINFO.fCanGetTickets)
921 lpp->fGrantTickets_Mixed = TRUE;
922 if (lpp->csecLifetime != (ULONG)Properties.u.UserProperties.KASINFO.csecTicketLifetime)
923 lpp->fGrantTickets_Mixed = TRUE;
924 if (lpp->cGroupQuota != Properties.u.UserProperties.PTSINFO.cgroupCreationQuota)
925 lpp->fGroupQuota_Mixed = TRUE;
926 if (lpp->aaStatus != Properties.u.UserProperties.PTSINFO.aaListStatus)
927 lpp->fStatus_Mixed = TRUE;
928 if (lpp->aaOwned != Properties.u.UserProperties.PTSINFO.aaGroupsOwned)
929 lpp->fOwned_Mixed = TRUE;
930 if (lpp->aaMember != Properties.u.UserProperties.PTSINFO.aaMembership)
931 lpp->fMember_Mixed = TRUE;
935 // Fill in the dialog's state
937 CheckDlgButton (hDlg, IDC_USER_CREATE_KAS, lpp->fCreateKAS);
938 CheckDlgButton (hDlg, IDC_USER_CREATE_PTS, lpp->fCreatePTS);
940 if (lpp->fSeal_Mixed)
941 Set3State (hDlg, IDC_USER_NOSEAL);
943 Set2State (hDlg, IDC_USER_NOSEAL);
944 CheckDlgButton (hDlg, IDC_USER_NOSEAL, (lpp->fSeal_Mixed) ? BST_INDETERMINATE : (!lpp->fSeal));
946 if (lpp->fAdmin_Mixed)
947 Set3State (hDlg, IDC_USER_ADMIN);
949 Set2State (hDlg, IDC_USER_ADMIN);
950 CheckDlgButton (hDlg, IDC_USER_ADMIN, (lpp->fAdmin_Mixed) ? BST_INDETERMINATE : lpp->fAdmin);
952 if (lpp->fGrantTickets_Mixed)
953 Set3State (hDlg, IDC_USER_TGS);
955 Set2State (hDlg, IDC_USER_TGS);
956 CheckDlgButton (hDlg, IDC_USER_TGS, (lpp->fGrantTickets_Mixed) ? BST_INDETERMINATE : lpp->fGrantTickets);
962 ULONG csecNow = lpp->csecLifetime;
963 ULONG csecMax = csecTICKETLIFETIME_MAX;
964 SET_ELAPSED_TIME_FROM_SECONDS (&stMin, csecMin);
965 SET_ELAPSED_TIME_FROM_SECONDS (&stNow, csecNow);
966 SET_ELAPSED_TIME_FROM_SECONDS (&stMax, csecMax);
967 EL_SetRange (GetDlgItem (hDlg, IDC_USER_LIFETIME), &stMin, &stMax);
968 EL_SetTime (GetDlgItem (hDlg, IDC_USER_LIFETIME), &stNow);
970 if (lpp->fGroupQuota_Mixed)
971 Set3State (hDlg, IDC_USER_GROUP_HASQUOTA);
973 Set2State (hDlg, IDC_USER_GROUP_HASQUOTA);
974 CheckDlgButton (hDlg, IDC_USER_GROUP_HASQUOTA, (lpp->fGroupQuota_Mixed) ? BST_INDETERMINATE : (lpp->cGroupQuota == cGROUPQUOTA_INFINITE) ? BST_UNCHECKED : BST_CHECKED);
976 if (fHasSpinner (GetDlgItem (hDlg, IDC_USER_GROUP_QUOTA)))
977 SP_SetPos (GetDlgItem (hDlg, IDC_USER_GROUP_QUOTA), lpp->cGroupQuota);
979 CreateSpinner (GetDlgItem (hDlg, IDC_USER_GROUP_QUOTA), 10, FALSE, cGROUPQUOTA_MIN, lpp->cGroupQuota, cGROUPQUOTA_MAX);
981 UserProp_Advanced_UpdateDialog_Perm (hDlg, IDC_USER_PERM_STATUS, lpp->aaStatus, lpp->fStatus_Mixed);
982 UserProp_Advanced_UpdateDialog_Perm (hDlg, IDC_USER_PERM_OWNED, lpp->aaOwned, lpp->fOwned_Mixed);
983 UserProp_Advanced_UpdateDialog_Perm (hDlg, IDC_USER_PERM_MEMBER, lpp->aaMember, lpp->fMember_Mixed);
985 UserProp_Advanced_OnGrantTickets (hDlg);
986 UserProp_Advanced_OnHasGroupQuota (hDlg);
987 UserProp_Advanced_OnAdmin (hDlg);
991 void UserProp_Advanced_UpdateDialog_Perm (HWND hDlg, int idc, ACCOUNTACCESS aa, BOOL fMixed)
993 CB_StartChange (GetDlgItem (hDlg, idc), TRUE);
994 CB_AddItem (GetDlgItem (hDlg, idc), IDS_ACCOUNTACCESS_OWNER, aaOWNER_ONLY);
995 CB_AddItem (GetDlgItem (hDlg, idc), IDS_ACCOUNTACCESS_ANYONE, aaANYONE);
997 CB_AddItem (GetDlgItem (hDlg, idc), IDS_ACCOUNTACCESS_MIXED, (LPARAM)-1);
998 CB_EndChange (GetDlgItem (hDlg, idc), TRUE);
1000 LPARAM lpSelect = (fMixed) ? ((LPARAM)-1) : (LPARAM)aa;
1001 CB_SetSelectedByData (GetDlgItem (hDlg, idc), lpSelect);
1005 void UserProp_Advanced_OnApply (HWND hDlg)
1007 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
1009 lpp->fApplyAdvanced = TRUE;
1010 lpp->fCreateKAS = IsDlgButtonChecked (hDlg, IDC_USER_CREATE_KAS);
1011 lpp->fCreatePTS = IsDlgButtonChecked (hDlg, IDC_USER_CREATE_PTS);
1013 if (IsWindow (GetDlgItem (hDlg, IDC_USER_NOSEAL)))
1015 lpp->fSeal = !IsDlgButtonChecked (hDlg, IDC_USER_NOSEAL);
1016 lpp->fSeal_Mixed = (IsDlgButtonChecked (hDlg, IDC_USER_NOSEAL) == BST_INDETERMINATE);
1019 if (IsWindow (GetDlgItem (hDlg, IDC_USER_ADMIN)))
1021 lpp->fAdmin = IsDlgButtonChecked (hDlg, IDC_USER_ADMIN);
1022 lpp->fAdmin_Mixed = (IsDlgButtonChecked (hDlg, IDC_USER_ADMIN) == BST_INDETERMINATE);
1025 if (IsWindow (GetDlgItem (hDlg, IDC_USER_TGS)))
1027 lpp->fGrantTickets = IsDlgButtonChecked (hDlg, IDC_USER_TGS);
1028 lpp->fGrantTickets_Mixed = (IsDlgButtonChecked (hDlg, IDC_USER_TGS) == BST_INDETERMINATE);
1031 if (IsWindow (GetDlgItem (hDlg, IDC_USER_LIFETIME)))
1033 SYSTEMTIME stLifetime;
1034 EL_GetTime (GetDlgItem (hDlg, IDC_USER_LIFETIME), &stLifetime);
1035 lpp->csecLifetime = GET_SECONDS_FROM_ELAPSED_TIME (&stLifetime);
1038 if (IsWindow (GetDlgItem (hDlg, IDC_USER_GROUP_HASQUOTA)))
1040 if (!IsDlgButtonChecked (hDlg, IDC_USER_GROUP_HASQUOTA))
1041 lpp->cGroupQuota = cGROUPQUOTA_INFINITE;
1042 else // (IsDlgButtonChecked (hDlg, IDC_USER_GROUP_HASQUOTA))
1043 lpp->cGroupQuota = SP_GetPos (GetDlgItem (hDlg, IDC_USER_GROUP_QUOTA));
1044 lpp->fGroupQuota_Mixed = (IsDlgButtonChecked (hDlg, IDC_USER_GROUP_HASQUOTA) == BST_INDETERMINATE);
1047 lpp->aaStatus = (ACCOUNTACCESS)CB_GetSelectedData (GetDlgItem (hDlg, IDC_USER_PERM_STATUS));
1048 lpp->fStatus_Mixed = (lpp->aaStatus == (ACCOUNTACCESS)-1) ? TRUE : FALSE;
1050 lpp->aaOwned = (ACCOUNTACCESS)CB_GetSelectedData (GetDlgItem (hDlg, IDC_USER_PERM_OWNED));
1051 lpp->fOwned_Mixed = (lpp->aaOwned == (ACCOUNTACCESS)-1) ? TRUE : FALSE;
1053 lpp->aaMember = (ACCOUNTACCESS)CB_GetSelectedData (GetDlgItem (hDlg, IDC_USER_PERM_MEMBER));
1054 lpp->fMember_Mixed = (lpp->aaMember == (ACCOUNTACCESS)-1) ? TRUE : FALSE;
1058 BOOL CALLBACK UserProp_Member_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
1060 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
1062 if (AfsAppLib_HandleHelp ((lpp && lpp->fMachine) ? IDD_MACHINE_MEMBER : IDD_USER_MEMBER, hDlg, msg, wp, lp))
1068 UserProp_Member_OnInitDialog (hDlg);
1072 UserProp_Member_OnDestroy (hDlg);
1077 if ((ptp = (LPTASKPACKET)lp) != NULL)
1079 if (ptp->idTask == taskGROUP_SEARCH)
1080 UserProp_Member_OnEndTask_GroupSearch (hDlg, ptp);
1081 FreeTaskPacket (ptp);
1089 UserProp_Member_OnApply (hDlg);
1092 case IDC_USER_SHOW_MEMBER:
1093 case IDC_USER_SHOW_OWNER:
1094 UserProp_Member_OnShowType (hDlg);
1097 case IDC_MEMBER_ADD:
1098 UserProp_Member_OnAdd (hDlg);
1101 case IDC_MEMBER_REMOVE:
1102 UserProp_Member_OnRemove (hDlg);
1108 switch (((LPNMHDR)lp)->code)
1110 case FLN_ITEMSELECT:
1111 UserProp_Member_OnSelect (hDlg);
1120 void UserProp_Member_OnInitDialog (HWND hDlg)
1122 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
1124 // If we've come in here with a valid set of groups to display,
1125 // copy those. We'll need the copies if the user cancels the dialog.
1127 SetWindowData (hDlg, GWD_ASIDLIST_MEMBER, (LPARAM)(lpp->pGroupsMember));
1128 SetWindowData (hDlg, GWD_ASIDLIST_OWNER, (LPARAM)(lpp->pGroupsOwner));
1131 if ((pList = lpp->pGroupsMember) != NULL)
1132 asc_AsidListCopy (&lpp->pGroupsMember, &pList);
1133 if ((pList = lpp->pGroupsOwner) != NULL)
1134 asc_AsidListCopy (&lpp->pGroupsOwner, &pList);
1136 // If this prop sheet reflects more than one user, disable the
1137 // Ownership button (we do this primarily because the Add/Remove
1138 // buttons have no straight-forward semantic for that case).
1139 // Actually, instead of disabling the thing, we'll hide the buttons
1140 // entirely and resize the list/move the title.
1142 if (lpp->pUserList && (lpp->pUserList->cEntries > 1))
1144 ShowWindow (GetDlgItem (hDlg, IDC_USER_SHOW_MEMBER), SW_HIDE);
1145 ShowWindow (GetDlgItem (hDlg, IDC_USER_SHOW_OWNER), SW_HIDE);
1148 GetRectInParent (GetDlgItem (hDlg, IDC_USER_SHOW_MEMBER), &rButton);
1151 GetRectInParent (GetDlgItem (hDlg, IDC_GROUPS_TITLE), &rTitle);
1154 GetRectInParent (GetDlgItem (hDlg, IDC_GROUPS_LIST), &rList);
1156 LONG cyDelta = rTitle.top - rButton.top;
1158 SetWindowPos (GetDlgItem (hDlg, IDC_GROUPS_TITLE), NULL,
1159 rTitle.left, rTitle.top-cyDelta,
1160 rTitle.right-rTitle.left, rTitle.bottom-rTitle.top,
1161 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
1163 SetWindowPos (GetDlgItem (hDlg, IDC_GROUPS_LIST), NULL,
1164 rList.left, rList.top-cyDelta,
1165 rList.right-rList.left, rList.bottom-rList.top+cyDelta,
1166 SWP_NOZORDER | SWP_NOACTIVATE);
1169 // Apply an imagelist to the dialog's fastlist
1171 FastList_SetImageLists (GetDlgItem (hDlg, IDC_GROUPS_LIST), AfsAppLib_CreateImageList (FALSE), NULL);
1173 // Select a checkbox and pretend that the user clicked it; that will
1174 // make the dialog automatically re-populate the list of groups
1176 CheckDlgButton (hDlg, IDC_USER_SHOW_MEMBER, TRUE);
1177 UserProp_Member_OnShowType (hDlg);
1181 void UserProp_Member_OnDestroy (HWND hDlg)
1183 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
1186 if ((pList = (LPASIDLIST)GetWindowData (hDlg, GWD_ASIDLIST_MEMBER)) != NULL)
1187 lpp->pGroupsMember = pList;
1188 if ((pList = (LPASIDLIST)GetWindowData (hDlg, GWD_ASIDLIST_OWNER)) != NULL)
1189 lpp->pGroupsOwner = pList;
1193 void UserProp_Member_OnShowType (HWND hDlg)
1195 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
1197 // If we've already obtained the list of groups we should be displaying,
1200 if (IsDlgButtonChecked (hDlg, IDC_USER_SHOW_MEMBER))
1202 if (lpp->pGroupsMember)
1204 UserProp_Member_PopulateList (hDlg);
1208 else // (IsDlgButtonChecked (hDlg, IDC_USER_SHOW_OWNER))
1210 if (lpp->pGroupsOwner)
1212 UserProp_Member_PopulateList (hDlg);
1217 // Otherwise, we'll have to start a background task to do the querying.
1218 // Change the text above the list to "Querying...", disable the buttons,
1219 // and remove any items in the list.
1221 if (!lpp->pUserList)
1223 // Generate a few empty ASID list; this is a new user account we're
1224 // displaying, and the caller hasn't yet added any groups.
1226 if (!lpp->pGroupsMember)
1228 if (!asc_AsidListCreate (&lpp->pGroupsMember))
1231 if (!lpp->pGroupsOwner)
1233 if (!asc_AsidListCreate (&lpp->pGroupsOwner))
1236 UserProp_Member_OnShowType (hDlg);
1238 else // (lpp->pUserList)
1240 TCHAR szTitle[ cchRESOURCE ];
1241 GetString (szTitle, IDS_QUERYING_LONG);
1242 SetDlgItemText (hDlg, IDC_GROUPS_TITLE, szTitle);
1244 EnableWindow (GetDlgItem (hDlg, IDC_MEMBER_ADD), FALSE);
1245 EnableWindow (GetDlgItem (hDlg, IDC_MEMBER_REMOVE), FALSE);
1247 FastList_RemoveAll (GetDlgItem (hDlg, IDC_GROUPS_LIST));
1249 // Then start a background task to grab an ASIDLIST of groups which
1250 // match the specified search criteria.
1252 LPGROUP_SEARCH_PARAMS pTask = New (GROUP_SEARCH_PARAMS);
1253 asc_AsidListCopy (&pTask->pUserList, &lpp->pUserList);
1254 pTask->fMembership = IsDlgButtonChecked (hDlg, IDC_USER_SHOW_MEMBER);
1255 StartTask (taskGROUP_SEARCH, hDlg, pTask);
1260 void UserProp_Member_OnEndTask_GroupSearch (HWND hDlg, LPTASKPACKET ptp)
1262 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
1264 // The search is complete. If we've just obtained an ASIDLIST successfully,
1265 // associate it with the dialog and repopulate the display.
1267 if (ptp->rc && TASKDATA(ptp)->pAsidList)
1269 if (TASKDATA(ptp)->fMembership)
1271 if (!lpp->pGroupsMember)
1273 asc_AsidListCopy (&lpp->pGroupsMember, &TASKDATA(ptp)->pAsidList);
1274 UserProp_Member_PopulateList (hDlg);
1277 else // (!TASKDATA(ptp)->fMembership)
1279 if (!lpp->pGroupsOwner)
1281 asc_AsidListCopy (&lpp->pGroupsOwner, &TASKDATA(ptp)->pAsidList);
1282 UserProp_Member_PopulateList (hDlg);
1289 void UserProp_Member_PopulateList (HWND hDlg)
1291 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
1293 // Clear the list of groups
1295 HWND hList = GetDlgItem (hDlg, IDC_GROUPS_LIST);
1296 FastList_Begin (hList);
1297 FastList_RemoveAll (hList);
1299 // We should have an ASIDLIST associated with the dialog to reflect
1300 // which groups to display. Find it, and repopulate the list on the display.
1302 LPASIDLIST pGroupList;
1303 if (IsDlgButtonChecked (hDlg, IDC_USER_SHOW_MEMBER))
1304 pGroupList = lpp->pGroupsMember;
1305 else // (!IsDlgButtonChecked (hDlg, IDC_USER_SHOW_OWNER))
1306 pGroupList = lpp->pGroupsOwner;
1310 TCHAR szMixed[ cchRESOURCE ];
1311 GetString (szMixed, IDS_MEMBER_MIXED);
1313 for (size_t ii = 0; ii < pGroupList->cEntries; ++ii)
1316 TCHAR szName[ cchNAME ];
1317 if (!asc_ObjectNameGet_Fast (g.idClient, g.idCell, pGroupList->aEntries[ ii ].idObject, szName, &status))
1319 if (!pGroupList->aEntries[ ii ].lParam)
1320 lstrcat (szName, szMixed);
1322 FASTLISTADDITEM flai;
1323 memset (&flai, 0x00, sizeof(flai));
1324 flai.iFirstImage = imageGROUP;
1325 flai.iSecondImage = IMAGE_NOIMAGE;
1326 flai.pszText = szName;
1327 flai.lParam = (LPARAM)(pGroupList->aEntries[ ii ].idObject);
1328 FastList_AddItem (hList, &flai);
1332 FastList_End (hList);
1334 // Fix the buttons, and the text at the top of the list
1336 TCHAR szTitle[ cchRESOURCE ];
1339 if (IsDlgButtonChecked (hDlg, IDC_USER_SHOW_MEMBER))
1341 if (!lpp->pUserList)
1342 GetString (szTitle, IDS_NEWMACHINE_SHOW_MEMBER_TITLE);
1343 else if (lpp->pUserList->cEntries == 1)
1344 GetString (szTitle, IDS_MACHINE_SHOW_MEMBER_TITLE);
1346 GetString (szTitle, IDS_MACHINE_SHOW_MEMBER_TITLE_MULTIPLE);
1350 if (!lpp->pUserList)
1351 GetString (szTitle, IDS_NEWMACHINE_SHOW_OWNER_TITLE);
1353 GetString (szTitle, IDS_MACHINE_SHOW_OWNER_TITLE);
1358 if (IsDlgButtonChecked (hDlg, IDC_USER_SHOW_MEMBER))
1360 if (!lpp->pUserList)
1361 GetString (szTitle, IDS_NEWUSER_SHOW_MEMBER_TITLE);
1362 else if (lpp->pUserList->cEntries == 1)
1363 GetString (szTitle, IDS_USER_SHOW_MEMBER_TITLE);
1365 GetString (szTitle, IDS_USER_SHOW_MEMBER_TITLE_MULTIPLE);
1369 if (!lpp->pUserList)
1370 GetString (szTitle, IDS_NEWUSER_SHOW_OWNER_TITLE);
1372 GetString (szTitle, IDS_USER_SHOW_OWNER_TITLE);
1376 SetDlgItemText (hDlg, IDC_GROUPS_TITLE, szTitle);
1378 EnableWindow (GetDlgItem (hDlg, IDC_MEMBER_ADD), TRUE);
1379 UserProp_Member_OnSelect (hDlg);
1383 void UserProp_Member_OnSelect (HWND hDlg)
1385 BOOL fEnable = IsWindowEnabled (GetDlgItem (hDlg, IDC_MEMBER_ADD));
1386 if (fEnable && !FastList_FindFirstSelected (GetDlgItem (hDlg, IDC_GROUPS_LIST)))
1388 EnableWindow (GetDlgItem (hDlg, IDC_MEMBER_REMOVE), fEnable);
1392 void UserProp_Member_OnAdd (HWND hDlg)
1394 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
1396 LPBROWSE_PARAMS pParams = New (BROWSE_PARAMS);
1397 memset (pParams, 0x00, sizeof(BROWSE_PARAMS));
1398 pParams->hParent = GetParent(hDlg);
1399 pParams->iddForHelp = IsDlgButtonChecked (hDlg, IDC_USER_SHOW_MEMBER) ? IDD_BROWSE_JOIN : IDD_BROWSE_OWN;
1400 pParams->idsTitle = IsDlgButtonChecked (hDlg, IDC_USER_SHOW_MEMBER) ? IDS_BROWSE_TITLE_JOIN : IDS_BROWSE_TITLE_OWN;
1401 pParams->idsPrompt = IsDlgButtonChecked (hDlg, IDC_USER_SHOW_MEMBER) ? IDS_BROWSE_PROMPT_JOIN : IDS_BROWSE_PROMPT_OWN;
1402 pParams->idsCheck = IsDlgButtonChecked (hDlg, IDC_USER_SHOW_MEMBER) ? IDS_BROWSE_CHECK_JOIN : IDS_BROWSE_CHECK_OWN;
1403 pParams->TypeToShow = TYPE_GROUP;
1404 pParams->fAllowMultiple = TRUE;
1406 // First prepare an ASIDLIST which reflects only the groups which
1407 // all selected users own/are members in.
1409 LPASIDLIST pGroupList;
1410 if (IsDlgButtonChecked (hDlg, IDC_USER_SHOW_MEMBER))
1411 pGroupList = lpp->pGroupsMember;
1412 else // (!IsDlgButtonChecked (hDlg, IDC_USER_SHOW_OWNER))
1413 pGroupList = lpp->pGroupsOwner;
1417 asc_AsidListCreate (&pParams->pObjectsToSkip);
1418 for (size_t ii = 0; ii < pGroupList->cEntries; ++ii)
1420 if (pGroupList->aEntries[ ii ].lParam) // all users have this group?
1421 asc_AsidListAddEntry (&pParams->pObjectsToSkip, pGroupList->aEntries[ ii ].idObject, 0);
1425 if (ShowBrowseDialog (pParams))
1427 // The user added some groups; modify pGroupList (and the dialog,
1428 // at the same time).
1430 HWND hList = GetDlgItem (hDlg, IDC_GROUPS_LIST);
1431 FastList_Begin (hList);
1433 for (size_t ii = 0; ii < pParams->pObjectsSelected->cEntries; ++ii)
1435 ASID idGroup = pParams->pObjectsSelected->aEntries[ ii ].idObject;
1437 // The user has chosen to add group {idGroup}. If it's not in our
1438 // list at all, add it (and a new entry for the display). If it
1439 // *is* in our list, make sure its lParam is 1--indicating all users
1440 // get it--and modify the display's entry to remove the "(some)"
1444 if (!asc_AsidListTest (&pGroupList, idGroup, &lParam))
1447 TCHAR szName[ cchNAME ];
1448 if (!asc_ObjectNameGet_Fast (g.idClient, g.idCell, idGroup, szName, &status))
1451 asc_AsidListAddEntry (&pGroupList, idGroup, TRUE);
1453 FASTLISTADDITEM flai;
1454 memset (&flai, 0x00, sizeof(flai));
1455 flai.iFirstImage = imageGROUP;
1456 flai.iSecondImage = IMAGE_NOIMAGE;
1457 flai.pszText = szName;
1458 flai.lParam = (LPARAM)idGroup;
1459 FastList_AddItem (hList, &flai);
1460 PropSheetChanged (hDlg);
1465 TCHAR szName[ cchNAME ];
1466 if (!asc_ObjectNameGet_Fast (g.idClient, g.idCell, idGroup, szName, &status))
1469 asc_AsidListSetEntryParam (&pGroupList, idGroup, TRUE);
1472 if ((hItem = FastList_FindItem (hList, (LPARAM)idGroup)) != NULL)
1473 FastList_SetItemText (hList, hItem, 0, szName);
1474 PropSheetChanged (hDlg);
1478 if (IsDlgButtonChecked (hDlg, IDC_USER_SHOW_MEMBER))
1479 lpp->pGroupsMember = pGroupList;
1480 else // (!IsDlgButtonChecked (hDlg, IDC_USER_SHOW_OWNER))
1481 lpp->pGroupsOwner = pGroupList;
1483 FastList_End (hList);
1486 if (pParams->pObjectsToSkip)
1487 asc_AsidListFree (&pParams->pObjectsToSkip);
1488 if (pParams->pObjectsSelected)
1489 asc_AsidListFree (&pParams->pObjectsSelected);
1494 void UserProp_Member_OnRemove (HWND hDlg)
1496 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
1498 // Find which list-of-groups is currently being displayed.
1500 LPASIDLIST pGroupList;
1501 if (IsDlgButtonChecked (hDlg, IDC_USER_SHOW_MEMBER))
1502 pGroupList = lpp->pGroupsMember;
1503 else // (!IsDlgButtonChecked (hDlg, IDC_USER_SHOW_OWNER))
1504 pGroupList = lpp->pGroupsOwner;
1506 // The user wants to remove some groups; modify pGroupList
1507 // (and the dialog, at the same time).
1509 HWND hList = GetDlgItem (hDlg, IDC_GROUPS_LIST);
1510 FastList_Begin (hList);
1513 while ((hItem = FastList_FindFirstSelected (hList)) != NULL)
1515 ASID idGroup = (ASID)FastList_GetItemParam (hList, hItem);
1516 FastList_RemoveItem (hList, hItem);
1517 asc_AsidListRemoveEntry (&pGroupList, idGroup);
1518 PropSheetChanged (hDlg);
1521 if (IsDlgButtonChecked (hDlg, IDC_USER_SHOW_MEMBER))
1522 lpp->pGroupsMember = pGroupList;
1523 else // (!IsDlgButtonChecked (hDlg, IDC_USER_SHOW_OWNER))
1524 lpp->pGroupsOwner = pGroupList;
1526 FastList_End (hList);
1530 void UserProp_Member_OnApply (HWND hDlg)
1532 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
1534 // Free the old backup ASIDLIST copies we attached to the dialog during
1535 // WM_INITDIALOG processing.
1538 if ((pList = (LPASIDLIST)GetWindowData (hDlg, GWD_ASIDLIST_MEMBER)) != NULL)
1539 asc_AsidListFree (&pList);
1540 if ((pList = (LPASIDLIST)GetWindowData (hDlg, GWD_ASIDLIST_OWNER)) != NULL)
1541 asc_AsidListFree (&pList);
1542 SetWindowData (hDlg, GWD_ASIDLIST_MEMBER, 0);
1543 SetWindowData (hDlg, GWD_ASIDLIST_OWNER, 0);
1547 // Start a background task to update the membership and ownership lists
1549 if (lpp->pGroupsMember)
1551 LPUSER_GROUPLIST_SET_PARAMS pTask = New (USER_GROUPLIST_SET_PARAMS);
1552 memset (pTask, 0x00, sizeof(USER_GROUPLIST_SET_PARAMS));
1553 asc_AsidListCopy (&pTask->pUsers, &lpp->pUserList);
1554 asc_AsidListCopy (&pTask->pGroups, &lpp->pGroupsMember);
1555 pTask->fMembership = TRUE;
1556 StartTask (taskUSER_GROUPLIST_SET, NULL, pTask);
1558 if (lpp->pGroupsOwner)
1560 LPUSER_GROUPLIST_SET_PARAMS pTask = New (USER_GROUPLIST_SET_PARAMS);
1561 memset (pTask, 0x00, sizeof(USER_GROUPLIST_SET_PARAMS));
1562 asc_AsidListCopy (&pTask->pUsers, &lpp->pUserList);
1563 asc_AsidListCopy (&pTask->pGroups, &lpp->pGroupsOwner);
1564 pTask->fMembership = FALSE;
1565 StartTask (taskUSER_GROUPLIST_SET, NULL, pTask);
1571 void UserProp_UpdateName (HWND hDlg)
1573 LPUSERPROPINFO lpp = (LPUSERPROPINFO)PropSheet_FindTabParam (hDlg);
1575 if (IsWindow (GetDlgItem (hDlg, IDC_USER_NAME)))
1577 if (!lpp->pUserList || (lpp->pUserList->cEntries == 1))
1579 TCHAR szText[ cchRESOURCE ];
1580 GetDlgItemText (hDlg, IDC_USER_NAME, szText, cchRESOURCE);
1583 TCHAR szName[ cchRESOURCE ];
1585 User_GetDisplayName (szName, lpp->pUserList->aEntries[ 0 ].idObject);
1587 asc_ObjectNameGet_Fast (g.idClient, g.idCell, g.idCell, szName, &status);
1591 ASOBJPROP Properties;
1592 if (asc_ObjectPropertiesGet_Fast (g.idClient, g.idCell, lpp->pUserList->aEntries[ 0 ].idObject, &Properties, &status))
1593 AppendUID (szName, Properties.u.UserProperties.PTSINFO.uidName);
1596 LPTSTR pszText = FormatString (szText, TEXT("%s"), szName);
1597 SetDlgItemText (hDlg, IDC_USER_NAME, pszText);
1598 FreeString (pszText);
1600 else if (lpp->pUserList && (lpp->pUserList->cEntries > 1))
1602 LPTSTR pszText = CreateNameList (lpp->pUserList, IDS_USER_NAME_MULTIPLE);
1603 SetDlgItemText (hDlg, IDC_USER_NAME, pszText);
1604 FreeString (pszText);