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
14 #include <afsconfig.h>
15 #include <afs/param.h>
19 #include <WINNT/afsclass.h>
24 * DEFINITIONS ________________________________________________________________
28 #define cREALLOC_ADMINLISTENTRIES 32
30 #define cREALLOC_HOSTLISTENTRIES 16
32 #define cREALLOC_SERVERKEYS 16
34 #define ACCOUNTACCESS_TO_USERACCESS(_aa) ( ((_aa) == aaOWNER_ONLY) ? PTS_USER_OWNER_ACCESS : PTS_USER_ANYUSER_ACCESS )
36 #define ACCOUNTACCESS_TO_GROUPACCESS(_aa) ( ((_aa) == aaOWNER_ONLY) ? PTS_GROUP_OWNER_ACCESS : ((_aa) == aaGROUP_ONLY) ? PTS_GROUP_ACCESS : PTS_GROUP_ANYUSER_ACCESS )
40 * PROTOTYPES _________________________________________________________________
46 * ROUTINES ___________________________________________________________________
50 BOOL
AfsClass_GetServerLogFile (LPIDENT lpiServer
, LPTSTR pszLocal
, LPTSTR pszRemote
, ULONG
*pStatus
)
56 NOTIFYCALLBACK::SendNotificationToAll (evtGetServerLogFileBegin
, lpiServer
, pszRemote
, 0);
60 LPSERVER lpServer
= NULL
;
61 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
65 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
73 wp
.wpBosLogGet
.hServer
= hBOS
;
74 wp
.wpBosLogGet
.pszLogName
= pszRemote
;
75 wp
.wpBosLogGet
.pszLogData
= NULL
;
78 if ((rc
= Worker_DoTask (wtaskBosLogGet
, &wp
, &status
)) == TRUE
)
81 if ((fh
= CreateFile (pszLocal
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_ARCHIVE
, NULL
)) != INVALID_HANDLE_VALUE
)
83 // Write the file a line at a time in order to make
84 // sure that each line ends with "\r\n". If we encounter
85 // a line which ends in \r\n already, well, leave it alone.
87 for (LPTSTR psz
= wp
.wpBosLogGet
.pszLogData
; psz
&& *psz
; )
90 for (pszNext
= psz
; *pszNext
&& (*pszNext
!= TEXT('\r')) && (*pszNext
!= TEXT('\n')); ++pszNext
)
94 if ((cbWrite
= (DWORD
)(pszNext
- psz
)) != 0)
95 WriteFile (fh
, psz
, cbWrite
, &cbWrote
, NULL
);
96 WriteFile (fh
, TEXT("\r\n"), 2, &cbWrote
, NULL
);
97 psz
= (*pszNext
== TEXT('\r')) ? (2+pszNext
) : (*pszNext
== TEXT('\n')) ? (1+pszNext
) : NULL
;
102 Free (wp
.wpBosLogGet
.pszLogData
);
108 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
110 lpServer
->CloseBosObject();
114 NOTIFYCALLBACK::SendNotificationToAll (evtGetServerLogFileEnd
, lpiServer
, pszRemote
, status
);
123 BOOL
AfsClass_SetServerAuth (LPIDENT lpiServer
, BOOL fEnabled
, ULONG
*pStatus
)
129 NOTIFYCALLBACK::SendNotificationToAll (evtSetServerAuthBegin
, lpiServer
);
134 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
138 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
146 wp
.wpBosAuthSet
.hServer
= hBOS
;
147 wp
.wpBosAuthSet
.fEnableAuth
= fEnabled
;
150 rc
= Worker_DoTask (wtaskBosAuthSet
, &wp
, &status
);
154 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
156 lpServer
->CloseBosObject();
160 NOTIFYCALLBACK::SendNotificationToAll (evtSetServerAuthEnd
, lpiServer
, status
);
169 BOOL
AfsClass_StartService (LPIDENT lpiStart
, BOOL fTemporary
, ULONG
*pStatus
)
175 NOTIFYCALLBACK::SendNotificationToAll (evtStartServiceBegin
, lpiStart
);
180 if ((lpServer
= lpiStart
->OpenServer (&status
)) == NULL
)
184 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
191 if (lpiStart
->fIsService())
193 TCHAR szName
[ cchNAME
];
194 lpiStart
->GetServiceName (szName
);
199 wp
.wpBosProcessExecutionStateSetTemporary
.hServer
= hBOS
;
200 wp
.wpBosProcessExecutionStateSetTemporary
.pszService
= szName
;
201 wp
.wpBosProcessExecutionStateSetTemporary
.state
= SERVICESTATE_RUNNING
;
204 rc
= Worker_DoTask (wtaskBosProcessExecutionStateSetTemporary
, &wp
, &status
);
210 wp
.wpBosProcessExecutionStateSet
.hServer
= hBOS
;
211 wp
.wpBosProcessExecutionStateSet
.pszService
= szName
;
212 wp
.wpBosProcessExecutionStateSet
.state
= SERVICESTATE_RUNNING
;
215 rc
= Worker_DoTask (wtaskBosProcessExecutionStateSet
, &wp
, &status
);
222 wp
.wpBosProcessAllStart
.hServer
= hBOS
;
224 rc
= Worker_DoTask (wtaskBosProcessAllStart
, &wp
, &status
);
231 if (lpiStart
->fIsService())
234 if ((lpService
= lpiStart
->OpenService (&status
)) == NULL
)
238 lpService
->Invalidate();
239 lpService
->RefreshStatus();
245 if ((lpServer
= lpiStart
->OpenServer (&status
)) == NULL
)
249 lpServer
->Invalidate();
250 lpServer
->RefreshAll();
256 if ((lpServer
= lpiStart
->OpenServer (&status
)) != NULL
)
258 lpServer
->CloseBosObject();
262 NOTIFYCALLBACK::SendNotificationToAll (evtStartServiceEnd
, lpiStart
, status
);
271 BOOL
AfsClass_StopService (LPIDENT lpiStop
, BOOL fTemporary
, BOOL fWait
, ULONG
*pStatus
)
277 NOTIFYCALLBACK::SendNotificationToAll (evtStopServiceBegin
, lpiStop
);
282 if ((lpServer
= lpiStop
->OpenServer (&status
)) == NULL
)
286 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
293 if (lpiStop
->fIsService())
295 TCHAR szName
[ cchNAME
];
296 lpiStop
->GetServiceName (szName
);
301 wp
.wpBosProcessExecutionStateSetTemporary
.hServer
= hBOS
;
302 wp
.wpBosProcessExecutionStateSetTemporary
.pszService
= szName
;
303 wp
.wpBosProcessExecutionStateSetTemporary
.state
= SERVICESTATE_STOPPED
;
304 // TODO: wp.wpStopBosProcessTemporary.fWait = TRUE;
307 rc
= Worker_DoTask (wtaskBosProcessExecutionStateSetTemporary
, &wp
, &status
);
313 wp
.wpBosProcessExecutionStateSet
.hServer
= hBOS
;
314 wp
.wpBosProcessExecutionStateSet
.pszService
= szName
;
315 wp
.wpBosProcessExecutionStateSet
.state
= SERVICESTATE_STOPPED
;
316 // TODO: wp.wpStopBosProcess.fWait = TRUE;
319 rc
= Worker_DoTask (wtaskBosProcessExecutionStateSet
, &wp
, &status
);
326 wp
.wpBosProcessAllWaitStop
.hServer
= hBOS
;
329 rc
= Worker_DoTask (wtaskBosProcessAllWaitStop
, &wp
, &status
);
335 wp
.wpBosProcessAllStop
.hServer
= hBOS
;
338 rc
= Worker_DoTask (wtaskBosProcessAllStop
, &wp
, &status
);
345 if (lpiStop
->fIsService())
348 if ((lpService
= lpiStop
->OpenService (&status
)) == NULL
)
352 lpService
->Invalidate();
353 lpService
->RefreshStatus();
360 if ((lpServer
= lpiStop
->OpenServer (&status
)) == NULL
)
364 lpServer
->Invalidate();
365 lpServer
->RefreshAll();
371 if ((lpServer
= lpiStop
->OpenServer (&status
)) != NULL
)
373 lpServer
->CloseBosObject();
377 NOTIFYCALLBACK::SendNotificationToAll (evtStopServiceEnd
, lpiStop
, status
);
386 BOOL
AfsClass_RestartService (LPIDENT lpiRestart
, ULONG
*pStatus
)
392 NOTIFYCALLBACK::SendNotificationToAll (evtRestartServiceBegin
, lpiRestart
);
397 if ((lpServer
= lpiRestart
->OpenServer (&status
)) == NULL
)
401 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
406 BOOL fRestartAll
= FALSE
;
407 if (!lpiRestart
->fIsService())
410 TCHAR szServiceRestart
[ cchNAME
];
411 if (lpiRestart
->fIsService())
413 lpiRestart
->GetServiceName (szServiceRestart
);
414 if (!lstrcmpi (szServiceRestart
, TEXT("BOS")))
423 wp
.wpBosProcessRestart
.hServer
= hBOS
;
424 wp
.wpBosProcessRestart
.pszService
= szServiceRestart
;
427 rc
= Worker_DoTask (wtaskBosProcessRestart
, &wp
, &status
);
430 else // (fRestartAll)
433 wp
.wpBosProcessAllStopAndRestart
.hServer
= hBOS
;
434 wp
.wpBosProcessAllStopAndRestart
.fRestartBOS
= TRUE
;
437 rc
= Worker_DoTask (wtaskBosProcessAllStopAndRestart
, &wp
, &status
);
447 if ((lpService
= lpiRestart
->OpenService (&status
)) == NULL
)
451 lpService
->Invalidate();
452 lpService
->RefreshStatus();
456 else // (fRestartAll)
459 if ((lpServer
= lpiRestart
->OpenServer (&status
)) == NULL
)
463 lpServer
->Invalidate();
464 lpServer
->RefreshAll();
470 if ((lpServer
= lpiRestart
->OpenServer (&status
)) != NULL
)
472 lpServer
->CloseBosObject();
476 NOTIFYCALLBACK::SendNotificationToAll (evtRestartServiceEnd
, lpiRestart
, status
);
485 LPIDENT
AfsClass_CreateFileset (LPIDENT lpiAggregate
, LPTSTR pszFileset
, ULONG ckQuota
, ULONG
*pStatus
)
487 LPIDENT lpiFileset
= NULL
;
492 NOTIFYCALLBACK::SendNotificationToAll (evtCreateFilesetBegin
, lpiAggregate
, pszFileset
, 0);
494 // Obtain hCell and hVOS
498 LPSERVER lpServer
= NULL
;
499 if ((lpServer
= lpiAggregate
->OpenServer (&status
)) == NULL
)
503 if ((hVOS
= lpServer
->OpenVosObject (&hCell
, &status
)) == NULL
)
508 // Obtain idPartition
511 LPAGGREGATE lpAggregate
;
512 if ((lpAggregate
= lpiAggregate
->OpenAggregate (&status
)) == NULL
)
516 idPartition
= lpAggregate
->GetID();
517 lpAggregate
->Close();
520 // Perform the actual operation
525 wp
.wpVosVolumeCreate
.hCell
= hCell
;
526 wp
.wpVosVolumeCreate
.hServer
= hVOS
;
527 wp
.wpVosVolumeCreate
.idPartition
= idPartition
;
528 wp
.wpVosVolumeCreate
.pszVolume
= pszFileset
;
529 wp
.wpVosVolumeCreate
.ckQuota
= ckQuota
;
532 rc
= Worker_DoTask (wtaskVosVolumeCreate
, &wp
, &status
);
540 LPAGGREGATE lpAggregate
;
541 if ((lpAggregate
= lpiAggregate
->OpenAggregate (&status
)) == NULL
)
545 lpAggregate
->Invalidate();
546 lpAggregate
->RefreshFilesets (TRUE
, &status
);
547 lpAggregate
->Close();
554 if ((lpCell
= lpiAggregate
->OpenCell()) == NULL
)
558 lpCell
->RefreshVLDB (lpiAggregate
);
565 LPAGGREGATE lpAggregate
;
566 if ((lpAggregate
= lpiAggregate
->OpenAggregate (&status
)) == NULL
)
571 if ((lpFileset
= lpAggregate
->OpenFileset (pszFileset
, &status
)) == NULL
)
575 lpiFileset
= lpFileset
->GetIdentifier();
578 lpAggregate
->Close();
584 if ((lpServer
= lpiAggregate
->OpenServer (&status
)) != NULL
)
586 lpServer
->CloseVosObject();
591 NOTIFYCALLBACK::SendNotificationToAll (evtCreateFilesetEnd
, lpiAggregate
, pszFileset
, status
);
596 return (rc
) ? lpiFileset
: NULL
;
600 BOOL
AfsClass_DeleteFileset (LPIDENT lpiFileset
, BOOL fVLDB
, BOOL fServer
, ULONG
*pStatus
)
606 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteFilesetBegin
, lpiFileset
);
608 // Obtain hCell and hVOS
612 LPSERVER lpServer
= NULL
;
613 if ((lpServer
= lpiFileset
->OpenServer (&status
)) == NULL
)
617 if ((hVOS
= lpServer
->OpenVosObject (&hCell
, &status
)) == NULL
)
622 // Does the fileset have a VLDB entry? Does it actually exist on the server?
623 // What's its volume ID? Its R/W ID? Its partition ID?
626 VOLUMEID vidReadWrite
;
629 // Obtain the ID of the fileset's parent aggregate.
632 LPAGGREGATE lpAggregate
;
633 if ((lpAggregate
= lpiFileset
->OpenAggregate (&status
)) == NULL
)
637 if ((idPartition
= lpAggregate
->GetID()) == NO_PARTITION
)
639 lpAggregate
->Close();
645 if ((lpFileset
= lpiFileset
->OpenFileset (&status
)) == NULL
)
649 wFilesetGhost
= lpFileset
->GetGhostStatus();
650 lpiFileset
->GetFilesetID (&vidFileset
);
653 if (!lpFileset
->GetStatus (&fs
))
654 vidReadWrite
= vidFileset
;
656 vidReadWrite
= fs
.idReadWrite
;
662 if (!(wFilesetGhost
& GHOST_HAS_VLDB_ENTRY
))
664 if (!(wFilesetGhost
& GHOST_HAS_SERVER_ENTRY
))
667 if (rc
&& fVLDB
&& fServer
)
670 wp
.wpVosVolumeDelete
.hCell
= hCell
;
671 wp
.wpVosVolumeDelete
.hServer
= hVOS
;
672 wp
.wpVosVolumeDelete
.idPartition
= idPartition
;
673 wp
.wpVosVolumeDelete
.idVolume
= vidFileset
;
676 rc
= Worker_DoTask (wtaskVosVolumeDelete
, &wp
, &status
);
679 else if (rc
&& fVLDB
)
682 wp
.wpVosVLDBEntryRemove
.hCell
= hCell
;
683 wp
.wpVosVLDBEntryRemove
.hServer
= hVOS
;
684 wp
.wpVosVLDBEntryRemove
.idPartition
= idPartition
;
685 wp
.wpVosVLDBEntryRemove
.idVolume
= vidReadWrite
;
688 rc
= Worker_DoTask (wtaskVosVLDBEntryRemove
, &wp
, &status
);
691 else if (rc
&& fServer
)
694 wp
.wpVosVolumeZap
.hCell
= hCell
;
695 wp
.wpVosVolumeZap
.hServer
= hVOS
;
696 wp
.wpVosVolumeZap
.idPartition
= idPartition
;
697 wp
.wpVosVolumeZap
.idVolume
= vidFileset
;
698 wp
.wpVosVolumeZap
.fForce
= TRUE
;
701 rc
= Worker_DoTask (wtaskVosVolumeZap
, &wp
, &status
);
707 LPAGGREGATE lpAggregate
;
708 if ((lpAggregate
= lpiFileset
->OpenAggregate (&status
)) == NULL
)
712 lpAggregate
->Invalidate();
713 lpAggregate
->RefreshFilesets (TRUE
);
714 lpAggregate
->Close();
721 if ((lpCell
= lpiFileset
->OpenCell (&status
)) == NULL
)
725 lpCell
->RefreshVLDB (lpiFileset
->GetAggregate(), TRUE
);
732 if ((lpServer
= lpiFileset
->OpenServer()) != NULL
)
734 lpServer
->CloseVosObject();
739 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteFilesetEnd
, lpiFileset
, status
);
748 BOOL
AfsClass_MoveFileset (LPIDENT lpiFileset
, LPIDENT lpiAggregateTarget
, ULONG
*pStatus
)
754 NOTIFYCALLBACK::SendNotificationToAll (evtMoveFilesetBegin
, lpiFileset
, lpiAggregateTarget
, NULL
, NULL
, 0, 0);
756 LPIDENT lpiAggregateSource
= lpiFileset
->GetAggregate();
758 // Obtain hCell, hVOS and the aggregate name for the source
761 PVOID hVOSSource
= NULL
;
763 if ((lpServer
= lpiFileset
->OpenServer (&status
)) == NULL
)
767 if ((hVOSSource
= lpServer
->OpenVosObject (&hCell
, &status
)) == NULL
)
772 // Obtain the ID of the source aggregate
774 int idPartitionSource
;
775 LPAGGREGATE lpAggregate
;
776 if ((lpAggregate
= lpiFileset
->OpenAggregate (&status
)) == NULL
)
780 if ((idPartitionSource
= lpAggregate
->GetID()) == NO_PARTITION
)
782 lpAggregate
->Close();
785 // Obtain hCell, hVOS and the aggregate name for the target
787 PVOID hVOSTarget
= NULL
;
788 if ((lpServer
= lpiAggregateTarget
->OpenServer (&status
)) == NULL
)
792 if ((hVOSTarget
= lpServer
->OpenVosObject (NULL
, &status
)) == NULL
)
797 // Obtain the ID of the target aggregate
799 int idPartitionTarget
;
800 if ((lpAggregate
= lpiAggregateTarget
->OpenAggregate (&status
)) == NULL
)
804 if ((idPartitionTarget
= lpAggregate
->GetID()) == NO_PARTITION
)
806 lpAggregate
->Close();
812 wp
.wpVosVolumeMove
.hCell
= hCell
;
813 wp
.wpVosVolumeMove
.hServerFrom
= hVOSSource
;
814 wp
.wpVosVolumeMove
.idPartitionFrom
= idPartitionSource
;
815 wp
.wpVosVolumeMove
.hServerTo
= hVOSTarget
;
816 wp
.wpVosVolumeMove
.idPartitionTo
= idPartitionTarget
;
817 lpiFileset
->GetFilesetID (&wp
.wpVosVolumeMove
.idVolume
);
820 rc
= Worker_DoTask (wtaskVosVolumeMove
, &wp
, &status
);
826 LPAGGREGATE lpAggregate
;
827 if ((lpAggregate
= lpiAggregateSource
->OpenAggregate (&status
)) == NULL
)
831 lpAggregate
->Invalidate();
832 lpAggregate
->RefreshFilesets();
833 lpAggregate
->Close();
839 LPAGGREGATE lpAggregate
;
840 if ((lpAggregate
= lpiAggregateTarget
->OpenAggregate (&status
)) == NULL
)
844 lpAggregate
->Invalidate();
845 lpAggregate
->RefreshFilesets();
846 lpAggregate
->Close();
853 if ((lpFileset
= lpiFileset
->OpenFileset (&status
)) == NULL
)
857 lpFileset
->Invalidate();
858 lpFileset
->RefreshStatus();
866 if ((lpCell
= lpiFileset
->OpenCell (&status
)) == NULL
)
870 lpCell
->RefreshVLDB (lpiAggregateSource
, TRUE
);
871 lpCell
->RefreshVLDB (lpiAggregateTarget
, TRUE
);
878 if ((lpServer
= lpiAggregateSource
->OpenServer()) != NULL
)
880 lpServer
->CloseVosObject();
886 if ((lpServer
= lpiAggregateTarget
->OpenServer()) != NULL
)
888 lpServer
->CloseVosObject();
893 NOTIFYCALLBACK::SendNotificationToAll (evtMoveFilesetEnd
, lpiFileset
, lpiAggregateTarget
, NULL
, NULL
, 0, status
);
902 BOOL
AfsClass_SetFilesetQuota (LPIDENT lpiFileset
, size_t ckQuotaNew
, ULONG
*pStatus
)
908 NOTIFYCALLBACK::SendNotificationToAll (evtSetFilesetQuotaBegin
, lpiFileset
);
910 // Obtain hCell and hVOS for the server where this fileset lives
915 if ((lpServer
= lpiFileset
->OpenServer (&status
)) == NULL
)
919 if ((hVOS
= lpServer
->OpenVosObject (&hCell
, &status
)) == NULL
)
924 // Obtain the ID of the fileset's parent aggregate.
929 LPAGGREGATE lpAggregate
;
930 if ((lpAggregate
= lpiFileset
->OpenAggregate (&status
)) == NULL
)
934 if ((idPartition
= lpAggregate
->GetID()) == NO_PARTITION
)
936 lpAggregate
->Close();
940 // Change the fileset's quota.
945 wp
.wpVosVolumeQuotaChange
.hCell
= hCell
;
946 wp
.wpVosVolumeQuotaChange
.hServer
= hVOS
;
947 wp
.wpVosVolumeQuotaChange
.idPartition
= idPartition
;
948 lpiFileset
->GetFilesetID (&wp
.wpVosVolumeQuotaChange
.idVolume
);
949 wp
.wpVosVolumeQuotaChange
.ckQuota
= ckQuotaNew
;
952 rc
= Worker_DoTask (wtaskVosVolumeQuotaChange
, &wp
, &status
);
959 if ((lpFileset
= lpiFileset
->OpenFileset (&status
)) == NULL
)
963 lpFileset
->Invalidate();
964 lpFileset
->RefreshStatus();
971 LPAGGREGATE lpAggregate
;
972 if ((lpAggregate
= lpiFileset
->OpenAggregate (&status
)) == NULL
)
976 lpAggregate
->RefreshStatus();
977 lpAggregate
->Close();
983 if ((lpServer
= lpiFileset
->OpenServer()) != NULL
)
985 lpServer
->CloseVosObject();
990 NOTIFYCALLBACK::SendNotificationToAll (evtSetFilesetQuotaEnd
, lpiFileset
, status
);
999 BOOL
AfsClass_SyncVLDB (LPIDENT lpiSync
, BOOL fForce
, ULONG
*pStatus
)
1005 NOTIFYCALLBACK::SendNotificationToAll (evtSyncVLDBBegin
, lpiSync
);
1007 // Obtain hCell and hVOS
1012 if ((lpServer
= lpiSync
->OpenServer (&status
)) == NULL
)
1016 if ((hVOS
= lpServer
->OpenVosObject (&hCell
, &status
)) == NULL
)
1021 // Obtain the ID of the target aggregate.
1023 int idPartition
= NO_PARTITION
;
1024 if (rc
&& (lpiSync
->fIsAggregate() || lpiSync
->fIsFileset()))
1026 LPAGGREGATE lpAggregate
;
1027 if ((lpAggregate
= lpiSync
->OpenAggregate (&status
)) == NULL
)
1031 if ((idPartition
= lpAggregate
->GetID()) == NO_PARTITION
)
1033 lpAggregate
->Close();
1040 wp
.wpVosVLDBSync
.hCell
= hCell
;
1041 wp
.wpVosVLDBSync
.hServer
= hVOS
;
1042 wp
.wpVosVLDBSync
.idPartition
= idPartition
;
1043 wp
.wpVosVLDBSync
.fForce
= fForce
;
1046 rc
= Worker_DoTask (wtaskVosVLDBSync
, &wp
, &status
);
1052 if (lpiSync
->fIsServer())
1055 if ((lpServer
= lpiSync
->OpenServer (&status
)) == NULL
)
1059 lpServer
->Invalidate();
1060 rc
= lpServer
->RefreshAll (&status
);
1064 else // (lpiSync->fIsAggregate())
1066 LPAGGREGATE lpAggregate
;
1067 if ((lpAggregate
= lpiSync
->OpenAggregate (&status
)) == NULL
)
1071 lpAggregate
->Invalidate();
1072 lpAggregate
->RefreshStatus();
1073 lpAggregate
->RefreshFilesets();
1074 lpAggregate
->Close();
1077 if ((lpCell
= lpiSync
->OpenCell()) == NULL
)
1081 lpCell
->RefreshVLDB (lpiSync
);
1090 if ((lpServer
= lpiSync
->OpenServer()) != NULL
)
1092 lpServer
->CloseVosObject();
1097 NOTIFYCALLBACK::SendNotificationToAll (evtSyncVLDBEnd
, lpiSync
, status
);
1106 BOOL
AfsClass_ChangeAddress (LPIDENT lpiServer
, LPSOCKADDR_IN pAddrOld
, LPSOCKADDR_IN pAddrNew
, ULONG
*pStatus
)
1112 NOTIFYCALLBACK::SendNotificationToAll (evtChangeAddressBegin
, lpiServer
);
1118 if ((lpCell
= lpiServer
->OpenCell (&status
)) == NULL
)
1122 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
1130 wp
.wpVosFileServerAddressChange
.hCell
= hCell
;
1131 wp
.wpVosFileServerAddressChange
.addrOld
= *pAddrOld
;
1132 wp
.wpVosFileServerAddressChange
.addrNew
= *pAddrNew
;
1135 rc
= Worker_DoTask (wtaskVosFileServerAddressChange
, &wp
, &status
);
1138 else if (rc
&& !pAddrNew
)
1141 wp
.wpVosFileServerAddressRemove
.hCell
= hCell
;
1142 wp
.wpVosFileServerAddressRemove
.addr
= *pAddrOld
;
1145 rc
= Worker_DoTask (wtaskVosFileServerAddressRemove
, &wp
, &status
);
1152 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
1154 lpServer
->InvalidateStatus();
1158 if ((lpCell
= lpiServer
->OpenCell (&status
)) == NULL
)
1162 lpCell
->InvalidateServers ();
1163 rc
= lpCell
->RefreshServers (TRUE
, &status
);
1168 NOTIFYCALLBACK::SendNotificationToAll (evtChangeAddressEnd
, lpiServer
, status
);
1177 BOOL
AfsClass_ChangeAddress (LPIDENT lpiServer
, LPSERVERSTATUS pStatusOld
, LPSERVERSTATUS pStatusNew
, ULONG
*pStatus
)
1183 NOTIFYCALLBACK::SendNotificationToAll (evtChangeAddressBegin
, lpiServer
);
1189 if ((lpCell
= lpiServer
->OpenCell (&status
)) == NULL
)
1193 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
1202 for (size_t iAddr
= 0; rc
&& (iAddr
< AFSCLASS_MAX_ADDRESSES_PER_SITE
); ++iAddr
)
1206 AfsClass_AddressToInt (&oldAddress
, &pStatusOld
->aAddresses
[ iAddr
]);
1207 AfsClass_AddressToInt (&newAddress
, &pStatusNew
->aAddresses
[ iAddr
]);
1209 if (oldAddress
&& newAddress
&& (oldAddress
!= newAddress
))
1212 wp
.wpVosFileServerAddressChange
.hCell
= hCell
;
1213 wp
.wpVosFileServerAddressChange
.addrOld
= pStatusOld
->aAddresses
[ iAddr
];
1214 wp
.wpVosFileServerAddressChange
.addrNew
= pStatusNew
->aAddresses
[ iAddr
];
1216 rc
= Worker_DoTask (wtaskVosFileServerAddressChange
, &wp
, &status
);
1218 else if (oldAddress
&& !newAddress
)
1221 wp
.wpVosFileServerAddressRemove
.hCell
= hCell
;
1222 wp
.wpVosFileServerAddressRemove
.addr
= pStatusOld
->aAddresses
[ iAddr
];
1224 rc
= Worker_DoTask (wtaskVosFileServerAddressRemove
, &wp
, &status
);
1234 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
1236 lpServer
->InvalidateStatus();
1241 if ((lpCell
= lpiServer
->OpenCell (&status
)) == NULL
)
1245 lpCell
->InvalidateServers ();
1246 rc
= lpCell
->RefreshServers (TRUE
, &status
);
1251 NOTIFYCALLBACK::SendNotificationToAll (evtChangeAddressEnd
, lpiServer
, status
);
1260 BOOL
AfsClass_LockFileset (LPIDENT lpiFileset
, ULONG
*pStatus
)
1266 NOTIFYCALLBACK::SendNotificationToAll (evtLockFilesetBegin
, lpiFileset
);
1272 if ((lpCell
= lpiFileset
->OpenCell (&status
)) == NULL
)
1276 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
1281 // Obtain the fileset's read-write identifier
1283 LPIDENT lpiRW
= NULL
;
1284 LPFILESET lpFileset
;
1285 if ((lpFileset
= lpiFileset
->OpenFileset (&status
)) == NULL
)
1289 if ((lpiRW
= lpFileset
->GetReadWriteIdentifier()) == NULL
)
1294 // Perform the lock operation
1299 wp
.wpVosVLDBEntryLock
.hCell
= hCell
;
1300 lpiRW
->GetFilesetID (&wp
.wpVosVLDBEntryLock
.idVolume
);
1303 rc
= Worker_DoTask (wtaskVosVLDBEntryLock
, &wp
, &status
);
1310 if ((lpCell
= lpiFileset
->OpenCell (&status
)) == NULL
)
1315 lpCell
->RefreshVLDB (lpiRW
, TRUE
, NULL
, TRUE
);
1317 lpCell
->RefreshVLDB (lpiFileset
->GetCell());
1322 NOTIFYCALLBACK::SendNotificationToAll (evtLockFilesetEnd
, lpiFileset
, status
);
1331 BOOL
AfsClass_UnlockFileset (LPIDENT lpiFileset
, ULONG
*pStatus
)
1337 NOTIFYCALLBACK::SendNotificationToAll (evtUnlockFilesetBegin
, lpiFileset
);
1343 if ((lpCell
= lpiFileset
->OpenCell (&status
)) == NULL
)
1347 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
1352 // Obtain the fileset's read-write identifier
1354 LPIDENT lpiRW
= NULL
;
1355 LPFILESET lpFileset
;
1356 if ((lpFileset
= lpiFileset
->OpenFileset (&status
)) == NULL
)
1360 if ((lpiRW
= lpFileset
->GetReadWriteIdentifier()) == NULL
)
1365 // Perform the unlock operation
1370 wp
.wpVosVLDBEntryUnlock
.hCell
= hCell
;
1371 wp
.wpVosVLDBEntryUnlock
.hServer
= NULL
;
1372 wp
.wpVosVLDBEntryUnlock
.idPartition
= NO_PARTITION
;
1373 lpiRW
->GetFilesetID (&wp
.wpVosVLDBEntryUnlock
.idVolume
);
1376 rc
= Worker_DoTask (wtaskVosVLDBEntryUnlock
, &wp
, &status
);
1383 if ((lpCell
= lpiFileset
->OpenCell (&status
)) == NULL
)
1388 lpCell
->RefreshVLDB (lpiRW
, TRUE
, NULL
, TRUE
);
1390 lpCell
->RefreshVLDB (lpiFileset
->GetCell());
1395 NOTIFYCALLBACK::SendNotificationToAll (evtUnlockFilesetEnd
, lpiFileset
, status
);
1404 BOOL
AfsClass_UnlockAllFilesets (LPIDENT lpi
, ULONG
*pStatus
)
1410 NOTIFYCALLBACK::SendNotificationToAll (evtUnlockAllFilesetsBegin
, lpi
);
1416 if ((lpCell
= lpi
->OpenCell (&status
)) == NULL
)
1420 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
1425 // Obtain hServer if appropriate
1428 if (lpi
&& (!lpi
->fIsCell()))
1431 if ((lpServer
= lpi
->OpenServer (&status
)) == NULL
)
1435 if ((hVOS
= lpServer
->OpenVosObject (NULL
, &status
)) == NULL
)
1441 // Obtain the ID of the scope aggregate.
1443 int idPartition
= NO_PARTITION
;
1444 if (rc
&& (lpi
->fIsFileset() || (lpi
->fIsAggregate())))
1446 LPAGGREGATE lpAggregate
;
1447 if ((lpAggregate
= lpi
->OpenAggregate (&status
)) == NULL
)
1451 if ((idPartition
= lpAggregate
->GetID()) == NO_PARTITION
)
1453 lpAggregate
->Close();
1457 // Perform the unlock operation
1462 wp
.wpVosVLDBEntryUnlock
.hCell
= hCell
;
1463 wp
.wpVosVLDBEntryUnlock
.hServer
= hVOS
;
1464 wp
.wpVosVLDBEntryUnlock
.idPartition
= idPartition
;
1465 wp
.wpVosVLDBEntryUnlock
.idVolume
= NO_VOLUME
;
1468 rc
= Worker_DoTask (wtaskVosVLDBEntryUnlock
, &wp
, &status
);
1475 if ((lpCell
= lpi
->OpenCell (&status
)) == NULL
)
1479 lpCell
->RefreshVLDB (lpi
);
1487 if ((lpServer
= lpi
->OpenServer (&status
)) != NULL
)
1489 lpServer
->CloseVosObject();
1494 NOTIFYCALLBACK::SendNotificationToAll (evtUnlockAllFilesetsEnd
, lpi
);
1503 LPIDENT
AfsClass_CreateReplica (LPIDENT lpiFileset
, LPIDENT lpiAggregate
, ULONG
*pStatus
)
1507 LPIDENT lpiReplica
= NULL
;
1510 NOTIFYCALLBACK::SendNotificationToAll (evtCreateReplicaBegin
, lpiFileset
, lpiAggregate
, NULL
, NULL
, 0, 0);
1512 // Obtain hCell and hVOS for the target server
1517 if ((lpServer
= lpiAggregate
->OpenServer (&status
)) == NULL
)
1521 if ((hVOS
= lpServer
->OpenVosObject (&hCell
, &status
)) == NULL
)
1526 // Obtain idPartition
1529 LPAGGREGATE lpAggregate
;
1530 if ((lpAggregate
= lpiAggregate
->OpenAggregate (&status
)) == NULL
)
1534 idPartition
= lpAggregate
->GetID();
1535 lpAggregate
->Close();
1538 // Modify VLDB to create mention of a new replica
1543 wp
.wpVosVLDBReadOnlySiteCreate
.hCell
= hCell
;
1544 wp
.wpVosVLDBReadOnlySiteCreate
.hServer
= hVOS
;
1545 wp
.wpVosVLDBReadOnlySiteCreate
.idPartition
= idPartition
;
1546 lpiFileset
->GetFilesetID (&wp
.wpVosVLDBReadOnlySiteCreate
.idVolume
);
1549 rc
= Worker_DoTask (wtaskVosVLDBReadOnlySiteCreate
, &wp
, &status
);
1557 LPAGGREGATE lpAggregate
;
1558 if ((lpAggregate
= lpiAggregate
->OpenAggregate (&status
)) == NULL
)
1562 lpAggregate
->Invalidate();
1563 lpAggregate
->RefreshFilesets (TRUE
, &status
);
1564 lpAggregate
->Close();
1571 if ((lpCell
= lpiAggregate
->OpenCell()) == NULL
)
1575 lpCell
->RefreshVLDB (lpiAggregate
);
1582 LPFILESET lpFileset
;
1583 if ((lpFileset
= lpiFileset
->OpenFileset (&status
)) == NULL
)
1587 if ((lpiReplica
= lpFileset
->GetReadOnlyIdentifier (lpiAggregate
, &status
)) == NULL
)
1595 if ((lpServer
= lpiAggregate
->OpenServer (&status
)) != NULL
)
1597 lpServer
->CloseVosObject();
1602 NOTIFYCALLBACK::SendNotificationToAll (evtCreateReplicaEnd
, lpiFileset
, lpiAggregate
, NULL
, NULL
, 0, status
);
1607 return (rc
) ? lpiReplica
: FALSE
;
1611 BOOL
AfsClass_DeleteReplica (LPIDENT lpiReplica
, ULONG
*pStatus
)
1617 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteFilesetBegin
, lpiReplica
);
1619 // Obtain hCell and hVOS for the server
1624 if ((lpServer
= lpiReplica
->OpenServer (&status
)) == NULL
)
1628 if ((hVOS
= lpServer
->OpenVosObject (&hCell
, &status
)) == NULL
)
1633 // Get the read/write fileset identifier and Ghost status
1635 LPIDENT lpiRW
= NULL
;
1636 int wFilesetGhost
= 0;
1637 LPFILESET lpFileset
;
1638 if ((lpFileset
= lpiReplica
->OpenFileset (&status
)) == NULL
)
1642 wFilesetGhost
= lpFileset
->GetGhostStatus();
1643 if ((lpiRW
= lpFileset
->GetReadWriteIdentifier()) == NULL
)
1648 TCHAR szAggregateName
[ cchNAME
];
1649 lpiReplica
->GetAggregateName (szAggregateName
);
1651 // Obtain the ID of the replica's partition
1654 LPAGGREGATE lpAggregate
;
1655 if ((lpAggregate
= lpiReplica
->OpenAggregate (&status
)) == NULL
)
1659 idPartition
= lpAggregate
->GetID();
1660 lpAggregate
->Close();
1663 // If the volume exists in both VLDB and on the server, just delete it
1665 if (rc
&& (wFilesetGhost
& GHOST_HAS_VLDB_ENTRY
) && (wFilesetGhost
& GHOST_HAS_SERVER_ENTRY
))
1668 wp
.wpVosVolumeDelete
.hCell
= hCell
;
1669 wp
.wpVosVolumeDelete
.hServer
= hVOS
;
1670 wp
.wpVosVolumeDelete
.idPartition
= idPartition
;
1671 lpiReplica
->GetFilesetID (&wp
.wpVosVolumeDelete
.idVolume
);
1674 rc
= Worker_DoTask (wtaskVosVolumeDelete
, &wp
, &status
);
1679 // If necessary, modify VLDB to remove mention of this replica
1681 if (rc
&& (wFilesetGhost
& GHOST_HAS_VLDB_ENTRY
))
1684 wp
.wpVosVLDBReadOnlySiteDelete
.hCell
= hCell
;
1685 wp
.wpVosVLDBReadOnlySiteDelete
.hServer
= hVOS
;
1686 wp
.wpVosVLDBReadOnlySiteDelete
.idPartition
= idPartition
;
1687 lpiRW
->GetFilesetID (&wp
.wpVosVLDBReadOnlySiteDelete
.idVolume
);
1690 rc
= Worker_DoTask (wtaskVosVLDBReadOnlySiteDelete
, &wp
, &status
);
1694 // If necessary, zap the volume
1696 if (rc
&& (wFilesetGhost
& GHOST_HAS_SERVER_ENTRY
))
1699 wp
.wpVosVolumeZap
.hCell
= hCell
;
1700 wp
.wpVosVolumeZap
.hServer
= hVOS
;
1701 wp
.wpVosVolumeZap
.idPartition
= idPartition
;
1702 lpiReplica
->GetFilesetID (&wp
.wpVosVolumeZap
.idVolume
);
1703 wp
.wpVosVolumeZap
.fForce
= TRUE
;
1706 rc
= Worker_DoTask (wtaskVosVolumeZap
, &wp
, &status
);
1715 LPAGGREGATE lpAggregate
;
1716 if ((lpAggregate
= lpiReplica
->OpenAggregate (&status
)) == NULL
)
1720 lpAggregate
->Invalidate();
1721 lpAggregate
->RefreshFilesets (TRUE
, &status
);
1722 lpAggregate
->Close();
1729 if ((lpCell
= lpiReplica
->OpenCell()) == NULL
)
1733 lpCell
->RefreshVLDB (lpiReplica
->GetAggregate());
1740 if ((lpServer
= lpiReplica
->OpenServer (&status
)) != NULL
)
1742 lpServer
->CloseVosObject();
1747 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteFilesetEnd
, lpiReplica
, status
);
1756 BOOL
AfsClass_DeleteClone (LPIDENT lpiClone
, ULONG
*pStatus
)
1758 return AfsClass_DeleteFileset (lpiClone
, TRUE
, TRUE
, pStatus
);
1762 BOOL
AfsClass_InstallFile (LPIDENT lpiServer
, LPTSTR pszTarget
, LPTSTR pszSource
, ULONG
*pStatus
)
1768 NOTIFYCALLBACK::SendNotificationToAll (evtInstallFileBegin
, lpiServer
, pszSource
, 0);
1773 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
1777 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
1785 wp
.wpBosExecutableCreate
.hServer
= hBOS
;
1786 wp
.wpBosExecutableCreate
.pszLocal
= pszSource
;
1787 wp
.wpBosExecutableCreate
.pszRemoteDir
= pszTarget
;
1790 rc
= Worker_DoTask (wtaskBosExecutableCreate
, &wp
, &status
);
1794 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
1796 lpServer
->CloseBosObject();
1800 NOTIFYCALLBACK::SendNotificationToAll (evtInstallFileEnd
, lpiServer
, pszSource
, status
);
1809 BOOL
AfsClass_UninstallFile (LPIDENT lpiServer
, LPTSTR pszUninstall
, ULONG
*pStatus
)
1815 NOTIFYCALLBACK::SendNotificationToAll (evtUninstallFileBegin
, lpiServer
, pszUninstall
, 0);
1820 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
1824 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
1832 wp
.wpBosExecutableRevert
.hServer
= hBOS
;
1833 wp
.wpBosExecutableRevert
.pszFilename
= pszUninstall
;
1836 rc
= Worker_DoTask (wtaskBosExecutableRevert
, &wp
, &status
);
1840 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
1842 lpServer
->CloseBosObject();
1846 NOTIFYCALLBACK::SendNotificationToAll (evtUninstallFileEnd
, lpiServer
, pszUninstall
, status
);
1855 BOOL
AfsClass_PruneOldFiles (LPIDENT lpiServer
, BOOL fBAK
, BOOL fOLD
, BOOL fCore
, ULONG
*pStatus
)
1861 NOTIFYCALLBACK::SendNotificationToAll (evtPruneFilesBegin
, lpiServer
);
1866 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
1870 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
1878 wp
.wpBosExecutablePrune
.hServer
= hBOS
;
1879 wp
.wpBosExecutablePrune
.fPruneBak
= fBAK
;
1880 wp
.wpBosExecutablePrune
.fPruneOld
= fOLD
;
1881 wp
.wpBosExecutablePrune
.fPruneCore
= fCore
;
1884 rc
= Worker_DoTask (wtaskBosExecutablePrune
, &wp
, &status
);
1888 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
1890 lpServer
->CloseBosObject();
1894 NOTIFYCALLBACK::SendNotificationToAll (evtPruneFilesEnd
, lpiServer
, status
);
1903 BOOL
AfsClass_RenameFileset (LPIDENT lpiFileset
, LPTSTR pszNewName
, ULONG
*pStatus
)
1909 NOTIFYCALLBACK::SendNotificationToAll (evtRenameFilesetBegin
, lpiFileset
, pszNewName
, 0);
1913 if ((lpCell
= lpiFileset
->OpenCell (&status
)) == NULL
)
1917 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
1925 wp
.wpVosVolumeRename
.hCell
= hCell
;
1926 lpiFileset
->GetFilesetID (&wp
.wpVosVolumeRename
.idVolume
);
1927 wp
.wpVosVolumeRename
.pszVolume
= pszNewName
;
1930 rc
= Worker_DoTask (wtaskVosVolumeRename
, &wp
, &status
);
1937 if ((lpCell
= lpiFileset
->OpenCell (&status
)) == NULL
)
1941 lpCell
->Invalidate();
1942 rc
= lpCell
->RefreshAll (&status
);
1948 NOTIFYCALLBACK::SendNotificationToAll (evtRenameFilesetEnd
, lpiFileset
, pszNewName
, status
);
1957 #define iswhite(_ch) ((_ch)==TEXT(' ') || (_ch)==TEXT('\t'))
1959 LPIDENT
AfsClass_CreateService (LPIDENT lpiServer
, LPTSTR pszService
, LPTSTR pszCommand
, LPTSTR pszParams
, LPTSTR pszNotifier
, AFSSERVICETYPE type
, SYSTEMTIME
*pstIfCron
, ULONG
*pStatus
)
1963 LPIDENT lpiService
= NULL
;
1966 NOTIFYCALLBACK::SendNotificationToAll (evtCreateServiceBegin
, lpiServer
, pszService
, 0);
1971 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
1975 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
1983 wp
.wpBosProcessCreate
.hServer
= hBOS
;
1984 wp
.wpBosProcessCreate
.pszService
= pszService
;
1985 wp
.wpBosProcessCreate
.type
= type
;
1986 wp
.wpBosProcessCreate
.pszNotifier
= pszNotifier
;
1988 TCHAR szFullCommand
[ MAX_PATH
+ MAX_PATH
];
1989 wsprintf (szFullCommand
, TEXT("%s %s"), pszCommand
, pszParams
);
1990 wp
.wpBosProcessCreate
.pszCommand
= szFullCommand
;
1992 TCHAR szCronTime
[ 256 ] = TEXT("");
1993 wp
.wpBosProcessCreate
.pszTimeCron
= szCronTime
;
1995 if (type
== SERVICETYPE_CRON
)
1996 AfsClass_FormatRecurringTime (szCronTime
, pstIfCron
);
1998 wp
.wpBosProcessCreate
.pszTimeCron
= NULL
;
2001 rc
= Worker_DoTask (wtaskBosProcessCreate
, &wp
, &status
);
2007 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
2011 lpServer
->InvalidateServices();
2012 if (!lpServer
->RefreshServices (TRUE
, &status
))
2016 LPSERVICE lpService
;
2017 if ((lpService
= lpServer
->OpenService (pszService
, &status
)) == NULL
)
2021 lpiService
= lpService
->GetIdentifier();
2029 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
2031 lpServer
->CloseBosObject();
2035 NOTIFYCALLBACK::SendNotificationToAll (evtCreateServiceEnd
, lpiServer
, pszService
, status
);
2040 return (rc
) ? lpiService
: NULL
;
2044 BOOL
AfsClass_DeleteService (LPIDENT lpiService
, ULONG
*pStatus
)
2050 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteServiceBegin
, lpiService
);
2055 if ((lpServer
= lpiService
->OpenServer (&status
)) == NULL
)
2059 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
2064 // Before a service can be deleted, it must be stopped (otherwise, on NT,
2065 // the Delete operation won't block for the required Stop to complete--
2066 // so our wtaskDeleteBosProcess would return before the service really
2071 TCHAR szService
[ cchNAME
];
2072 lpiService
->GetServiceName (szService
);
2075 wp
.wpBosProcessExecutionStateSet
.hServer
= hBOS
;
2076 wp
.wpBosProcessExecutionStateSet
.pszService
= szService
;
2077 wp
.wpBosProcessExecutionStateSet
.state
= SERVICESTATE_STOPPED
;
2078 // TODO: wp.wpStopBosProcess.fWait = TRUE;
2081 rc
= Worker_DoTask (wtaskBosProcessExecutionStateSet
, &wp
, &status
);
2085 // Delete the service
2089 TCHAR szService
[ cchNAME
];
2090 lpiService
->GetServiceName (szService
);
2093 wp
.wpBosProcessDelete
.hServer
= hBOS
;
2094 wp
.wpBosProcessDelete
.pszService
= szService
;
2097 rc
= Worker_DoTask (wtaskBosProcessDelete
, &wp
, &status
);
2103 if ((lpServer
= lpiService
->OpenServer (&status
)) == NULL
)
2107 lpServer
->InvalidateServices();
2108 if (!lpServer
->RefreshServices (TRUE
, &status
))
2114 if ((lpServer
= lpiService
->OpenServer (&status
)) != NULL
)
2116 lpServer
->CloseBosObject();
2120 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteServiceEnd
, lpiService
, status
);
2129 BOOL
AfsClass_ReleaseFileset (LPIDENT lpiFilesetRW
, BOOL fForce
, ULONG
*pStatus
)
2135 NOTIFYCALLBACK::SendNotificationToAll (evtReleaseFilesetBegin
, lpiFilesetRW
);
2137 // Obtain hCell and hVOS
2142 if ((lpServer
= lpiFilesetRW
->OpenServer (&status
)) == NULL
)
2146 if ((hVOS
= lpServer
->OpenVosObject (&hCell
, &status
)) == NULL
)
2151 // Perform the actual operation
2156 wp
.wpVosVolumeRelease
.hCell
= hCell
;
2157 wp
.wpVosVolumeRelease
.fForce
= fForce
;
2158 lpiFilesetRW
->GetFilesetID (&wp
.wpVosVolumeRelease
.idVolume
);
2161 rc
= Worker_DoTask (wtaskVosVolumeRelease
, &wp
, &status
);
2170 if ((lpCell
= lpiFilesetRW
->OpenCell (&status
)) == NULL
)
2174 lpCell
->Invalidate();
2175 rc
= lpCell
->RefreshAll (&status
);
2182 if ((lpServer
= lpiFilesetRW
->OpenServer (&status
)) != NULL
)
2184 lpServer
->CloseVosObject();
2189 NOTIFYCALLBACK::SendNotificationToAll (evtReleaseFilesetEnd
, lpiFilesetRW
, status
);
2198 BOOL
AfsClass_GetFileDates (LPIDENT lpiServer
, LPTSTR pszFilename
, SYSTEMTIME
*pstFile
, SYSTEMTIME
*pstBAK
, SYSTEMTIME
*pstOLD
, ULONG
*pStatus
)
2204 NOTIFYCALLBACK::SendNotificationToAll (evtGetFileDatesBegin
, lpiServer
, pszFilename
, 0);
2209 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
2213 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
2221 wp
.wpBosExecutableTimestampGet
.hServer
= hBOS
;
2222 wp
.wpBosExecutableTimestampGet
.pszFilename
= pszFilename
;
2225 if ((rc
= Worker_DoTask (wtaskBosExecutableTimestampGet
, &wp
, &status
)) == TRUE
)
2227 *pstFile
= wp
.wpBosExecutableTimestampGet
.timeNew
;
2228 *pstBAK
= wp
.wpBosExecutableTimestampGet
.timeBak
;
2229 *pstOLD
= wp
.wpBosExecutableTimestampGet
.timeOld
;
2235 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
2237 lpServer
->CloseBosObject();
2241 NOTIFYCALLBACK::SendNotificationToAll (evtGetFileDatesEnd
, lpiServer
, pszFilename
, status
);
2250 BOOL
AfsClass_ExecuteCommand (LPIDENT lpiServer
, LPTSTR pszCommand
, ULONG
*pStatus
)
2256 NOTIFYCALLBACK::SendNotificationToAll (evtExecuteCommandBegin
, lpiServer
, pszCommand
, 0);
2261 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
2265 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
2273 wp
.wpBosCommandExecute
.hServer
= hBOS
;
2274 wp
.wpBosCommandExecute
.pszCommand
= pszCommand
;
2277 rc
= Worker_DoTask (wtaskBosCommandExecute
, &wp
, &status
);
2281 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
2283 lpServer
->CloseBosObject();
2287 NOTIFYCALLBACK::SendNotificationToAll (evtExecuteCommandEnd
, lpiServer
, pszCommand
, status
);
2296 LPADMINLIST
AfsClass_AdminList_Load (LPIDENT lpiServer
, ULONG
*pStatus
)
2300 LPADMINLIST lpList
= NULL
;
2303 NOTIFYCALLBACK::SendNotificationToAll (evtAdminListLoadBegin
, lpiServer
);
2308 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
2312 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
2319 lpList
= New(ADMINLIST
);
2320 memset (lpList
, 0x00, sizeof(ADMINLIST
));
2322 lpList
->lpiServer
= lpiServer
;
2324 WORKERPACKET wpBegin
;
2325 wpBegin
.wpBosAdminGetBegin
.hServer
= hBOS
;
2326 if (!Worker_DoTask (wtaskBosAdminGetBegin
, &wpBegin
, &status
))
2332 TCHAR szAdmin
[ cchNAME
];
2334 WORKERPACKET wpNext
;
2335 wpNext
.wpBosAdminGetNext
.hEnum
= wpBegin
.wpBosAdminGetBegin
.hEnum
;
2336 wpNext
.wpBosAdminGetNext
.pszAdmin
= szAdmin
;
2338 if (!Worker_DoTask (wtaskBosAdminGetNext
, &wpNext
, &status
))
2340 if (status
== ADMITERATORDONE
)
2348 if ((iAdded
= AfsClass_AdminList_AddEntry (lpList
, szAdmin
)) != (size_t)-1)
2350 lpList
->aEntries
[ iAdded
].fAdded
= FALSE
;
2354 WORKERPACKET wpDone
;
2355 wpDone
.wpBosAdminGetDone
.hEnum
= wpBegin
.wpBosAdminGetBegin
.hEnum
;
2356 Worker_DoTask (wtaskBosAdminGetDone
, &wpDone
);
2360 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
2362 lpServer
->CloseBosObject();
2366 NOTIFYCALLBACK::SendNotificationToAll (evtAdminListLoadEnd
, lpiServer
, status
);
2371 return (rc
) ? lpList
: NULL
;
2375 LPADMINLIST
AfsClass_AdminList_Copy (LPADMINLIST lpOld
)
2377 LPADMINLIST lpNew
= NULL
;
2381 lpNew
= New(ADMINLIST
);
2382 memcpy (lpNew
, lpOld
, sizeof(ADMINLIST
));
2385 lpNew
->aEntries
= 0;
2386 lpNew
->cEntries
= 0;
2388 if (REALLOC (lpNew
->aEntries
, lpNew
->cEntries
, lpOld
->cEntries
, cREALLOC_ADMINLISTENTRIES
))
2390 size_t cb
= lpOld
->cEntries
* sizeof(ADMINLISTENTRY
);
2391 memcpy (lpNew
->aEntries
, lpOld
->aEntries
, cb
);
2399 BOOL
AfsClass_AdminList_Save (LPADMINLIST lpList
, ULONG
*pStatus
)
2405 NOTIFYCALLBACK::SendNotificationToAll (evtAdminListSaveBegin
, lpList
->lpiServer
);
2410 if ((lpServer
= lpList
->lpiServer
->OpenServer (&status
)) == NULL
)
2414 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
2421 for (size_t iEntry
= 0; iEntry
< lpList
->cEntries
; ++iEntry
)
2423 if (!lpList
->aEntries
[ iEntry
].szAdmin
[0])
2426 // are we supposed to add this entry?
2428 if (lpList
->aEntries
[ iEntry
].fAdded
&& !lpList
->aEntries
[ iEntry
].fDeleted
)
2431 wp
.wpBosAdminCreate
.hServer
= hBOS
;
2432 wp
.wpBosAdminCreate
.pszAdmin
= lpList
->aEntries
[ iEntry
].szAdmin
;
2435 if (!Worker_DoTask (wtaskBosAdminCreate
, &wp
, &thisstatus
))
2438 status
= thisstatus
;
2442 lpList
->aEntries
[ iEntry
].fAdded
= FALSE
;
2446 // are we supposed to delete this entry?
2448 if (!lpList
->aEntries
[ iEntry
].fAdded
&& lpList
->aEntries
[ iEntry
].fDeleted
)
2451 wp
.wpBosAdminDelete
.hServer
= hBOS
;
2452 wp
.wpBosAdminDelete
.pszAdmin
= lpList
->aEntries
[ iEntry
].szAdmin
;
2455 if (!Worker_DoTask (wtaskBosAdminDelete
, &wp
, &thisstatus
))
2458 status
= thisstatus
;
2462 lpList
->aEntries
[ iEntry
].szAdmin
[0] = TEXT('\0');
2463 lpList
->aEntries
[ iEntry
].fDeleted
= FALSE
;
2469 if ((lpServer
= lpList
->lpiServer
->OpenServer (&status
)) != NULL
)
2471 lpServer
->CloseBosObject();
2475 NOTIFYCALLBACK::SendNotificationToAll (evtAdminListSaveEnd
, lpList
->lpiServer
, status
);
2484 void AfsClass_AdminList_Free (LPADMINLIST lpList
)
2486 if (lpList
&& !InterlockedDecrement (&lpList
->cRef
))
2488 if (lpList
->aEntries
)
2489 Free (lpList
->aEntries
);
2490 memset (lpList
, 0x00, sizeof(ADMINLIST
));
2496 size_t AfsClass_AdminList_AddEntry (LPADMINLIST lpList
, LPTSTR pszAdmin
)
2498 size_t iAdded
= (size_t)-1;
2503 for (iEntry
= 0; iEntry
< lpList
->cEntries
; ++iEntry
)
2505 if (!lpList
->aEntries
[ iEntry
].szAdmin
[0])
2508 if (iEntry
>= lpList
->cEntries
)
2510 (void)REALLOC (lpList
->aEntries
, lpList
->cEntries
, 1+iEntry
, cREALLOC_ADMINLISTENTRIES
);
2512 if (iEntry
< lpList
->cEntries
)
2515 lstrcpy (lpList
->aEntries
[ iAdded
].szAdmin
, pszAdmin
);
2516 lpList
->aEntries
[ iAdded
].fAdded
= TRUE
;
2517 lpList
->aEntries
[ iAdded
].fDeleted
= FALSE
;
2525 BOOL
AfsClass_AdminList_DelEntry (LPADMINLIST lpList
, size_t iIndex
)
2530 (iIndex
< lpList
->cEntries
) &&
2531 (lpList
->aEntries
[ iIndex
].szAdmin
[0]) &&
2532 (!lpList
->aEntries
[ iIndex
].fDeleted
) )
2534 if (lpList
->aEntries
[ iIndex
].fAdded
)
2535 lpList
->aEntries
[ iIndex
].szAdmin
[0] = TEXT('\0');
2537 lpList
->aEntries
[ iIndex
].fDeleted
= TRUE
;
2546 LPKEYLIST
AfsClass_KeyList_Load (LPIDENT lpiServer
, ULONG
*pStatus
)
2550 LPKEYLIST lpList
= NULL
;
2553 NOTIFYCALLBACK::SendNotificationToAll (evtKeyListLoadBegin
, lpiServer
);
2558 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
2562 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
2569 lpList
= New(KEYLIST
);
2570 memset (lpList
, 0x00, sizeof(KEYLIST
));
2571 lpList
->lpiServer
= lpiServer
;
2573 WORKERPACKET wpBegin
;
2574 wpBegin
.wpBosKeyGetBegin
.hServer
= hBOS
;
2575 if (!Worker_DoTask (wtaskBosKeyGetBegin
, &wpBegin
, &status
))
2579 for (size_t iEnum
= 0; ; ++iEnum
)
2581 WORKERPACKET wpNext
;
2582 wpNext
.wpBosKeyGetNext
.hEnum
= wpBegin
.wpBosKeyGetBegin
.hEnum
;
2584 if (!Worker_DoTask (wtaskBosKeyGetNext
, &wpNext
, &status
))
2586 if (status
== ADMITERATORDONE
)
2593 if (REALLOC (lpList
->aKeys
, lpList
->cKeys
, 1+iEnum
, cREALLOC_SERVERKEYS
))
2595 lpList
->aKeys
[ iEnum
].keyVersion
= wpNext
.wpBosKeyGetNext
.keyVersion
;
2596 memcpy (&lpList
->aKeys
[ iEnum
].keyData
, &wpNext
.wpBosKeyGetNext
.keyData
, sizeof(ENCRYPTIONKEY
));
2597 memcpy (&lpList
->aKeys
[ iEnum
].keyInfo
, &wpNext
.wpBosKeyGetNext
.keyInfo
, sizeof(ENCRYPTIONKEYINFO
));
2601 WORKERPACKET wpDone
;
2602 wpDone
.wpBosKeyGetDone
.hEnum
= wpBegin
.wpBosKeyGetBegin
.hEnum
;
2603 Worker_DoTask (wtaskBosKeyGetDone
, &wpDone
);
2607 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
2609 lpServer
->CloseBosObject();
2613 NOTIFYCALLBACK::SendNotificationToAll (evtKeyListLoadEnd
, lpiServer
, status
);
2618 return (rc
) ? lpList
: NULL
;
2622 void AfsClass_KeyList_Free (LPKEYLIST lpList
)
2627 Free (lpList
->aKeys
);
2628 memset (lpList
, 0x00, sizeof(KEYLIST
));
2634 BOOL
AfsClass_AddKey (LPIDENT lpiServer
, int keyVersion
, LPTSTR pszString
, ULONG
*pStatus
)
2639 TCHAR szCell
[ cchNAME
];
2640 lpiServer
->GetCellName (szCell
);
2643 wp
.wpKasStringToKey
.pszCell
= szCell
;
2644 wp
.wpKasStringToKey
.pszString
= pszString
;
2645 if (!Worker_DoTask (wtaskKasStringToKey
, &wp
, &status
))
2649 else if (!AfsClass_AddKey (lpiServer
, keyVersion
, &wp
.wpKasStringToKey
.key
, &status
))
2660 BOOL
AfsClass_AddKey (LPIDENT lpiServer
, int keyVersion
, LPENCRYPTIONKEY pKey
, ULONG
*pStatus
)
2668 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
2672 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
2680 wp
.wpBosKeyCreate
.hServer
= hBOS
;
2681 wp
.wpBosKeyCreate
.keyVersion
= keyVersion
;
2682 memcpy (&wp
.wpBosKeyCreate
.key
, pKey
, sizeof(ENCRYPTIONKEY
));
2683 rc
= Worker_DoTask (wtaskBosKeyCreate
, &wp
, &status
);
2686 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
2688 lpServer
->CloseBosObject();
2698 BOOL
AfsClass_DeleteKey (LPIDENT lpiServer
, int keyVersion
, ULONG
*pStatus
)
2706 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
2710 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
2718 wp
.wpBosKeyDelete
.hServer
= hBOS
;
2719 wp
.wpBosKeyDelete
.keyVersion
= keyVersion
;
2720 rc
= Worker_DoTask (wtaskBosKeyDelete
, &wp
, &status
);
2723 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
2725 lpServer
->CloseBosObject();
2735 BOOL
AfsClass_GetRandomKey (LPIDENT lpi
, LPENCRYPTIONKEY pKey
, ULONG
*pStatus
)
2743 if ((lpCell
= lpi
->OpenCell (&status
)) == NULL
)
2747 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
2750 hKAS
= lpCell
->GetKasObject (&status
);
2757 wp
.wpKasServerRandomKeyGet
.hCell
= hCell
;
2758 wp
.wpKasServerRandomKeyGet
.hServer
= hKAS
;
2759 rc
= Worker_DoTask (wtaskKasServerRandomKeyGet
, &wp
, &status
);
2762 memcpy (pKey
, &wp
.wpKasServerRandomKeyGet
.key
, sizeof(ENCRYPTIONKEY
));
2771 BOOL
AfsClass_Clone (LPIDENT lpiRW
, ULONG
*pStatus
)
2777 NOTIFYCALLBACK::SendNotificationToAll (evtCloneBegin
, lpiRW
, 0);
2783 if ((lpCell
= lpiRW
->OpenCell (&status
)) == NULL
)
2787 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
2792 // Perform the actual operation
2797 wp
.wpVosBackupVolumeCreate
.hCell
= hCell
;
2798 lpiRW
->GetFilesetID (&wp
.wpVosBackupVolumeCreate
.idVolume
);
2801 rc
= Worker_DoTask (wtaskVosBackupVolumeCreate
, &wp
, &status
);
2810 if ((lpServer
= lpiRW
->OpenServer (&status
)) == NULL
)
2814 lpServer
->Invalidate();
2815 rc
= lpServer
->RefreshAll (&status
);
2820 NOTIFYCALLBACK::SendNotificationToAll (evtCloneEnd
, lpiRW
, status
);
2829 BOOL
AfsClass_CloneMultiple (LPIDENT lpi
, LPTSTR pszPrefix
, BOOL fExclude
, ULONG
*pStatus
)
2835 NOTIFYCALLBACK::SendNotificationToAll (evtCloneMultipleBegin
, lpi
);
2841 if ((lpCell
= lpi
->OpenCell (&status
)) == NULL
)
2845 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
2850 // Obtain hServer if appropriate
2853 if (!lpi
->fIsCell())
2856 if ((lpServer
= lpi
->OpenServer (&status
)) == NULL
)
2860 if ((hVOS
= lpServer
->OpenVosObject (NULL
, &status
)) == NULL
)
2866 // If requested, obtain the appropriate aggregate ID
2868 int idPartition
= NO_PARTITION
;
2869 if (rc
&& (lpi
->fIsFileset() || lpi
->fIsAggregate()))
2871 LPAGGREGATE lpAggregate
;
2872 if ((lpAggregate
= lpi
->OpenAggregate (&status
)) == NULL
)
2876 if ((idPartition
= lpAggregate
->GetID()) == NO_PARTITION
)
2878 lpAggregate
->Close();
2882 // Perform the actual operation
2887 wp
.wpVosBackupVolumeCreateMultiple
.hCell
= hCell
;
2888 wp
.wpVosBackupVolumeCreateMultiple
.hServer
= hVOS
;
2889 wp
.wpVosBackupVolumeCreateMultiple
.idPartition
= idPartition
;
2890 wp
.wpVosBackupVolumeCreateMultiple
.pszPrefix
= pszPrefix
;
2891 wp
.wpVosBackupVolumeCreateMultiple
.fExclude
= fExclude
;
2894 rc
= Worker_DoTask (wtaskVosBackupVolumeCreateMultiple
, &wp
, &status
);
2905 if ((lpCell
= lpi
->OpenCell (&status
)) == NULL
)
2909 lpCell
->Invalidate();
2910 rc
= lpCell
->RefreshAll (&status
);
2917 if ((lpServer
= lpi
->OpenServer (&status
)) == NULL
)
2921 lpServer
->Invalidate();
2922 rc
= lpServer
->RefreshAll (&status
);
2931 if ((lpServer
= lpi
->OpenServer (&status
)) != NULL
)
2933 lpServer
->CloseVosObject();
2938 NOTIFYCALLBACK::SendNotificationToAll (evtCloneMultipleEnd
, lpi
, status
);
2947 BOOL
AfsClass_DumpFileset (LPIDENT lpi
, LPTSTR pszFilename
, LPSYSTEMTIME pstDate
, ULONG
*pStatus
)
2953 NOTIFYCALLBACK::SendNotificationToAll (evtDumpFilesetBegin
, lpi
, pszFilename
, 0);
2955 // Obtain hCell and hVOS
2960 if ((lpServer
= lpi
->OpenServer (&status
)) == NULL
)
2964 if ((hVOS
= lpServer
->OpenVosObject (&hCell
, &status
)) == NULL
)
2969 // Obtain idPartition
2972 LPAGGREGATE lpAggregate
;
2973 if ((lpAggregate
= lpi
->OpenAggregate (&status
)) == NULL
)
2977 idPartition
= lpAggregate
->GetID();
2978 lpAggregate
->Close();
2981 // Perform the actual operation
2986 wp
.wpVosVolumeDump
.hCell
= hCell
;
2987 wp
.wpVosVolumeDump
.hServer
= hVOS
;
2988 wp
.wpVosVolumeDump
.pszFilename
= pszFilename
;
2989 wp
.wpVosVolumeDump
.idPartition
= idPartition
;
2990 lpi
->GetFilesetID (&wp
.wpVosVolumeDump
.idVolume
);
2993 memcpy (&wp
.wpVosVolumeDump
.stStart
, pstDate
, sizeof(SYSTEMTIME
));
2995 memset (&wp
.wpVosVolumeDump
.stStart
, 0x00, sizeof(SYSTEMTIME
));
2998 rc
= Worker_DoTask (wtaskVosVolumeDump
, &wp
, &status
);
3002 NOTIFYCALLBACK::SendNotificationToAll (evtDumpFilesetEnd
, lpi
, pszFilename
, status
);
3008 if ((lpServer
= lpi
->OpenServer (&status
)) != NULL
)
3010 lpServer
->CloseVosObject();
3021 BOOL
AfsClass_RestoreFileset (LPIDENT lpi
, LPTSTR pszFileset
, LPTSTR pszFilename
, BOOL fIncremental
, ULONG
*pStatus
)
3027 NOTIFYCALLBACK::SendNotificationToAll (evtRestoreFilesetBegin
, lpi
, NULL
, pszFileset
, pszFilename
, 0, 0);
3029 // Obtain hCell and hVOS
3034 if ((lpServer
= lpi
->OpenServer (&status
)) == NULL
)
3038 if ((hVOS
= lpServer
->OpenVosObject (&hCell
, &status
)) == NULL
)
3043 // Obtain idPartition
3046 LPAGGREGATE lpAggregate
;
3047 if ((lpAggregate
= lpi
->OpenAggregate (&status
)) == NULL
)
3051 idPartition
= lpAggregate
->GetID();
3052 lpAggregate
->Close();
3055 // Perform the actual operation
3060 wp
.wpVosVolumeRestore
.hCell
= hCell
;
3061 wp
.wpVosVolumeRestore
.hServer
= hVOS
;
3062 wp
.wpVosVolumeRestore
.idPartition
= idPartition
;
3063 wp
.wpVosVolumeRestore
.pszVolume
= pszFileset
;
3064 wp
.wpVosVolumeRestore
.pszFilename
= pszFilename
;
3065 wp
.wpVosVolumeRestore
.fIncremental
= fIncremental
;
3067 if (lpi
->fIsFileset())
3068 lpi
->GetFilesetID (&wp
.wpVosVolumeRestore
.idVolume
);
3070 wp
.wpVosVolumeRestore
.idVolume
= NO_VOLUME
;
3073 rc
= Worker_DoTask (wtaskVosVolumeRestore
, &wp
, &status
);
3081 if ((lpServer
= lpi
->OpenServer (&status
)) == NULL
)
3085 lpServer
->Invalidate();
3086 rc
= lpServer
->RefreshAll (&status
);
3093 if ((lpServer
= lpi
->OpenServer (&status
)) != NULL
)
3095 lpServer
->CloseVosObject();
3100 NOTIFYCALLBACK::SendNotificationToAll (evtRestoreFilesetEnd
, lpi
, NULL
, pszFileset
, pszFilename
, 0, status
);
3109 BOOL
AfsClass_GetRestartTimes (LPIDENT lpiServer
, BOOL
*pfWeekly
, LPSYSTEMTIME pstWeekly
, BOOL
*pfDaily
, LPSYSTEMTIME pstDaily
, ULONG
*pStatus
)
3115 NOTIFYCALLBACK::SendNotificationToAll (evtGetRestartTimesBegin
, lpiServer
);
3120 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
3124 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
3132 wp
.wpBosExecutableRestartTimeGet
.hServer
= hBOS
;
3135 rc
= Worker_DoTask (wtaskBosExecutableRestartTimeGet
, &wp
, &status
);
3140 *pfWeekly
= wp
.wpBosExecutableRestartTimeGet
.fWeeklyRestart
;
3141 *pstWeekly
= wp
.wpBosExecutableRestartTimeGet
.timeWeekly
;
3142 *pfDaily
= wp
.wpBosExecutableRestartTimeGet
.fDailyRestart
;
3143 *pstDaily
= wp
.wpBosExecutableRestartTimeGet
.timeDaily
;
3147 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
3149 lpServer
->CloseBosObject();
3153 NOTIFYCALLBACK::SendNotificationToAll (evtGetRestartTimesEnd
, lpiServer
, status
);
3162 BOOL
AfsClass_SetRestartTimes (LPIDENT lpiServer
, LPSYSTEMTIME pstWeekly
, LPSYSTEMTIME pstDaily
, ULONG
*pStatus
)
3168 NOTIFYCALLBACK::SendNotificationToAll (evtSetRestartTimesBegin
, lpiServer
);
3173 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
3177 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
3184 SYSTEMTIME timeNever
;
3185 memset (&timeNever
, 0x00, sizeof(SYSTEMTIME
));
3188 wp
.wpBosExecutableRestartTimeSet
.hServer
= hBOS
;
3189 wp
.wpBosExecutableRestartTimeSet
.fWeeklyRestart
= (pstWeekly
!= NULL
) ? TRUE
: FALSE
;
3190 wp
.wpBosExecutableRestartTimeSet
.timeWeekly
= (pstWeekly
!= NULL
) ? *pstWeekly
: timeNever
;
3191 wp
.wpBosExecutableRestartTimeSet
.fDailyRestart
= (pstDaily
!= NULL
) ? TRUE
: FALSE
;
3192 wp
.wpBosExecutableRestartTimeSet
.timeDaily
= (pstDaily
!= NULL
) ? *pstDaily
: timeNever
;
3195 rc
= Worker_DoTask (wtaskBosExecutableRestartTimeSet
, &wp
, &status
);
3199 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
3201 lpServer
->CloseBosObject();
3205 NOTIFYCALLBACK::SendNotificationToAll (evtSetRestartTimesEnd
, lpiServer
, status
);
3214 BOOL
AfsClass_MoveReplica (LPIDENT lpiReplica
, LPIDENT lpiAggregateTarget
, ULONG
*pStatus
)
3218 // Find the identifier for this replica's read/write fileset.
3220 LPIDENT lpiFilesetRW
= NULL
;
3221 LPFILESET lpFileset
;
3222 if ((lpFileset
= lpiReplica
->OpenFileset (pStatus
)) == NULL
)
3226 if ((lpiFilesetRW
= lpFileset
->GetReadWriteIdentifier (pStatus
)) == NULL
)
3231 // If the fileset replica currently resides on the same server
3232 // as the target aggregate, we'll follow the following steps:
3234 // 1. Delete the old fileset replica -> on error, quit
3235 // 2. Create the new fileset replica -> on error, recreate old replica, quit
3237 // If the fileset replica instead currently resides on a different
3238 // server, we can follow the preferred steps:
3240 // 1. Create the new fileset replica -> on error, quit
3241 // 2. Delete the old fileset replica -> on error, delete the new replica, quit
3245 LPIDENT lpiReplicaNew
;
3247 if (lpiReplica
->GetServer() == lpiAggregateTarget
->GetServer())
3249 LPIDENT lpiAggregateOriginal
= lpiReplica
->GetAggregate();
3251 if (!AfsClass_DeleteReplica (lpiReplica
, pStatus
))
3255 else if ((lpiReplicaNew
= AfsClass_CreateReplica (lpiFilesetRW
, lpiAggregateTarget
, pStatus
)) == NULL
)
3257 (void)AfsClass_CreateReplica (lpiFilesetRW
, lpiAggregateOriginal
);
3261 else // different server?
3263 if ((lpiReplicaNew
= AfsClass_CreateReplica (lpiFilesetRW
, lpiAggregateTarget
, pStatus
)) == NULL
)
3267 else if (!AfsClass_DeleteReplica (lpiReplica
, pStatus
))
3269 (void)AfsClass_DeleteReplica (lpiReplicaNew
, pStatus
);
3279 BOOL
AfsClass_Salvage (LPIDENT lpiSalvage
, LPTSTR
*ppszLogData
, int nProcesses
, LPTSTR pszTempDir
, LPTSTR pszLogFile
, BOOL fForce
, BOOL fReadonly
, BOOL fLogInodes
, BOOL fLogRootInodes
, BOOL fRebuildDirs
, BOOL fReadBlocks
, ULONG
*pStatus
)
3285 NOTIFYCALLBACK::SendNotificationToAll (evtSalvageBegin
, lpiSalvage
);
3290 if ((lpServer
= lpiSalvage
->OpenServer (&status
)) == NULL
)
3294 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
3300 *ppszLogData
= NULL
;
3302 // Step one: perform the actual salvage. This will dump a log file onto
3303 // the target computer.
3307 LPTSTR pszAggregate
= NULL
;
3308 TCHAR szAggregate
[ cchNAME
];
3309 if (lpiSalvage
->fIsAggregate() || lpiSalvage
->fIsFileset())
3311 lpiSalvage
->GetAggregateName (szAggregate
);
3312 pszAggregate
= szAggregate
;
3315 LPTSTR pszFileset
= NULL
;
3316 TCHAR szFileset
[ cchNAME
];
3317 if (lpiSalvage
->fIsFileset())
3320 lpiSalvage
->GetFilesetID (&vid
);
3321 wsprintf (szFileset
, TEXT("%lu"), vid
);
3322 pszFileset
= szFileset
;
3325 if (pszLogFile
== NULL
)
3326 pszLogFile
= TEXT("SalvageLog");
3329 wp
.wpBosSalvage
.hCell
= hCell
;
3330 wp
.wpBosSalvage
.hServer
= hBOS
;
3331 wp
.wpBosSalvage
.pszAggregate
= pszAggregate
;
3332 wp
.wpBosSalvage
.pszFileset
= pszFileset
;
3333 wp
.wpBosSalvage
.nProcesses
= nProcesses
;
3334 wp
.wpBosSalvage
.pszTempDir
= pszTempDir
;
3335 wp
.wpBosSalvage
.pszLogFile
= pszLogFile
;
3336 wp
.wpBosSalvage
.fForce
= fForce
;
3337 wp
.wpBosSalvage
.fReadonly
= fReadonly
;
3338 wp
.wpBosSalvage
.fLogInodes
= fLogInodes
;
3339 wp
.wpBosSalvage
.fLogRootInodes
= fLogRootInodes
;
3340 wp
.wpBosSalvage
.fRebuildDirs
= fRebuildDirs
;
3341 wp
.wpBosSalvage
.fReadBlocks
= fReadBlocks
;
3344 rc
= Worker_DoTask (wtaskBosSalvage
, &wp
, &status
);
3348 // Step two: retrieve the log file from that salvage operation.
3349 // If we can't get the log file back, that's not fatal--just return
3350 // a NULL pointer for the log data.
3352 if (rc
&& ppszLogData
)
3355 wp
.wpBosLogGet
.hServer
= hBOS
;
3356 wp
.wpBosLogGet
.pszLogName
= pszLogFile
;
3357 wp
.wpBosLogGet
.pszLogData
= NULL
;
3360 if ((rc
= Worker_DoTask (wtaskBosLogGet
, &wp
, &status
)) == TRUE
)
3362 // Okay, well, we have the log in memory now. Problem is,
3363 // it has UNIX-style CR's... and so is missing the LF which
3364 // PCs expect before each CR. Wow--look at all the
3365 // acronyms! Count the CRs, alloc a larger buffer, and stuff
3366 // in the LFs before each CR.
3368 size_t cchRequired
= 1;
3369 for (LPTSTR pchIn
= wp
.wpBosLogGet
.pszLogData
; *pchIn
; ++pchIn
)
3371 cchRequired
+= (*pchIn
== TEXT('\r')) ? 0 : (*pchIn
== TEXT('\n')) ? 2 : 1;
3374 if ((*ppszLogData
= AllocateString (cchRequired
)) != NULL
)
3376 LPTSTR pszOut
= *ppszLogData
;
3377 for (LPTSTR pchIn
= wp
.wpBosLogGet
.pszLogData
; *pchIn
; ++pchIn
)
3379 if (*pchIn
== TEXT('\n'))
3380 *pszOut
++ = TEXT('\r');
3381 if (*pchIn
!= TEXT('\r'))
3384 *pszOut
++ = TEXT('\0');
3390 if ((lpServer
= lpiSalvage
->OpenServer (&status
)) != NULL
)
3392 lpServer
->CloseBosObject();
3396 NOTIFYCALLBACK::SendNotificationToAll (evtSalvageEnd
, lpiSalvage
, status
);
3405 void AfsClass_FreeSalvageLog (LPTSTR pszLogData
)
3412 LPHOSTLIST
AfsClass_HostList_Load (LPIDENT lpiServer
, ULONG
*pStatus
)
3416 LPHOSTLIST lpList
= NULL
;
3419 NOTIFYCALLBACK::SendNotificationToAll (evtHostListLoadBegin
, lpiServer
);
3424 if ((lpServer
= lpiServer
->OpenServer (&status
)) == NULL
)
3428 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
3435 lpList
= New(HOSTLIST
);
3436 memset (lpList
, 0x00, sizeof(HOSTLIST
));
3438 lpList
->lpiServer
= lpiServer
;
3440 WORKERPACKET wpBegin
;
3441 wpBegin
.wpBosHostGetBegin
.hServer
= hBOS
;
3442 if (!Worker_DoTask (wtaskBosHostGetBegin
, &wpBegin
, &status
))
3448 TCHAR szHost
[ cchNAME
];
3450 WORKERPACKET wpNext
;
3451 wpNext
.wpBosHostGetNext
.hEnum
= wpBegin
.wpBosHostGetBegin
.hEnum
;
3452 wpNext
.wpBosHostGetNext
.pszServer
= szHost
;
3454 if (!Worker_DoTask (wtaskBosHostGetNext
, &wpNext
, &status
))
3456 if (status
== ADMITERATORDONE
)
3464 if ((iAdded
= AfsClass_HostList_AddEntry (lpList
, szHost
)) != (size_t)-1)
3466 lpList
->aEntries
[ iAdded
].fAdded
= FALSE
;
3470 WORKERPACKET wpDone
;
3471 wpDone
.wpBosHostGetDone
.hEnum
= wpBegin
.wpBosHostGetBegin
.hEnum
;
3472 Worker_DoTask (wtaskBosHostGetDone
, &wpDone
);
3476 if ((lpServer
= lpiServer
->OpenServer (&status
)) != NULL
)
3478 lpServer
->CloseBosObject();
3482 NOTIFYCALLBACK::SendNotificationToAll (evtHostListLoadEnd
, lpiServer
, status
);
3487 return (rc
) ? lpList
: NULL
;
3491 LPHOSTLIST
AfsClass_HostList_Copy (LPHOSTLIST lpOld
)
3493 LPHOSTLIST lpNew
= NULL
;
3497 lpNew
= New(HOSTLIST
);
3498 memcpy (lpNew
, lpOld
, sizeof(HOSTLIST
));
3501 lpNew
->aEntries
= 0;
3502 lpNew
->cEntries
= 0;
3504 if (REALLOC (lpNew
->aEntries
, lpNew
->cEntries
, lpOld
->cEntries
, cREALLOC_HOSTLISTENTRIES
))
3506 size_t cb
= lpOld
->cEntries
* sizeof(HOSTLISTENTRY
);
3507 memcpy (lpNew
->aEntries
, lpOld
->aEntries
, cb
);
3515 BOOL
AfsClass_HostList_Save (LPHOSTLIST lpList
, ULONG
*pStatus
)
3521 NOTIFYCALLBACK::SendNotificationToAll (evtHostListSaveBegin
, lpList
->lpiServer
);
3526 if ((lpServer
= lpList
->lpiServer
->OpenServer (&status
)) == NULL
)
3530 if ((hBOS
= lpServer
->OpenBosObject (&hCell
, &status
)) == NULL
)
3537 for (size_t iEntry
= 0; iEntry
< lpList
->cEntries
; ++iEntry
)
3539 if (!lpList
->aEntries
[ iEntry
].szHost
[0])
3542 // are we supposed to add this entry?
3544 if (lpList
->aEntries
[ iEntry
].fAdded
&& !lpList
->aEntries
[ iEntry
].fDeleted
)
3547 wp
.wpBosHostCreate
.hServer
= hBOS
;
3548 wp
.wpBosHostCreate
.pszServer
= lpList
->aEntries
[ iEntry
].szHost
;
3551 if (!Worker_DoTask (wtaskBosHostCreate
, &wp
, &thisstatus
))
3554 status
= thisstatus
;
3558 lpList
->aEntries
[ iEntry
].fAdded
= FALSE
;
3562 // are we supposed to delete this entry?
3564 if (!lpList
->aEntries
[ iEntry
].fAdded
&& lpList
->aEntries
[ iEntry
].fDeleted
)
3567 wp
.wpBosHostDelete
.hServer
= hBOS
;
3568 wp
.wpBosHostDelete
.pszServer
= lpList
->aEntries
[ iEntry
].szHost
;
3571 if (!Worker_DoTask (wtaskBosHostDelete
, &wp
, &thisstatus
))
3574 status
= thisstatus
;
3578 lpList
->aEntries
[ iEntry
].szHost
[0] = TEXT('\0');
3579 lpList
->aEntries
[ iEntry
].fDeleted
= FALSE
;
3585 if ((lpServer
= lpList
->lpiServer
->OpenServer (&status
)) != NULL
)
3587 lpServer
->CloseBosObject();
3591 NOTIFYCALLBACK::SendNotificationToAll (evtHostListSaveEnd
, lpList
->lpiServer
, status
);
3600 void AfsClass_HostList_Free (LPHOSTLIST lpList
)
3602 if (lpList
&& !InterlockedDecrement (&lpList
->cRef
))
3604 if (lpList
->aEntries
)
3605 Free (lpList
->aEntries
);
3606 memset (lpList
, 0x00, sizeof(HOSTLIST
));
3612 size_t AfsClass_HostList_AddEntry (LPHOSTLIST lpList
, LPTSTR pszHost
)
3614 size_t iAdded
= (size_t)-1;
3619 for (iEntry
= 0; iEntry
< lpList
->cEntries
; ++iEntry
)
3621 if (!lpList
->aEntries
[ iEntry
].szHost
[0])
3624 if (iEntry
>= lpList
->cEntries
)
3626 (void)REALLOC (lpList
->aEntries
, lpList
->cEntries
, 1+iEntry
, cREALLOC_HOSTLISTENTRIES
);
3628 if (iEntry
< lpList
->cEntries
)
3631 lstrcpy (lpList
->aEntries
[ iAdded
].szHost
, pszHost
);
3632 lpList
->aEntries
[ iAdded
].fAdded
= TRUE
;
3633 lpList
->aEntries
[ iAdded
].fDeleted
= FALSE
;
3641 BOOL
AfsClass_HostList_DelEntry (LPHOSTLIST lpList
, size_t iIndex
)
3646 (iIndex
< lpList
->cEntries
) &&
3647 (lpList
->aEntries
[ iIndex
].szHost
[0]) &&
3648 (!lpList
->aEntries
[ iIndex
].fDeleted
) )
3650 if (lpList
->aEntries
[ iIndex
].fAdded
)
3651 lpList
->aEntries
[ iIndex
].szHost
[0] = TEXT('\0');
3653 lpList
->aEntries
[ iIndex
].fDeleted
= TRUE
;
3662 BOOL
AfsClass_GetPtsProperties (LPIDENT lpiCell
, LPPTSPROPERTIES pProperties
, ULONG
*pStatus
)
3667 memset (pProperties
, 0x00, sizeof(PTSPROPERTIES
));
3673 if ((lpCell
= lpiCell
->OpenCell (&status
)) == NULL
)
3677 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
3682 // Go get the necessary properties
3687 wp
.wpPtsUserMaxGet
.hCell
= hCell
;
3689 if ((rc
= Worker_DoTask (wtaskPtsUserMaxGet
, &wp
, &status
)) == TRUE
)
3690 pProperties
->idUserMax
= wp
.wpPtsUserMaxGet
.idUserMax
;
3696 wp
.wpPtsGroupMaxGet
.hCell
= hCell
;
3698 if ((rc
= Worker_DoTask (wtaskPtsGroupMaxGet
, &wp
, &status
)) == TRUE
)
3699 pProperties
->idGroupMax
= wp
.wpPtsGroupMaxGet
.idGroupMax
;
3708 BOOL
AfsClass_SetPtsProperties (LPIDENT lpiCell
, LPPTSPROPERTIES pProperties
, ULONG
*pStatus
)
3717 if ((lpCell
= lpiCell
->OpenCell (&status
)) == NULL
)
3721 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
3726 // Modify the specified properties
3731 wp
.wpPtsUserMaxSet
.hCell
= hCell
;
3732 wp
.wpPtsUserMaxSet
.idUserMax
= pProperties
->idUserMax
;
3733 rc
= Worker_DoTask (wtaskPtsUserMaxSet
, &wp
, &status
);
3739 wp
.wpPtsGroupMaxSet
.hCell
= hCell
;
3740 wp
.wpPtsGroupMaxSet
.idGroupMax
= pProperties
->idGroupMax
;
3741 Worker_DoTask (wtaskPtsGroupMaxSet
, &wp
, &status
);
3750 LPIDENT
AfsClass_CreateUser (LPIDENT lpiCell
, LPTSTR pszUserName
, LPTSTR pszInstance
, LPTSTR pszPassword
, UINT_PTR idUser
, BOOL fCreateKAS
, BOOL fCreatePTS
, ULONG
*pStatus
)
3755 if (pszInstance
&& !*pszInstance
)
3759 NOTIFYCALLBACK::SendNotificationToAll (evtCreateUserBegin
, lpiCell
, pszUserName
, 0);
3761 // We'll need both hCell and hKAS.
3766 if ((lpCell
= lpiCell
->OpenCell (&status
)) == NULL
)
3770 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
3773 hKAS
= lpCell
->GetKasObject (&status
);
3777 // First try to create a KAS entry.
3779 if (rc
&& fCreateKAS
)
3782 wp
.wpKasPrincipalCreate
.hCell
= hCell
;
3783 wp
.wpKasPrincipalCreate
.hServer
= hKAS
;
3784 wp
.wpKasPrincipalCreate
.pszPrincipal
= pszUserName
;
3785 wp
.wpKasPrincipalCreate
.pszInstance
= pszInstance
;
3786 wp
.wpKasPrincipalCreate
.pszPassword
= pszPassword
;
3789 rc
= Worker_DoTask (wtaskKasPrincipalCreate
, &wp
, &status
);
3793 // If that succeeded, try to create a PTS entry as well.
3795 if (rc
&& fCreatePTS
)
3797 TCHAR szUserName
[ cchNAME
];
3798 lstrcpy (szUserName
, pszUserName
);
3800 wsprintf (&szUserName
[ lstrlen(szUserName
) ], TEXT(".%s"), pszInstance
);
3803 wp
.wpPtsUserCreate
.hCell
= hCell
;
3804 wp
.wpPtsUserCreate
.pszUser
= szUserName
;
3805 wp
.wpPtsUserCreate
.idUser
= (int) idUser
;
3809 if ((rc
= Worker_DoTask (wtaskPtsUserCreate
, &wp
, &status
)) == FALSE
)
3811 if (status
== PREXIST
)
3817 // If we couldn't make a KAS entry as well, remove the KAS entry.
3822 wpDel
.wpKasPrincipalDelete
.hCell
= hCell
;
3823 wpDel
.wpKasPrincipalDelete
.hServer
= hKAS
;
3824 wpDel
.wpKasPrincipalDelete
.pszPrincipal
= pszUserName
;
3825 wpDel
.wpKasPrincipalDelete
.pszInstance
= pszInstance
;
3826 Worker_DoTask (wtaskKasPrincipalDelete
, &wpDel
);
3833 // If we were able to create the user's accounts successfully, refresh
3834 // the cell status and return the new user's ident.
3840 if ((lpCell
= lpiCell
->OpenCell (&status
)) == NULL
)
3844 if (!lpCell
->RefreshAccount (pszUserName
, pszInstance
, CELL_REFRESH_ACCOUNT_CREATED_USER
, &lpiUser
))
3852 NOTIFYCALLBACK::SendNotificationToAll (evtCreateUserEnd
, lpiCell
, pszUserName
, status
);
3857 return (rc
) ? lpiUser
: NULL
;
3861 BOOL
AfsClass_SetUserProperties (LPIDENT lpiUser
, LPUSERPROPERTIES pProperties
, ULONG
*pStatus
)
3867 NOTIFYCALLBACK::SendNotificationToAll (evtChangeUserBegin
, lpiUser
);
3869 // We'll need both hCell and hKAS.
3874 if ((lpCell
= lpiUser
->OpenCell (&status
)) == NULL
)
3878 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
3881 hKAS
= lpCell
->GetKasObject (&status
);
3885 // We'll also need this user's current status
3889 if ((lpUser
= lpiUser
->OpenUser (&status
)) == NULL
)
3893 if (!lpUser
->GetStatus (&us
, TRUE
, &status
))
3898 // Modify the user's KAS entry (if necessary)
3900 DWORD dwKasMask
= ( MASK_USERPROP_fAdmin
|
3901 MASK_USERPROP_fGrantTickets
|
3902 MASK_USERPROP_fCanEncrypt
|
3903 MASK_USERPROP_fCanChangePassword
|
3904 MASK_USERPROP_fCanReusePasswords
|
3905 MASK_USERPROP_timeAccountExpires
|
3906 MASK_USERPROP_cdayPwExpires
|
3907 MASK_USERPROP_csecTicketLifetime
|
3908 MASK_USERPROP_nFailureAttempts
|
3909 MASK_USERPROP_csecFailedLoginLockTime
);
3911 if (rc
&& (pProperties
->dwMask
& dwKasMask
))
3913 TCHAR szPrincipal
[ cchNAME
];
3914 TCHAR szInstance
[ cchNAME
];
3915 lpiUser
->GetUserName (szPrincipal
, szInstance
);
3918 wp
.wpKasPrincipalFieldsSet
.hCell
= hCell
;
3919 wp
.wpKasPrincipalFieldsSet
.hServer
= hKAS
;
3920 wp
.wpKasPrincipalFieldsSet
.pszPrincipal
= szPrincipal
;
3921 wp
.wpKasPrincipalFieldsSet
.pszInstance
= szInstance
;
3922 wp
.wpKasPrincipalFieldsSet
.fIsAdmin
= (pProperties
->dwMask
& MASK_USERPROP_fAdmin
) ? pProperties
->fAdmin
: us
.KASINFO
.fIsAdmin
;
3923 wp
.wpKasPrincipalFieldsSet
.fGrantTickets
= (pProperties
->dwMask
& MASK_USERPROP_fGrantTickets
) ? pProperties
->fGrantTickets
: us
.KASINFO
.fCanGetTickets
;
3924 wp
.wpKasPrincipalFieldsSet
.fCanEncrypt
= (pProperties
->dwMask
& MASK_USERPROP_fCanEncrypt
) ? pProperties
->fCanEncrypt
: us
.KASINFO
.fEncrypt
;
3925 wp
.wpKasPrincipalFieldsSet
.fCanChangePassword
= (pProperties
->dwMask
& MASK_USERPROP_fCanChangePassword
) ? pProperties
->fCanChangePassword
: us
.KASINFO
.fCanChangePassword
;
3926 wp
.wpKasPrincipalFieldsSet
.fCanReusePasswords
= (pProperties
->dwMask
& MASK_USERPROP_fCanReusePasswords
) ? pProperties
->fCanReusePasswords
: us
.KASINFO
.fCanReusePasswords
;
3927 memcpy (&wp
.wpKasPrincipalFieldsSet
.timeExpires
, (pProperties
->dwMask
& MASK_USERPROP_timeAccountExpires
) ? &pProperties
->timeAccountExpires
: &us
.KASINFO
.timeExpires
, sizeof(SYSTEMTIME
));
3928 wp
.wpKasPrincipalFieldsSet
.cdayPwExpires
= (pProperties
->dwMask
& MASK_USERPROP_cdayPwExpires
) ? pProperties
->cdayPwExpires
: us
.KASINFO
.cdayPwExpire
;
3929 wp
.wpKasPrincipalFieldsSet
.csecTicketLifetime
= (pProperties
->dwMask
& MASK_USERPROP_csecTicketLifetime
) ? pProperties
->csecTicketLifetime
: us
.KASINFO
.csecTicketLifetime
;
3930 wp
.wpKasPrincipalFieldsSet
.nFailureAttempts
= (pProperties
->dwMask
& MASK_USERPROP_nFailureAttempts
) ? pProperties
->nFailureAttempts
: us
.KASINFO
.cFailLogin
;
3931 wp
.wpKasPrincipalFieldsSet
.csecFailedLoginLockTime
= (pProperties
->dwMask
& MASK_USERPROP_csecFailedLoginLockTime
) ? pProperties
->csecFailedLoginLockTime
: us
.KASINFO
.csecFailLoginLock
;
3934 rc
= Worker_DoTask (wtaskKasPrincipalFieldsSet
, &wp
, &status
);
3939 // Modify the user's PTS entry (if necessary)
3941 DWORD dwPtsMask
= ( MASK_USERPROP_cGroupCreationQuota
|
3942 MASK_USERPROP_aaListStatus
|
3943 MASK_USERPROP_aaGroupsOwned
|
3944 MASK_USERPROP_aaMembership
);
3946 if (rc
&& (pProperties
->dwMask
& dwPtsMask
))
3948 TCHAR szFullName
[ cchNAME
];
3949 lpiUser
->GetFullUserName (szFullName
);
3952 wp
.wpPtsUserModify
.hCell
= hCell
;
3953 wp
.wpPtsUserModify
.pszUser
= szFullName
;
3954 memset (&wp
.wpPtsUserModify
.Delta
, 0x00, sizeof(wp
.wpPtsUserModify
.Delta
));
3956 if (pProperties
->dwMask
& MASK_USERPROP_cGroupCreationQuota
)
3958 wp
.wpPtsUserModify
.Delta
.flag
= (pts_UserUpdateFlag_t
)( (LONG
)wp
.wpPtsUserModify
.Delta
.flag
| (LONG
)PTS_USER_UPDATE_GROUP_CREATE_QUOTA
);
3959 wp
.wpPtsUserModify
.Delta
.groupCreationQuota
= pProperties
->cGroupCreationQuota
;
3962 if (pProperties
->dwMask
& (MASK_USERPROP_aaListStatus
| MASK_USERPROP_aaGroupsOwned
| MASK_USERPROP_aaMembership
))
3964 wp
.wpPtsUserModify
.Delta
.flag
= (pts_UserUpdateFlag_t
)( (LONG
)wp
.wpPtsUserModify
.Delta
.flag
| (LONG
)PTS_USER_UPDATE_PERMISSIONS
);
3965 wp
.wpPtsUserModify
.Delta
.listStatus
= ACCOUNTACCESS_TO_USERACCESS( (pProperties
->dwMask
& MASK_USERPROP_aaListStatus
) ? pProperties
->aaListStatus
: us
.PTSINFO
.aaListStatus
);
3966 wp
.wpPtsUserModify
.Delta
.listGroupsOwned
= ACCOUNTACCESS_TO_USERACCESS( (pProperties
->dwMask
& MASK_USERPROP_aaGroupsOwned
) ? pProperties
->aaGroupsOwned
: us
.PTSINFO
.aaGroupsOwned
);
3967 wp
.wpPtsUserModify
.Delta
.listMembership
= ACCOUNTACCESS_TO_USERACCESS( (pProperties
->dwMask
& MASK_USERPROP_aaMembership
) ? pProperties
->aaMembership
: us
.PTSINFO
.aaMembership
);
3971 rc
= Worker_DoTask (wtaskPtsUserModify
, &wp
, &status
);
3975 // If we were able to modify the user's properties successfully, refresh
3976 // that user's status.
3978 if ((lpUser
= lpiUser
->OpenUser (&status
)) != NULL
)
3980 lpUser
->Invalidate();
3981 lpUser
->RefreshStatus();
3985 NOTIFYCALLBACK::SendNotificationToAll (evtChangeUserBegin
, lpiUser
, status
);
3994 BOOL
AfsClass_SetUserPassword (LPIDENT lpiUser
, int keyVersion
, LPTSTR pszPassword
, ULONG
*pStatus
)
3999 TCHAR szCell
[ cchNAME
];
4000 lpiUser
->GetCellName (szCell
);
4003 wp
.wpKasStringToKey
.pszCell
= szCell
;
4004 wp
.wpKasStringToKey
.pszString
= pszPassword
;
4005 if (!Worker_DoTask (wtaskKasStringToKey
, &wp
, &status
))
4009 else if (!AfsClass_SetUserPassword (lpiUser
, keyVersion
, &wp
.wpKasStringToKey
.key
, &status
))
4020 BOOL
AfsClass_SetUserPassword (LPIDENT lpiUser
, int keyVersion
, LPENCRYPTIONKEY pKey
, ULONG
*pStatus
)
4026 NOTIFYCALLBACK::SendNotificationToAll (evtChangeUserPasswordBegin
, lpiUser
);
4028 // We'll need both hCell and hKAS.
4033 if ((lpCell
= lpiUser
->OpenCell (&status
)) == NULL
)
4037 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
4040 hKAS
= lpCell
->GetKasObject (&status
);
4044 // Change the user's password
4048 TCHAR szPrincipal
[ cchNAME
];
4049 TCHAR szInstance
[ cchNAME
];
4050 lpiUser
->GetUserName (szPrincipal
, szInstance
);
4053 wp
.wpKasPrincipalKeySet
.hCell
= hCell
;
4054 wp
.wpKasPrincipalKeySet
.hServer
= hKAS
;
4055 wp
.wpKasPrincipalKeySet
.pszPrincipal
= szPrincipal
;
4056 wp
.wpKasPrincipalKeySet
.pszInstance
= szInstance
;
4057 wp
.wpKasPrincipalKeySet
.keyVersion
= keyVersion
;
4058 memcpy (&wp
.wpKasPrincipalKeySet
.key
.key
, &pKey
->key
, ENCRYPTIONKEY_LEN
);
4061 rc
= Worker_DoTask (wtaskKasPrincipalKeySet
, &wp
, &status
);
4065 // If we were able to modify the user's password successfully, refresh
4066 // that user's status.
4069 if ((lpUser
= lpiUser
->OpenUser (&status
)) != NULL
)
4071 lpUser
->Invalidate();
4072 lpUser
->RefreshStatus();
4076 NOTIFYCALLBACK::SendNotificationToAll (evtChangeUserPasswordEnd
, lpiUser
, status
);
4085 BOOL
AfsClass_DeleteUser (LPIDENT lpiUser
, BOOL fDeleteKAS
, BOOL fDeletePTS
, ULONG
*pStatus
)
4091 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteUserBegin
, lpiUser
);
4093 // We'll need both hCell and hKAS.
4098 if ((lpCell
= lpiUser
->OpenCell (&status
)) == NULL
)
4102 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
4105 hKAS
= lpCell
->GetKasObject (&status
);
4109 // Find out whether this user has KAS and/or PTS entries. Also
4110 // get the various lists of groups for this user...
4113 LPTSTR mszOwnerOf
= NULL
;
4114 LPTSTR mszMemberOf
= NULL
;
4115 if ((lpUser
= lpiUser
->OpenUser (&status
)) == NULL
)
4119 lpUser
->GetOwnerOf (&mszOwnerOf
);
4120 lpUser
->GetMemberOf (&mszMemberOf
);
4124 // Delete the user's PTS entry
4126 if (rc
&& fDeletePTS
)
4128 TCHAR szFullName
[ cchNAME
];
4129 lpiUser
->GetFullUserName (szFullName
);
4132 wp
.wpPtsUserDelete
.hCell
= hCell
;
4133 wp
.wpPtsUserDelete
.pszUser
= szFullName
;
4136 if ((rc
= Worker_DoTask (wtaskPtsUserDelete
, &wp
, &status
)) == FALSE
)
4138 if (status
== ADMPTSFAILEDNAMETRANSLATE
) // User had no PTS entry?
4144 // Delete the user's KAS entry
4146 if (rc
&& fDeleteKAS
)
4148 TCHAR szPrincipal
[ cchNAME
];
4149 TCHAR szInstance
[ cchNAME
];
4150 lpiUser
->GetUserName (szPrincipal
, szInstance
);
4153 wp
.wpKasPrincipalDelete
.hCell
= hCell
;
4154 wp
.wpKasPrincipalDelete
.hServer
= hKAS
;
4155 wp
.wpKasPrincipalDelete
.pszPrincipal
= szPrincipal
;
4156 wp
.wpKasPrincipalDelete
.pszInstance
= szInstance
;
4159 if ((rc
= Worker_DoTask (wtaskKasPrincipalDelete
, &wp
, &status
)) == FALSE
)
4161 if (status
== KANOENT
)
4167 // If we were able to delete the user's accounts successfully, refresh
4172 if ((lpCell
= lpiUser
->OpenCell (&status
)) != NULL
)
4174 TCHAR szPrincipal
[ cchNAME
];
4175 TCHAR szInstance
[ cchNAME
];
4176 lpiUser
->GetUserName (szPrincipal
, szInstance
);
4178 lpCell
->RefreshAccount (szPrincipal
, szInstance
, CELL_REFRESH_ACCOUNT_DELETED
);
4179 lpCell
->RefreshAccounts (mszOwnerOf
, CELL_REFRESH_ACCOUNT_CHANGED
);
4180 lpCell
->RefreshAccounts (mszMemberOf
, CELL_REFRESH_ACCOUNT_CHANGED
);
4185 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteUserEnd
, lpiUser
, status
);
4189 FreeString (mszOwnerOf
);
4191 FreeString (mszMemberOf
);
4198 BOOL
AfsClass_UnlockUser (LPIDENT lpiUser
, ULONG
*pStatus
)
4204 NOTIFYCALLBACK::SendNotificationToAll (evtUnlockUserBegin
, lpiUser
);
4206 // We'll need both hCell and hKAS.
4211 if ((lpCell
= lpiUser
->OpenCell (&status
)) == NULL
)
4215 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
4218 hKAS
= lpCell
->GetKasObject (&status
);
4222 // Unlock the user's KAS entry
4226 TCHAR szPrincipal
[ cchNAME
];
4227 TCHAR szInstance
[ cchNAME
];
4228 lpiUser
->GetUserName (szPrincipal
, szInstance
);
4231 wp
.wpKasPrincipalUnlock
.hCell
= hCell
;
4232 wp
.wpKasPrincipalUnlock
.hServer
= hKAS
;
4233 wp
.wpKasPrincipalUnlock
.pszPrincipal
= szPrincipal
;
4234 wp
.wpKasPrincipalUnlock
.pszInstance
= szInstance
;
4237 rc
= Worker_DoTask (wtaskKasPrincipalUnlock
, &wp
, &status
);
4241 // If we were able to unlock the user's accounts successfully, refresh
4242 // the user's properties.
4247 if ((lpUser
= lpiUser
->OpenUser (&status
)) != NULL
)
4249 lpUser
->Invalidate();
4250 lpUser
->RefreshStatus();
4255 NOTIFYCALLBACK::SendNotificationToAll (evtUnlockUserEnd
, lpiUser
, status
);
4264 LPIDENT
AfsClass_CreateGroup (LPIDENT lpiCell
, LPTSTR pszGroupName
, LPIDENT lpiOwner
, int idGroup
, ULONG
*pStatus
)
4270 NOTIFYCALLBACK::SendNotificationToAll (evtCreateGroupBegin
, lpiCell
, pszGroupName
, 0);
4276 if ((lpCell
= lpiCell
->OpenCell (&status
)) == NULL
)
4280 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
4285 // Create a PTS entry for the new group
4289 TCHAR szOwner
[ cchNAME
] = TEXT("");
4290 if (lpiOwner
&& lpiOwner
->fIsUser())
4291 lpiOwner
->GetFullUserName (szOwner
);
4292 else if (lpiOwner
&& lpiOwner
->fIsGroup())
4293 lpiOwner
->GetGroupName (szOwner
);
4296 wp
.wpPtsGroupCreate
.hCell
= hCell
;
4297 wp
.wpPtsGroupCreate
.pszGroup
= pszGroupName
;
4298 wp
.wpPtsGroupCreate
.pszOwner
= (szOwner
[0]) ? szOwner
: NULL
;
4299 wp
.wpPtsGroupCreate
.idGroup
= idGroup
;
4302 rc
= Worker_DoTask (wtaskPtsGroupCreate
, &wp
, &status
);
4306 // If we were able to create the group successfully, refresh
4307 // the cell status and return the new group's ident.
4313 if ((lpCell
= lpiCell
->OpenCell (&status
)) == NULL
)
4317 if (!lpCell
->RefreshAccount (pszGroupName
, NULL
, CELL_REFRESH_ACCOUNT_CREATED_GROUP
, &lpiGroup
))
4325 NOTIFYCALLBACK::SendNotificationToAll (evtCreateGroupEnd
, lpiCell
, pszGroupName
, status
);
4330 return (rc
) ? lpiGroup
: NULL
;
4334 BOOL
AfsClass_SetGroupProperties (LPIDENT lpiGroup
, LPGROUPPROPERTIES pProperties
, ULONG
*pStatus
)
4340 NOTIFYCALLBACK::SendNotificationToAll (evtChangeGroupBegin
, lpiGroup
);
4346 if ((lpCell
= lpiGroup
->OpenCell (&status
)) == NULL
)
4350 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
4355 // We'll also need this group's current status
4359 if ((lpGroup
= lpiGroup
->OpenGroup (&status
)) == NULL
)
4363 if (!lpGroup
->GetStatus (&gs
, TRUE
, &status
))
4368 // Modify the group's PTS entry (if requested)
4370 DWORD dwPtsMask
= ( MASK_GROUPPROP_aaListStatus
|
4371 MASK_GROUPPROP_aaListGroupsOwned
|
4372 MASK_GROUPPROP_aaListMembers
|
4373 MASK_GROUPPROP_aaAddMember
|
4374 MASK_GROUPPROP_aaDeleteMember
);
4376 if (rc
&& (pProperties
->dwMask
& dwPtsMask
))
4378 TCHAR szGroup
[ cchNAME
];
4379 lpiGroup
->GetGroupName (szGroup
);
4382 wp
.wpPtsGroupModify
.hCell
= hCell
;
4383 wp
.wpPtsGroupModify
.pszGroup
= szGroup
;
4384 memset (&wp
.wpPtsGroupModify
.Delta
, 0x00, sizeof(wp
.wpPtsGroupModify
.Delta
));
4385 wp
.wpPtsGroupModify
.Delta
.listStatus
= ACCOUNTACCESS_TO_GROUPACCESS( (pProperties
->dwMask
& MASK_GROUPPROP_aaListStatus
) ? pProperties
->aaListStatus
: gs
.aaListStatus
);
4386 wp
.wpPtsGroupModify
.Delta
.listGroupsOwned
= ACCOUNTACCESS_TO_GROUPACCESS( (pProperties
->dwMask
& MASK_GROUPPROP_aaListGroupsOwned
) ? pProperties
->aaListGroupsOwned
: gs
.aaListGroupsOwned
);
4387 wp
.wpPtsGroupModify
.Delta
.listMembership
= ACCOUNTACCESS_TO_GROUPACCESS( (pProperties
->dwMask
& MASK_GROUPPROP_aaListMembers
) ? pProperties
->aaListMembers
: gs
.aaListMembers
);
4388 wp
.wpPtsGroupModify
.Delta
.listAdd
= ACCOUNTACCESS_TO_GROUPACCESS( (pProperties
->dwMask
& MASK_GROUPPROP_aaAddMember
) ? pProperties
->aaAddMember
: gs
.aaAddMember
);
4389 wp
.wpPtsGroupModify
.Delta
.listDelete
= ACCOUNTACCESS_TO_GROUPACCESS( (pProperties
->dwMask
& MASK_GROUPPROP_aaDeleteMember
) ? pProperties
->aaDeleteMember
: gs
.aaDeleteMember
);
4392 rc
= Worker_DoTask (wtaskPtsGroupModify
, &wp
, &status
);
4396 // Change the group's owner (if requested)
4398 if (rc
&& (pProperties
->dwMask
& MASK_GROUPPROP_szOwner
))
4400 TCHAR szGroup
[ cchNAME
];
4401 lpiGroup
->GetGroupName (szGroup
);
4404 wp
.wpPtsGroupOwnerChange
.hCell
= hCell
;
4405 wp
.wpPtsGroupOwnerChange
.pszGroup
= szGroup
;
4406 wp
.wpPtsGroupOwnerChange
.pszOwner
= pProperties
->szOwner
;
4409 rc
= Worker_DoTask (wtaskPtsGroupOwnerChange
, &wp
, &status
);
4413 // If we were able to modify the group's properties successfully, refresh
4414 // either the group's status. If the group's owner changed, also refresh
4415 // the group's old and new owners.
4419 if ((lpCell
= lpiGroup
->OpenCell (&status
)) != NULL
)
4421 TCHAR szAccount
[ cchNAME
];
4422 lpiGroup
->GetGroupName (szAccount
);
4423 lpCell
->RefreshAccount (szAccount
, NULL
, CELL_REFRESH_ACCOUNT_CHANGED
);
4425 if (pProperties
->dwMask
& MASK_GROUPPROP_szOwner
)
4427 lpCell
->RefreshAccount (gs
.szOwner
, NULL
, CELL_REFRESH_ACCOUNT_CHANGED
);
4428 lpCell
->RefreshAccount (pProperties
->szOwner
, NULL
, CELL_REFRESH_ACCOUNT_CHANGED
);
4435 NOTIFYCALLBACK::SendNotificationToAll (evtChangeGroupBegin
, lpiGroup
, status
);
4444 BOOL
AfsClass_RenameGroup (LPIDENT lpiGroup
, LPTSTR pszNewName
, ULONG
*pStatus
)
4450 NOTIFYCALLBACK::SendNotificationToAll (evtRenameGroupBegin
, lpiGroup
);
4456 if ((lpCell
= lpiGroup
->OpenCell (&status
)) == NULL
)
4460 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
4465 // Get this group's list of members (etc)
4467 LPTSTR mszOwnerOf
= NULL
;
4468 LPTSTR mszMemberOf
= NULL
;
4469 LPTSTR mszMembers
= NULL
;
4472 if ((lpGroup
= lpiGroup
->OpenGroup (&status
)) != NULL
)
4474 lpGroup
->GetOwnerOf (&mszOwnerOf
);
4475 lpGroup
->GetMemberOf (&mszMemberOf
);
4476 lpGroup
->GetMembers (&mszMembers
);
4480 // Rename the group's PTS entry
4484 TCHAR szGroup
[ cchNAME
];
4485 lpiGroup
->GetGroupName (szGroup
);
4488 wp
.wpPtsGroupRename
.hCell
= hCell
;
4489 wp
.wpPtsGroupRename
.pszGroup
= szGroup
;
4490 wp
.wpPtsGroupRename
.pszNewName
= pszNewName
;
4493 rc
= Worker_DoTask (wtaskPtsGroupRename
, &wp
, &status
);
4497 // If we were able to rename the group successfully, refresh the cell status.
4502 if ((lpGroup
= lpiGroup
->OpenGroup (&status
)) != NULL
)
4504 lpGroup
->ChangeIdentName (pszNewName
);
4507 if ((lpCell
= lpiGroup
->OpenCell (&status
)) != NULL
)
4509 lpCell
->RefreshAccount (pszNewName
, NULL
, CELL_REFRESH_ACCOUNT_CHANGED
);
4510 lpCell
->RefreshAccounts (mszOwnerOf
, CELL_REFRESH_ACCOUNT_CHANGED
);
4511 lpCell
->RefreshAccounts (mszMemberOf
, CELL_REFRESH_ACCOUNT_CHANGED
);
4512 lpCell
->RefreshAccounts (mszMembers
, CELL_REFRESH_ACCOUNT_CHANGED
);
4517 NOTIFYCALLBACK::SendNotificationToAll (evtRenameGroupEnd
, lpiGroup
, status
);
4521 FreeString (mszOwnerOf
);
4523 FreeString (mszMemberOf
);
4525 FreeString (mszMembers
);
4532 BOOL
AfsClass_DeleteGroup (LPIDENT lpiGroup
, ULONG
*pStatus
)
4538 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteGroupBegin
, lpiGroup
);
4544 if ((lpCell
= lpiGroup
->OpenCell (&status
)) == NULL
)
4548 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
4553 // Get this group's list of members (etc)
4555 LPTSTR mszOwnerOf
= NULL
;
4556 LPTSTR mszMemberOf
= NULL
;
4557 LPTSTR mszMembers
= NULL
;
4560 if ((lpGroup
= lpiGroup
->OpenGroup (&status
)) != NULL
)
4562 lpGroup
->GetOwnerOf (&mszOwnerOf
);
4563 lpGroup
->GetMemberOf (&mszMemberOf
);
4564 lpGroup
->GetMembers (&mszMembers
);
4568 // Delete the group's PTS entry
4572 TCHAR szGroup
[ cchNAME
];
4573 lpiGroup
->GetGroupName (szGroup
);
4576 wp
.wpPtsGroupDelete
.hCell
= hCell
;
4577 wp
.wpPtsGroupDelete
.pszGroup
= szGroup
;
4580 if ((rc
= Worker_DoTask (wtaskPtsGroupDelete
, &wp
, &status
)) == FALSE
)
4582 if (status
== ADMPTSFAILEDNAMETRANSLATE
) // Group had no PTS entry?
4588 // If we were able to delete the group successfully, refresh the cell status.
4592 if ((lpCell
= lpiGroup
->OpenCell (&status
)) != NULL
)
4594 TCHAR szGroup
[ cchNAME
];
4595 lpiGroup
->GetGroupName (szGroup
);
4596 lpCell
->RefreshAccounts (mszOwnerOf
, CELL_REFRESH_ACCOUNT_CHANGED
);
4597 lpCell
->RefreshAccounts (mszMemberOf
, CELL_REFRESH_ACCOUNT_CHANGED
);
4598 lpCell
->RefreshAccounts (mszMembers
, CELL_REFRESH_ACCOUNT_CHANGED
);
4599 lpCell
->RefreshAccount (szGroup
, NULL
, CELL_REFRESH_ACCOUNT_DELETED
);
4604 NOTIFYCALLBACK::SendNotificationToAll (evtDeleteGroupEnd
, lpiGroup
, status
);
4608 FreeString (mszOwnerOf
);
4610 FreeString (mszMemberOf
);
4612 FreeString (mszMembers
);
4619 BOOL
AfsClass_AddUserToGroup (LPIDENT lpiGroup
, LPIDENT lpiUser
, ULONG
*pStatus
)
4625 NOTIFYCALLBACK::SendNotificationToAll (evtGroupMemberAddBegin
, lpiGroup
, lpiUser
, NULL
, NULL
, 0, 0);
4631 if ((lpCell
= lpiGroup
->OpenCell (&status
)) == NULL
)
4635 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
4640 TCHAR szGroup
[ cchNAME
];
4641 lpiGroup
->GetGroupName (szGroup
);
4643 TCHAR szMember
[ cchNAME
];
4644 if (lpiUser
->fIsUser())
4645 lpiUser
->GetFullUserName (szMember
);
4646 else // (lpiUser->fIsGroup())
4647 lpiUser
->GetGroupName (szMember
);
4649 // Add this user to the specified group
4654 wp
.wpPtsGroupMemberAdd
.hCell
= hCell
;
4655 wp
.wpPtsGroupMemberAdd
.pszGroup
= szGroup
;
4656 wp
.wpPtsGroupMemberAdd
.pszUser
= szMember
;
4659 rc
= Worker_DoTask (wtaskPtsGroupMemberAdd
, &wp
, &status
);
4663 // If we were able to change the group successfully, update the group's
4664 // and user's properties.
4668 if ((lpCell
= lpiGroup
->OpenCell (&status
)) != NULL
)
4670 lpCell
->RefreshAccount (szGroup
, NULL
, CELL_REFRESH_ACCOUNT_CHANGED
);
4671 lpCell
->RefreshAccount (szMember
, NULL
, CELL_REFRESH_ACCOUNT_CHANGED
);
4676 NOTIFYCALLBACK::SendNotificationToAll (evtGroupMemberAddEnd
, lpiGroup
, lpiUser
, NULL
, NULL
, 0, status
);
4685 BOOL
AfsClass_RemoveUserFromGroup (LPIDENT lpiGroup
, LPIDENT lpiUser
, ULONG
*pStatus
)
4691 NOTIFYCALLBACK::SendNotificationToAll (evtGroupMemberRemoveBegin
, lpiGroup
, lpiUser
, NULL
, NULL
, 0, 0);
4697 if ((lpCell
= lpiGroup
->OpenCell (&status
)) == NULL
)
4701 if ((hCell
= lpCell
->GetCellObject (&status
)) == NULL
)
4706 TCHAR szGroup
[ cchNAME
];
4707 lpiGroup
->GetGroupName (szGroup
);
4709 TCHAR szMember
[ cchNAME
];
4710 if (lpiUser
->fIsUser())
4711 lpiUser
->GetFullUserName (szMember
);
4712 else // (lpiUser->fIsGroup())
4713 lpiUser
->GetGroupName (szMember
);
4715 // Remove this user from the specified group
4720 wp
.wpPtsGroupMemberRemove
.hCell
= hCell
;
4721 wp
.wpPtsGroupMemberRemove
.pszGroup
= szGroup
;
4722 wp
.wpPtsGroupMemberRemove
.pszUser
= szMember
;
4725 rc
= Worker_DoTask (wtaskPtsGroupMemberRemove
, &wp
, &status
);
4729 // If we were able to change the group successfully, update the group's
4730 // and user's properties.
4734 if ((lpCell
= lpiGroup
->OpenCell (&status
)) != NULL
)
4736 lpCell
->RefreshAccount (szGroup
, NULL
, CELL_REFRESH_ACCOUNT_CHANGED
);
4737 lpCell
->RefreshAccount (szMember
, NULL
, CELL_REFRESH_ACCOUNT_CHANGED
);
4742 NOTIFYCALLBACK::SendNotificationToAll (evtGroupMemberRemoveEnd
, lpiGroup
, lpiUser
, NULL
, NULL
, 0, status
);