Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / WINNT / afsadmsvr / TaAfsAdmSvrClient.cpp
1
2 extern "C" {
3 #include <afs/param.h>
4 #include <afs/stds.h>
5 }
6
7 #include "TaAfsAdmSvrClientInternal.h"
8
9
10 /*
11  * VARIABLES __________________________________________________________________
12  *
13  */
14
15 static struct
16    {
17    BOOL fInitializedSockets;
18    size_t cReqForAdminServer;
19    } l;
20
21
22 /*
23  * ROUTINES ___________________________________________________________________
24  *
25  */
26
27 void __RPC_FAR * __RPC_USER MIDL_user_allocate (size_t cbAllocate)
28 {
29    return (void __RPC_FAR *)Allocate (cbAllocate);
30 }
31
32 void __RPC_USER MIDL_user_free (void __RPC_FAR *pData)
33 {
34    Free (pData);
35 }
36
37
38 /*
39  * DATA STRUCTURES ____________________________________________________________
40  *
41  */
42
43 BOOL ADMINAPI asc_AsidListCreate (LPASIDLIST *ppList)
44 {
45    return ((*ppList = AfsAdmSvr_CreateAsidList()) != NULL);
46 }
47
48 BOOL ADMINAPI asc_AsidListCopy (LPASIDLIST *ppListTarget, LPASIDLIST *ppListSource)
49 {
50    return ((*ppListTarget = AfsAdmSvr_CopyAsidList (*ppListSource)) != NULL);
51 }
52
53 BOOL ADMINAPI asc_AsidListAddEntry (LPASIDLIST *ppList, ASID idObject, LPARAM lp)
54 {
55    return AfsAdmSvr_AddToAsidList (ppList, idObject, lp);
56 }
57
58 BOOL ADMINAPI asc_AsidListRemoveEntry (LPASIDLIST *ppList, ASID idObject)
59 {
60    return AfsAdmSvr_RemoveFromAsidList (ppList, idObject);
61 }
62
63 BOOL ADMINAPI asc_AsidListRemoveEntryByIndex (LPASIDLIST *ppList, size_t iIndex)
64 {
65    return AfsAdmSvr_RemoveFromAsidListByIndex (ppList, iIndex);
66 }
67
68 BOOL ADMINAPI asc_AsidListSetEntryParam (LPASIDLIST *ppList, ASID idObject, LPARAM lp)
69 {
70    return AfsAdmSvr_SetAsidListParam (ppList, idObject, lp);
71 }
72
73 BOOL ADMINAPI asc_AsidListSetEntryParamByIndex (LPASIDLIST *ppList, size_t iIndex, LPARAM lp)
74 {
75    return AfsAdmSvr_SetAsidListParamByIndex (ppList, iIndex, lp);
76 }
77
78 BOOL ADMINAPI asc_AsidListTest (LPASIDLIST *ppList, ASID idObject, LPARAM *pParam)
79 {
80    return AfsAdmSvr_IsInAsidList (ppList, idObject, pParam);
81 }
82
83 BOOL ADMINAPI asc_AsidListFree (LPASIDLIST *ppList)
84 {
85    AfsAdmSvr_FreeAsidList (ppList);
86    return TRUE;
87 }
88
89
90 BOOL ADMINAPI asc_ObjPropListCreate (LPASOBJPROPLIST *ppList)
91 {
92    return ((*ppList = AfsAdmSvr_CreateObjPropList()) != NULL);
93 }
94
95 BOOL ADMINAPI asc_ObjPropListCopy (LPASOBJPROPLIST *ppListTarget, LPASOBJPROPLIST *ppListSource)
96 {
97    return ((*ppListTarget = AfsAdmSvr_CopyObjPropList (*ppListSource)) != NULL);
98 }
99
100 BOOL ADMINAPI asc_ObjPropListAddEntry (LPASOBJPROPLIST *ppList, LPASOBJPROP pProperties, LPARAM lp)
101 {
102    return AfsAdmSvr_AddToObjPropList (ppList, pProperties, lp);
103 }
104
105 BOOL ADMINAPI asc_ObjPropListRemoveEntry (LPASOBJPROPLIST *ppList, ASID idObject)
106 {
107    return AfsAdmSvr_RemoveFromObjPropList (ppList, idObject);
108 }
109
110 BOOL ADMINAPI asc_ObjPropListTest (LPASOBJPROPLIST *ppList, ASID idObject, LPASOBJPROP pProperties, LPARAM *pParam)
111 {
112    return AfsAdmSvr_IsInObjPropList (ppList, idObject, pProperties, pParam);
113 }
114
115 BOOL ADMINAPI asc_ObjPropListFree (LPASOBJPROPLIST *ppList)
116 {
117    AfsAdmSvr_FreeObjPropList (ppList);
118    return TRUE;
119 }
120
121
122 BOOL ADMINAPI asc_ActionListCreate (LPASACTIONLIST *ppList)
123 {
124    return ((*ppList = AfsAdmSvr_CreateActionList()) != NULL);
125 }
126
127 BOOL ADMINAPI asc_ActionListCopy (LPASACTIONLIST *ppListTarget, LPASACTIONLIST *ppListSource)
128 {
129    return ((*ppListTarget = AfsAdmSvr_CopyActionList (*ppListSource)) != NULL);
130 }
131
132 BOOL ADMINAPI asc_ActionListAddEntry (LPASACTIONLIST *ppList, LPASACTION pAction)
133 {
134    return AfsAdmSvr_AddToActionList (ppList, pAction);
135 }
136
137 BOOL ADMINAPI asc_ActionListRemoveEntry (LPASACTIONLIST *ppList, DWORD idAction)
138 {
139    return AfsAdmSvr_RemoveFromActionList (ppList, idAction);
140 }
141
142 BOOL ADMINAPI asc_ActionListTest (LPASACTIONLIST *ppList, DWORD idAction, LPASACTION pAction)
143 {
144    return AfsAdmSvr_IsInActionList (ppList, idAction, pAction);
145 }
146
147 BOOL ADMINAPI asc_ActionListFree (LPASACTIONLIST *ppList)
148 {
149    AfsAdmSvr_FreeActionList (ppList);
150    return TRUE;
151 }
152
153
154 /*
155  * ROUTINES ___________________________________________________________________
156  *
157  */
158
159 BOOL ADMINAPI asc_AdminServerOpen (LPCTSTR pszAddress, DWORD *pidClient, ULONG *pStatus)
160 {
161    BOOL rc = TRUE;
162    ULONG status = 0;
163
164    if (!l.fInitializedSockets)
165       {
166       WSADATA Data;
167       WSAStartup (0x0101, &Data);
168       l.fInitializedSockets = TRUE;
169       }
170
171    if ((++l.cReqForAdminServer) == 1)
172       {
173       LPCTSTR pszResolvedAddress = ResolveAddress (pszAddress);
174       if (!BindToAdminServer (pszResolvedAddress, FALSE, pidClient, &status))
175          {
176          if (status != RPC_S_CALL_FAILED_DNE) // server rejected us?
177             rc = FALSE;
178          else if (pszResolvedAddress || !ForkNewAdminServer (&status))
179             rc = FALSE;
180          else
181             rc = BindToAdminServer (pszResolvedAddress, TRUE, pidClient, &status);
182          }
183       }
184
185    if (rc)
186       StartPingThread (*pidClient);
187    if (rc)
188       StartCallbackThread();
189    if (!rc && pStatus)
190       *pStatus = status;
191    return rc;
192 }
193
194
195 BOOL ADMINAPI asc_AdminServerClose (DWORD idClient, ULONG *pStatus)
196 {
197    BOOL rc = TRUE;
198    ULONG status = 0;
199
200    StopCallbackThread();
201    StopPingThread (idClient);
202
203    if (l.cReqForAdminServer && ((--l.cReqForAdminServer) == 0))
204       {
205       UnbindFromAdminServer (idClient, &status);
206       }
207
208    if (!rc && pStatus)
209       *pStatus = status;
210    return rc;
211 }
212
213
214
215 BOOL ADMINAPI asc_CredentialsCrack (DWORD idClient, PVOID hCreds, LPTSTR pszCell, LPTSTR pszUser, SYSTEMTIME *pstExpiration, ULONG *pStatus)
216 {
217    BOOL rc = FALSE;
218    ULONG status = 0;
219
220    RpcTryExcept
221       {
222       STRING szCell = TEXT("");
223       STRING szUser = TEXT("");
224
225       if ((rc = AfsAdmSvr_CrackCredentials (idClient, (DWORD)hCreds, szCell, szUser, pstExpiration, &status)) != FALSE)
226          {
227          lstrcpy (pszCell, szCell);
228          lstrcpy (pszUser, szUser);
229          }
230       }
231    RpcExcept(1)
232       {
233       rc = FALSE;
234       status = RPC_S_CALL_FAILED_DNE;
235       }
236    RpcEndExcept
237
238    if (!rc && pStatus)
239       *pStatus = status;
240    return rc;
241 }
242
243
244 PVOID ADMINAPI asc_CredentialsGet (DWORD idClient, LPCTSTR pszCell, ULONG *pStatus)
245 {
246    PVOID rc = NULL;
247    ULONG status = 0;
248
249    RpcTryExcept
250       {
251       if (pszCell)
252          {
253          STRING szCell;
254          lstrcpy (szCell, pszCell);
255
256          rc = (PVOID)AfsAdmSvr_GetCredentials (idClient, szCell, &status);
257          }
258       }
259    RpcExcept(1)
260       {
261       rc = FALSE;
262       status = RPC_S_CALL_FAILED_DNE;
263       }
264    RpcEndExcept
265
266    if (!rc && pStatus)
267       *pStatus = status;
268    return rc;
269 }
270
271
272 PVOID ADMINAPI asc_CredentialsSet (DWORD idClient, LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword, ULONG *pStatus)
273 {
274    PVOID rc = NULL;
275    ULONG status = 0;
276
277    RpcTryExcept
278       {
279       STRING szCell;
280       lstrcpy (szCell, pszCell);
281
282       STRING szUser;
283       lstrcpy (szUser, pszUser);
284
285       STRING szPassword;
286       lstrcpy (szPassword, pszPassword);
287
288       // TODO: Ensure we do some encryption here, or using an
289       // encrypted socket, or something... can't just be pushing
290       // the user's unencrypted password across the wire.
291
292       rc = (PVOID)AfsAdmSvr_SetCredentials (idClient, szCell, szUser, szPassword, &status);
293       }
294    RpcExcept(1)
295       {
296       rc = FALSE;
297       status = RPC_S_CALL_FAILED_DNE;
298       }
299    RpcEndExcept
300
301    if (!rc && pStatus)
302       *pStatus = status;
303    return rc;
304 }
305
306
307 BOOL ADMINAPI asc_CredentialsPush (DWORD idClient, PVOID hCreds, ASID idCell, ULONG *pStatus)
308 {
309    BOOL rc = TRUE;
310    ULONG status = 0;
311
312    RpcTryExcept
313       {
314       rc = AfsAdmSvr_PushCredentials (idClient, (DWORD)hCreds, idCell, &status);
315       }
316    RpcExcept(1)
317       {
318       rc = FALSE;
319       status = RPC_S_CALL_FAILED_DNE;
320       }
321    RpcEndExcept
322
323    if (!rc && pStatus)
324       *pStatus = status;
325    return rc;
326 }
327
328
329 BOOL ADMINAPI asc_LocalCellGet (DWORD idClient, LPTSTR pszCell, ULONG *pStatus)
330 {
331    BOOL rc = TRUE;
332    ULONG status = 0;
333
334    RpcTryExcept
335       {
336       STRING szCell;
337       if ((rc = AfsAdmSvr_GetLocalCell (idClient, szCell, &status)) != FALSE)
338          {
339          lstrcpy (pszCell, szCell);
340          }
341       }
342    RpcExcept(1)
343       {
344       rc = FALSE;
345       status = RPC_S_CALL_FAILED_DNE;
346       }
347    RpcEndExcept
348
349    if (!rc && pStatus)
350       *pStatus = status;
351    return rc;
352 }
353
354
355 BOOL ADMINAPI asc_ErrorCodeTranslate (DWORD idClient, ULONG code, LANGID idLanguage, STRING pszErrorText, ULONG *pStatus)
356 {
357    BOOL rc = TRUE;
358    ULONG status = 0;
359
360    RpcTryExcept
361       {
362       STRING szText;
363       if ((rc = AfsAdmSvr_ErrorCodeTranslate (idClient, code, idLanguage, szText, &status)) != FALSE)
364          {
365          lstrcpy (pszErrorText, szText);
366          }
367       }
368    RpcExcept(1)
369       {
370       rc = FALSE;
371       status = RPC_S_CALL_FAILED_DNE;
372       }
373    RpcEndExcept
374
375    if (!rc && pStatus)
376       *pStatus = status;
377    return rc;
378 }
379
380
381 BOOL ADMINAPI asc_CellOpen (DWORD idClient, PVOID hCreds, LPCTSTR pszCell, DWORD dwScope, ASID *pidCell, ULONG *pStatus)
382 {
383    BOOL rc = TRUE;
384    ULONG status = 0;
385
386    RpcTryExcept
387       {
388       STRING szCell;
389       lstrcpy (szCell, pszCell);
390
391       if ((rc = AfsAdmSvr_OpenCell (idClient, (DWORD)hCreds, szCell, dwScope, pidCell, &status)) != FALSE)
392          {
393          if (!CreateCellCache (*pidCell))
394             {
395             (void)AfsAdmSvr_CloseCell (idClient, *pidCell, &status);
396             rc = FALSE;
397             status = ERROR_NOT_ENOUGH_MEMORY;
398             }
399          else // get rudimentary properties about the cell
400             {
401             rc = RefreshCachedProperties (idClient, *pidCell, *pidCell, GET_RUDIMENTARY_DATA, &status);
402             }
403          }
404       }
405    RpcExcept(1)
406       {
407       rc = FALSE;
408       status = RPC_S_CALL_FAILED_DNE;
409       }
410    RpcEndExcept
411
412    if (!rc && pStatus)
413       *pStatus = status;
414    return rc;
415 }
416
417
418 BOOL ADMINAPI asc_CellClose (DWORD idClient, ASID idCell, ULONG *pStatus)
419 {
420    BOOL rc = TRUE;
421    ULONG status = 0;
422
423    RpcTryExcept
424       {
425       rc = AfsAdmSvr_CloseCell (idClient, idCell, &status);
426       DestroyCellCache (idCell);
427       }
428    RpcExcept(1)
429       {
430       rc = FALSE;
431       status = RPC_S_CALL_FAILED_DNE;
432       }
433    RpcEndExcept
434
435    if (!rc && pStatus)
436       *pStatus = status;
437    return rc;
438 }
439
440
441 BOOL ADMINAPI asc_ObjectFind (DWORD idClient, ASID idSearchScope, ASOBJTYPE ObjectType, LPCTSTR pszName, ASID *pidObject, ULONG *pStatus)
442 {
443    BOOL rc = TRUE;
444    ULONG status = 0;
445
446    RpcTryExcept
447       {
448       STRING szName = TEXT("");
449       if (pszName)
450          lstrcpy (szName, pszName);
451       rc = AfsAdmSvr_FindObject (idClient, idSearchScope, ObjectType, SEARCH_ALL_OBJECTS, szName, pidObject, &status);
452       }
453    RpcExcept(1)
454       {
455       rc = FALSE;
456       status = RPC_S_CALL_FAILED_DNE;
457       }
458    RpcEndExcept
459
460    if (!rc && pStatus)
461       *pStatus = status;
462    return rc;
463 }
464
465
466 BOOL ADMINAPI asc_ObjectFindMultiple (DWORD idClient, ASID idSearchScope, ASOBJTYPE ObjectType, LPCTSTR pszPattern, LPAFSADMSVR_SEARCH_PARAMS pSearchParams, LPASIDLIST *ppList, ULONG *pStatus)
467 {
468    BOOL rc = TRUE;
469    ULONG status = 0;
470
471    RpcTryExcept
472       {
473       *ppList = NULL;
474
475       STRING szPattern = TEXT("");
476       if (pszPattern)
477          lstrcpy (szPattern, pszPattern);
478
479       AFSADMSVR_SEARCH_PARAMS SearchParams;
480       if (pSearchParams)
481          memcpy (&SearchParams, pSearchParams, sizeof(AFSADMSVR_SEARCH_PARAMS));
482       else
483          {
484          memset (&SearchParams, 0x00, sizeof(AFSADMSVR_SEARCH_PARAMS));
485          SearchParams.SearchType = SEARCH_NO_LIMITATIONS;
486          }
487
488       rc = AfsAdmSvr_FindObjects (idClient, idSearchScope, ObjectType, SEARCH_ALL_OBJECTS, szPattern, &SearchParams, ppList, &status);
489       }
490    RpcExcept(1)
491       {
492       rc = FALSE;
493       status = RPC_S_CALL_FAILED_DNE;
494       }
495    RpcEndExcept
496
497    if (!rc && pStatus)
498       *pStatus = status;
499    return rc;
500 }
501
502
503 BOOL ADMINAPI asc_ObjectPropertiesGet (DWORD idClient, AFSADMSVR_GET_LEVEL GetLevel, ASID idCell, ASID idObject, LPASOBJPROP pProperties, ULONG *pStatus)
504 {
505    BOOL rc = TRUE;
506    ULONG status = 0;
507
508    if (!RefreshCachedProperties (idClient, idCell, idObject, GetLevel, &status))
509       {
510       rc = FALSE;
511       }
512    else
513       {
514       LPASOBJPROP pFound;
515       if ((pFound = GetCachedProperties (idCell, idObject)) == NULL)
516          {
517          status = ERROR_NOT_ENOUGH_MEMORY;
518          rc = FALSE;
519          }
520       else
521          {
522          memcpy (pProperties, pFound, sizeof(ASOBJPROP));
523          }
524       }
525
526    if (!rc && pStatus)
527       *pStatus = status;
528    return rc;
529 }
530
531
532 BOOL ADMINAPI asc_ObjectPropertiesGetMultiple (DWORD idClient, AFSADMSVR_GET_LEVEL GetLevel, ASID idCell, LPASIDLIST pAsidList, LPASOBJPROPLIST *ppPropertiesList, ULONG *pStatus)
533 {
534    BOOL rc = TRUE;
535    ULONG status = 0;
536
537    if (!RefreshCachedProperties (idClient, idCell, pAsidList, GetLevel, &status))
538       {
539       rc = FALSE;
540       }
541    else
542       {
543       *ppPropertiesList = NULL;
544       for (size_t iAsidList = 0; iAsidList < pAsidList->cEntries; ++iAsidList)
545          {
546          LPASOBJPROP pFound;
547          if ((pFound = GetCachedProperties (idCell, pAsidList->aEntries[ iAsidList ].idObject)) != NULL)
548             {
549             if (!*ppPropertiesList)
550                asc_ObjPropListCreate(ppPropertiesList);
551             if (*ppPropertiesList)
552                AfsAdmSvr_AddToObjPropList (ppPropertiesList, pFound, pAsidList->aEntries[ iAsidList ].lParam);
553             }
554          }
555       }
556
557    if (!rc && *ppPropertiesList)
558       AfsAdmSvr_FreeObjPropList (ppPropertiesList);
559    if (!rc && pStatus)
560       *pStatus = status;
561    return rc;
562 }
563
564
565 BOOL ADMINAPI asc_ObjectListen (DWORD idClient, ASID idCell, ASID idObject, HWND hNotify, ULONG *pStatus)
566 {
567    if (!idObject)
568       {
569       if (*pStatus)
570          *pStatus = ERROR_INVALID_PARAMETER;
571       return FALSE;
572       }
573
574    if (!AddObjectNotification (hNotify, idCell, idObject))
575       {
576       if (*pStatus)
577          *pStatus = ERROR_NOT_ENOUGH_MEMORY;
578       return FALSE;
579       }
580
581    TestForNotifications (idClient, idCell, idObject);
582    return TRUE;
583 }
584
585
586 BOOL ADMINAPI asc_ObjectListenClear (DWORD idClient, HWND hNotify, ULONG *pStatus)
587 {
588    ClearObjectNotifications (hNotify);
589    return TRUE;
590 }
591
592
593 BOOL ADMINAPI asc_ObjectListenMultiple (DWORD idClient, ASID idCell, LPASIDLIST pAsidList, HWND hNotify, ULONG *pStatus)
594 {
595    if (!pAsidList)
596       {
597       if (*pStatus)
598          *pStatus = ERROR_INVALID_PARAMETER;
599       return FALSE;
600       }
601
602    for (size_t ii = 0; ii < pAsidList->cEntriesAllocated; ++ii)
603       {
604       if (!pAsidList->aEntries[ ii ].idObject)
605          continue;
606
607       if (!AddObjectNotification (hNotify, idCell, pAsidList->aEntries[ ii ].idObject))
608          {
609          if (*pStatus)
610             *pStatus = ERROR_NOT_ENOUGH_MEMORY;
611          return FALSE;
612          }
613
614       TestForNotifications (idClient, idCell, pAsidList->aEntries[ ii ].idObject);
615       }
616
617    return TRUE;
618 }
619
620
621 BOOL ADMINAPI asc_ObjectRefresh (DWORD idClient, ASID idCell, ASID idObject, ULONG *pStatus)
622 {
623    BOOL rc = TRUE;
624    ULONG status = 0;
625
626    // First have the server invalidate its cache of information; regardless
627    // of the name, this is actually just an Invalidate call, not a Refresh call
628    //
629    RpcTryExcept
630       {
631       rc = AfsAdmSvr_RefreshObject (idClient, idObject, &status);
632       }
633    RpcExcept(1)
634       {
635       rc = FALSE;
636       status = RPC_S_CALL_FAILED_DNE;
637       }
638    RpcEndExcept
639
640    // If that suceeded, see if there is anyone listening for changes
641    // in this object or any of its children. If so, this call
642    // will requery the server for the latest properties for all
643    // listened-for objects, which will make us post notifications if
644    // we get new data back.
645    //
646    if (rc)
647       {
648       TestForNotifications (idClient, idCell);
649       }
650
651    if (!rc && pStatus)
652       *pStatus = status;
653    return rc;
654 }
655
656
657 BOOL ADMINAPI asc_ObjectRefreshMultiple (DWORD idClient, ASID idCell, LPASIDLIST pAsidList, ULONG *pStatus)
658 {
659    BOOL rc = TRUE;
660    ULONG status = 0;
661
662    // First have the server invalidate its cache of information; regardless
663    // of the name, this is actually just an Invalidate call, not a Refresh call
664    //
665    RpcTryExcept
666       {
667       rc = AfsAdmSvr_RefreshObjects (idClient, pAsidList, &status);
668       }
669    RpcExcept(1)
670       {
671       rc = FALSE;
672       status = RPC_S_CALL_FAILED_DNE;
673       }
674    RpcEndExcept
675
676    // If that suceeded, see if there is anyone listening for changes
677    // in any of these objects or their children. If so, this call
678    // will requery the server for the latest properties for all
679    // listened-for objects, which will make us post notifications if
680    // we get new data back.
681    //
682    if (rc)
683       {
684       TestForNotifications (idClient, idCell);
685       }
686
687    if (!rc && pStatus)
688       *pStatus = status;
689    return rc;
690 }
691
692
693 BOOL ADMINAPI asc_RandomKeyGet (DWORD idClient, ASID idCell, PBYTE key, ULONG *pStatus)
694 {
695    BOOL rc = TRUE;
696    ULONG status = 0;
697
698    RpcTryExcept
699       {
700       memset (key, 0x00, sizeof(BYTE) * ENCRYPTIONKEYLENGTH);
701       rc = AfsAdmSvr_GetRandomKey (idClient, idCell, key, &status);
702       }
703    RpcExcept(1)
704       {
705       rc = FALSE;
706       status = RPC_S_CALL_FAILED_DNE;
707       }
708    RpcEndExcept
709
710    if (!rc && pStatus)
711       *pStatus = status;
712    return rc;
713 }
714
715
716 BOOL ADMINAPI asc_CellNameGet_Fast (DWORD idClient, ASID idCell, LPTSTR pszCell, ULONG *pStatus)
717 {
718    return asc_ObjectNameGet_Fast (idClient, idCell, idCell, pszCell, pStatus);
719 }
720
721
722 BOOL ADMINAPI asc_ObjectNameGet_Fast (DWORD idClient, ASID idCell, ASID idObject, LPTSTR pszObject, ULONG *pStatus)
723 {
724    BOOL rc = TRUE;
725    ULONG status = 0;
726
727    LPASOBJPROP pProperties;
728    if ((pProperties = GetCachedProperties (idCell, idObject)) == NULL)
729       {
730       rc = FALSE;
731       status = ERROR_NO_DATA;
732       }
733    else if (pProperties->verProperties == verPROP_NO_OBJECT)
734       {
735       rc = FALSE;
736       status = ERROR_NO_DATA;
737       }
738    else
739       {
740       lstrcpy (pszObject, pProperties->szName);
741       }
742
743    if (!rc && pStatus)
744       *pStatus = status;
745    return rc;
746 }
747
748
749 BOOL ADMINAPI asc_ObjectTypeGet_Fast (DWORD idClient, ASID idCell, ASID idObject, ASOBJTYPE *pObjectType, ULONG *pStatus)
750 {
751    BOOL rc = TRUE;
752    ULONG status = 0;
753
754    LPASOBJPROP pProperties;
755    if ((pProperties = GetCachedProperties (idCell, idObject)) == NULL)
756       {
757       rc = FALSE;
758       status = ERROR_NO_DATA;
759       }
760    else if (pProperties->verProperties == verPROP_NO_OBJECT)
761       {
762       rc = FALSE;
763       status = ERROR_NO_DATA;
764       }
765    else
766       {
767       *pObjectType = pProperties->Type;
768       }
769
770    if (!rc && pStatus)
771       *pStatus = status;
772    return rc;
773 }
774
775
776 BOOL ADMINAPI asc_ObjectPropertiesGet_Fast (DWORD idClient, ASID idCell, ASID idObject, LPASOBJPROP pProperties, ULONG *pStatus)
777 {
778    BOOL rc = TRUE;
779    ULONG status = 0;
780
781    LPASOBJPROP pPropFound;
782    if ((pPropFound = GetCachedProperties (idCell, idObject)) == NULL)
783       {
784       rc = FALSE;
785       status = ERROR_NO_DATA;
786       }
787    else if (pPropFound->verProperties == verPROP_NO_OBJECT)
788       {
789       rc = FALSE;
790       status = ERROR_NO_DATA;
791       }
792    else if (pProperties)
793       {
794       memcpy (pProperties, pPropFound, sizeof(ASOBJPROP));
795       }
796
797    if (!rc && pStatus)
798       *pStatus = status;
799    return rc;
800 }
801
802
803 BOOL ADMINAPI asc_ActionGet (DWORD idClient, DWORD idAction, LPASACTION pAction, ULONG *pStatus)
804 {
805    BOOL rc = TRUE;
806    ULONG status = 0;
807
808    RpcTryExcept
809       {
810       memset (pAction, 0x00, sizeof(ASACTION));
811       rc = AfsAdmSvr_GetAction (idClient, idAction, pAction, &status);
812       }
813    RpcExcept(1)
814       {
815       rc = FALSE;
816       status = RPC_S_CALL_FAILED_DNE;
817       }
818    RpcEndExcept
819
820    if (!rc && pStatus)
821       *pStatus = status;
822    return rc;
823 }
824
825
826 BOOL ADMINAPI asc_ActionGetMultiple (DWORD idClient, DWORD idClientSearch, ASID idCellSearch, LPASACTIONLIST *ppList, ULONG *pStatus)
827 {
828    BOOL rc = TRUE;
829    ULONG status = 0;
830
831    RpcTryExcept
832       {
833       *ppList = NULL;
834       rc = AfsAdmSvr_GetActions (idClient, idClientSearch, idCellSearch, ppList, &status);
835       }
836    RpcExcept(1)
837       {
838       rc = FALSE;
839       status = RPC_S_CALL_FAILED_DNE;
840       }
841    RpcEndExcept
842
843    if (!rc && pStatus)
844       *pStatus = status;
845    return rc;
846 }
847
848
849 BOOL ADMINAPI asc_ActionListen (DWORD idClient, HWND hNotify, ULONG *pStatus)
850 {
851    if (!SetActionNotification (hNotify, TRUE))
852       {
853       if (*pStatus)
854          *pStatus = ERROR_NOT_ENOUGH_MEMORY;
855       return FALSE;
856       }
857    return TRUE;
858 }
859
860
861 BOOL ADMINAPI asc_ActionListenClear (DWORD idClient, HWND hNotify, ULONG *pStatus)
862 {
863    if (!SetActionNotification (hNotify, FALSE))
864       {
865       if (*pStatus)
866          *pStatus = ERROR_NOT_ENOUGH_MEMORY;
867       return FALSE;
868       }
869    return TRUE;
870 }
871
872
873       // AfsAdmSvrCallback_Action
874       // ...called by the server in the context of the CallbackHost() routine;
875       //    this routine is used to notify the client whenever an action is
876       //    initiated or completed.
877       //
878 void AfsAdmSvrCallback_Action (LPASACTION pAction, BOOL fFinished)
879 {
880    NotifyActionListeners (pAction, fFinished);
881 }
882