Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afsadmsvr / TaAfsAdmSvr.cpp
blobdc2729d8ab99dc88c68c9c02fa50dd29fa8256d1
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
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
8 */
10 #include <winsock2.h>
11 #include <ws2tcpip.h>
13 #include <afs/param.h>
14 #include <afs/stds.h>
16 #include "TaAfsAdmSvrInternal.h"
20 * ROUTINES ___________________________________________________________________
24 // AfsAdmSvr_Connect
25 // ...obtains a cookie to represent the calling process. The cookie should
26 // be freed with AfsAdmSvr_Disconnect when the process disconnects.
28 extern "C" int AfsAdmSvr_Connect (STRING szClientAddress, UINT_PTR *pidClient, ULONG *pStatus)
30 // Make sure AfsClass initialized properly. If it's already init'd,
31 // this won't hurt at all.
33 ULONG status;
34 if (!AfsClass_Initialize (&status))
36 Print (TEXT("Denying client %s due to AfsClass initialization failure"), szClientAddress);
37 return FALSE_(status, pStatus);
40 // Find a free CLIENTINFO structure for this caller
42 if (!AfsAdmSvr_AttachClient (szClientAddress, (PVOID *)pidClient, pStatus))
43 return FALSE;
45 Print (TEXT("Connected to client %s (ID 0x%08lX)"), AfsAdmSvr_GetClientName (*pidClient), *pidClient);
47 return TRUE;
51 // AfsAdmSvr_Ping
52 // ...reminds the admin server that the specified client is still around.
53 // this call should be made at least every csecAFSADMSVR_CLIENT_PING
54 // seconds, lest the admin server think you've disconnected. (The
55 // client library TaAfsAdmSvrClient.lib automatically handles this.)
57 extern "C" int AfsAdmSvr_Ping (UINT_PTR idClient, ULONG *pStatus)
59 AfsAdmSvr_Enter();
61 if (!AfsAdmSvr_fIsValidClient (idClient))
62 return Leave_FALSE_(ERROR_INVALID_PARAMETER, pStatus);
64 AfsAdmSvr_PingClient (idClient);
65 AfsAdmSvr_Leave();
66 return TRUE;
70 // AfsAdmSvr_Disconnect
71 // ...releases and invalidates the cookie representing the calling process.
73 extern "C" int AfsAdmSvr_Disconnect (UINT_PTR idClient, ULONG *pStatus)
75 AfsAdmSvr_Enter();
77 // Make sure this is a valid client, and free its l.aClients[] entry if so.
79 if (!AfsAdmSvr_fIsValidClient (idClient))
80 return Leave_FALSE_(ERROR_INVALID_PARAMETER, pStatus);
82 Print (TEXT("Disconnected from client %s (ID 0x%08lX)"), AfsAdmSvr_GetClientName (idClient), idClient);
84 AfsAdmSvr_DetachClient (idClient);
85 AfsAdmSvr_Leave();
86 return TRUE;
90 // AfsAdmSvr_CrackCredentials
91 // ...queries the specified AFS credentials token for its cell, user
92 // and expiration date.
94 extern "C" int AfsAdmSvr_CrackCredentials (UINT_PTR idClient, UINT_PTR hCreds, STRING pszCell, STRING pszUser, SYSTEMTIME *pstExpiration, ULONG *pStatus)
96 ULONG status;
97 size_t iOp = AfsAdmSvr_BeginOperation (idClient);
99 if (!AfsAdmSvr_fIsValidClient (idClient))
100 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
102 Print (dlDETAIL, TEXT("Client 0x%08lX: CrackCredentials (0x%08lX)"), idClient, hCreds);
104 unsigned long dateExpirationQuery;
105 int fHasKasTokenQuery;
106 char szUser[ cchSTRING ];
107 char szUser2[ cchSTRING ];
108 char szCell[ cchSTRING ];
109 char *pszCellQuery = (pszCell) ? (char *)pszCell : szCell;
110 char *pszUserQuery = (pszUser) ? (char *)pszUser : szUser;
111 if (!afsclient_TokenQuery ((PVOID)hCreds, &dateExpirationQuery, pszUserQuery, szUser2, pszCellQuery, &fHasKasTokenQuery, (afs_status_p)&status))
112 return FALSE_(status, pStatus, iOp);
114 if (pstExpiration)
115 AfsAppLib_UnixTimeToSystemTime (pstExpiration, dateExpirationQuery);
117 AfsAdmSvr_EndOperation (iOp);
118 return TRUE;
122 // AfsAdmSvr_GetCredentials
123 // ...queries the user's current AFS credentials for the specified cell
124 // if the user already has credentials in the cell, returns a nonzero
125 // token {hCreds}, suitable for use in AfsAdmSvr_OpenCell().
127 extern "C" UINT_PTR AfsAdmSvr_GetCredentials (UINT_PTR idClient, STRING pszCell, ULONG *pStatus)
129 ULONG status;
130 size_t iOp = AfsAdmSvr_BeginOperation (idClient);
132 if (!AfsAdmSvr_fIsValidClient (idClient))
133 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
135 Print (dlDETAIL, TEXT("Client 0x%08lX: GetCredentials (%s)"), idClient, pszCell);
137 const char *pszCellTest = (pszCell && *pszCell) ? (const char *)pszCell : NULL;
139 UINT_PTR hCreds = NULL;
140 if (!afsclient_TokenGetExisting (pszCellTest, (PVOID *)&hCreds, (afs_status_p)&status))
141 return FALSE_(status, pStatus, iOp);
143 AfsAdmSvr_EndOperation (iOp);
144 return hCreds;
148 // AfsAdmSvr_SetCredentials
149 // ...obtains new AFS credentials within the administrative server process
150 // on behalf of the specified user. if successful, returns a nonzero
151 // token {hCreds}, suitable for use in AfsAdmSvr_OpenCell().
153 extern "C" UINT_PTR AfsAdmSvr_SetCredentials (UINT_PTR idClient, STRING pszCell, STRING pszUser, STRING pszPassword, ULONG *pStatus)
155 ULONG status;
156 size_t iOp = AfsAdmSvr_BeginOperation (idClient);
158 Print (dlDETAIL, TEXT("Client 0x%08lX: SetCredentials (%s,%s)"), idClient, pszCell, pszUser);
160 if (!AfsAdmSvr_fIsValidClient (idClient))
161 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
163 const char *pszCellSet = (pszCell && *pszCell) ? (const char *)pszCell : NULL;
165 UINT_PTR hCreds;
166 if (!afsclient_TokenGetNew (pszCellSet, (const char *)pszUser, (const char *)pszPassword, (PVOID *)&hCreds, (afs_status_p)&status))
167 return FALSE_(status,pStatus,iOp);
169 AfsAdmSvr_EndOperation (iOp);
170 return hCreds;
174 // AfsAdmSvr_PushCredentials
175 // ...requests that the specified AFS credentials be used hereafter
176 // when manipulating the specified cell. You should follow this
177 // call with a Refresh request if necessary.
179 extern "C" int AfsAdmSvr_PushCredentials (UINT_PTR idClient, UINT_PTR hCreds, ASID idCell, ULONG *pStatus)
181 ULONG status;
182 size_t iOp = AfsAdmSvr_BeginOperation (idClient);
184 Print (dlDETAIL, TEXT("Client 0x%08lX: PushCredentials (hCreds=0x%08lX, idCell=0x%08lX)"), idClient, hCreds, idCell);
186 if (!AfsAdmSvr_fIsValidClient (idClient))
187 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
189 if (GetAsidType (idCell) != itCELL)
190 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
192 LPCELL lpCell;
193 if ((lpCell = ((LPIDENT)idCell)->OpenCell (&status)) == NULL)
194 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
196 lpCell->SetCurrentCredentials ((PVOID)hCreds);
197 lpCell->Close();
199 AfsAdmSvr_EndOperation (iOp);
200 return TRUE;
204 // AfsAdmSvr_GetLocalCell
205 // ...obtains the name of the primary cell used by the admin server
207 extern "C" int AfsAdmSvr_GetLocalCell (UINT_PTR idClient, STRING pszCellName, ULONG *pStatus)
209 size_t iOp = AfsAdmSvr_BeginOperation (idClient);
211 Print (dlDETAIL, TEXT("Client 0x%08lX: GetLocalCell"), idClient);
213 if (!AfsAdmSvr_fIsValidClient (idClient))
214 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
216 if (!CELL::GetDefaultCell (pszCellName, pStatus))
218 AfsAdmSvr_EndOperation (iOp);
219 return FALSE;
222 AfsAdmSvr_EndOperation (iOp);
223 return TRUE;
227 // AfsAdmSvr_ErrorCodeTranslate
228 // ...translates an error code into an English string
230 extern "C" int AfsAdmSvr_ErrorCodeTranslate (UINT_PTR idClient, ULONG code, LANGID idLanguage, STRING pszErrorText, ULONG *pStatus)
232 if (!AfsAppLib_TranslateError (pszErrorText, code, idLanguage))
233 return FALSE_(ERROR_INVALID_PARAMETER,pStatus);
235 LPTSTR pch;
236 if ((pch = (LPTSTR)lstrrchr (pszErrorText, TEXT('('))) != NULL)
237 *pch = TEXT('\0');
238 while (lstrlen(pszErrorText) && pszErrorText[ lstrlen(pszErrorText)-1 ] == TEXT(' '))
239 pszErrorText[ lstrlen(pszErrorText)-1 ] = TEXT('\0');
240 return TRUE;
244 // AfsAdmSvr_GetAction
245 // ...returns information about a particular operation in progress.
247 extern "C" int AfsAdmSvr_GetAction (UINT_PTR idClient, DWORD idAction, LPASACTION pAction, ULONG *pStatus)
249 Print (dlDETAIL, TEXT("Client 0x%08lX: GetAction (idAction=0x%08lX)"), idClient, idAction);
251 if (!AfsAdmSvr_fIsValidClient (idClient))
252 return FALSE_(ERROR_INVALID_PARAMETER,pStatus);
254 if (!AfsAdmSvr_GetOperation (idAction, pAction))
255 return FALSE_(ERROR_INVALID_PARAMETER,pStatus);
257 Print (dlERROR, TEXT("Client 0x%08lX: GetAction succeeded"));
258 return TRUE;
262 // AfsAdmSvr_GetActions
263 // ...returns a list of operations in progress. The list returned can
264 // be constrained to only including those operations initiated by
265 // a particular client and/or performed in a particular cell.
267 extern "C" int AfsAdmSvr_GetActions (UINT_PTR idClient, UINT_PTR idClientSearch, ASID idCellSearch, LPASACTIONLIST *ppList, ULONG *pStatus)
269 Print (dlDETAIL, TEXT("Client 0x%08lX: GetActions (idClientSearch=0x%08lX, idCellSearch=0x%08lX)"), idClient, idClientSearch, idCellSearch);
271 if (!AfsAdmSvr_fIsValidClient (idClient))
272 return FALSE_(ERROR_INVALID_PARAMETER,pStatus);
274 if ((*ppList = AfsAdmSvr_GetOperations (idClientSearch, idCellSearch)) == NULL)
276 Print (dlERROR, TEXT("Client 0x%08lX: GetActions failed"), idClient);
277 return FALSE_(ERROR_NOT_ENOUGH_MEMORY,pStatus);
280 Print (dlERROR, TEXT("Client 0x%08lX: GetActions succeeded; %ld actions"), idClient, (*ppList) ? (*ppList)->cEntries : 0);
281 return TRUE;
285 // AfsAdmSvr_OpenCell
286 // ...opens a cell for administration.
288 extern "C" int AfsAdmSvr_OpenCell (UINT_PTR idClient, UINT_PTR hCreds, STRING pszCellName, DWORD dwScopeFlags, ASID *pidCell, ULONG *pStatus)
290 size_t iOp = AfsAdmSvr_BeginOperation (idClient);
292 if (!AfsAdmSvr_fIsValidClient (idClient))
293 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
295 Print (dlDETAIL, TEXT("Client 0x%08lX: OpenCell"), idClient);
297 AfsAdmSvr_AddToMinScope (dwScopeFlags);
299 LPIDENT lpiCell;
300 if ((lpiCell = CELL::OpenCell ((LPTSTR)pszCellName, (PVOID)hCreds, pStatus)) == NULL)
302 AfsAdmSvr_EndOperation (iOp);
303 return FALSE;
306 Print (dlDETAIL, TEXT("Client 0x%08lX: OpenCell succeeded (idCell=0x%08lX)"), idClient, lpiCell);
308 *pidCell = (ASID)lpiCell;
309 AfsAdmSvr_EndOperation (iOp);
310 return TRUE;
314 // AfsAdmSvr_CloseCell
315 // ...used by client to open a cell for administration.
317 extern "C" int AfsAdmSvr_CloseCell (UINT_PTR idClient, ASID idCell, ULONG *pStatus)
319 size_t iOp = AfsAdmSvr_BeginOperation (idClient);
321 Print (dlDETAIL, TEXT("Client 0x%08lX: CloseCell (idCell=0x%08lX)"), idClient, idCell);
323 if (!AfsAdmSvr_fIsValidClient (idClient))
324 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
326 if (GetAsidType (idCell) != itCELL)
327 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
329 CELL::CloseCell ((LPIDENT)idCell);
331 AfsAdmSvr_EndOperation (iOp);
332 return TRUE;
336 // AfsAdmSvr_FindObject
337 // AfsAdmSvr_FindObjects
338 // ...used to search through all objects in the cell, obtaining a list
339 // of those which match the specified criteria. For FindObjects, the
340 // {*ppList} parameter will be filled in with an allocated list of
341 // ASIDs, and should be freed using the AfsAdmSvr_FreeAsidList()
342 // routine (clients using the TaAfsAdmSvrClient.lib library should
343 // call asc_AsidListFree(), which is a wrapper for that routine).
344 // The _FindObject routine can be used to find exactly one object--
345 // for instance, finding the ASID for a particular user or volume--
346 // while the _FindObjects routine returns a list of all objects
347 // which match the specified criteria--all volumes on a partition,
348 // or all users named "b*" within a cell.
350 extern "C" int AfsAdmSvr_FindObject (UINT_PTR idClient, ASID idSearchScope, ASOBJTYPE ObjectType, AFSADMSVR_SEARCH_REFRESH SearchRefresh, STRING szName, ASID *pidObject, ULONG *pStatus)
352 BOOL rc = TRUE;
353 ULONG status = 0;
355 size_t iOp = AfsAdmSvr_BeginOperation (idClient);
357 Print (dlDETAIL, TEXT("Client 0x%08lX: FindObject (scope=0x%08lX, type=%lu, name='%s')"), idClient, idSearchScope, ObjectType, szName);
359 if (!AfsAdmSvr_fIsValidClient (idClient))
360 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
362 if (GetAsidType (idSearchScope) == itUNUSED)
363 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
365 // We've got a special case here: if possible, we don't want to have to
366 // refresh the contents of the entire cell. So if the client is looking
367 // for a user or group, we can just try to grab that object by its name;
368 // afsclass supports an interface for just this case.
370 switch (ObjectType)
372 case TYPE_USER:
373 rc = AfsAdmSvr_Search_OneUser (pidObject, idSearchScope, szName, &status);
374 break;
376 case TYPE_GROUP:
377 rc = AfsAdmSvr_Search_OneGroup (pidObject, idSearchScope, szName, &status);
378 break;
380 default:
381 // We'll have to do the search the hard way. First
382 // see if we need to refresh this cell/server.
384 if (!AfsAdmSvr_SearchRefresh (idSearchScope, ObjectType, SearchRefresh, &status))
385 return FALSE_(status,pStatus,iOp);
387 // Look for the specified object.
389 switch (GetAsidType (idSearchScope))
391 case itCELL:
392 if (ObjectType == TYPE_SERVER)
393 rc = AfsAdmSvr_Search_ServerInCell (pidObject, idSearchScope, szName, &status);
394 else if (ObjectType == TYPE_SERVICE)
395 rc = AfsAdmSvr_Search_ServiceInCell (pidObject, idSearchScope, szName, &status);
396 else if (ObjectType == TYPE_PARTITION)
397 rc = AfsAdmSvr_Search_PartitionInCell (pidObject, idSearchScope, szName, &status);
398 else if (ObjectType == TYPE_VOLUME)
399 rc = AfsAdmSvr_Search_VolumeInCell (pidObject, idSearchScope, szName, &status);
400 else if (ObjectType == TYPE_USER)
401 rc = AfsAdmSvr_Search_UserInCell (pidObject, idSearchScope, szName, &status);
402 else if (ObjectType == TYPE_GROUP)
403 rc = AfsAdmSvr_Search_GroupInCell (pidObject, idSearchScope, szName, &status);
404 else
406 rc = FALSE;
407 status = ERROR_INVALID_PARAMETER;
409 break;
411 case itSERVER:
412 if (ObjectType == TYPE_SERVICE)
413 rc = AfsAdmSvr_Search_ServiceInServer (pidObject, idSearchScope, szName, &status);
414 else if (ObjectType == TYPE_PARTITION)
415 rc = AfsAdmSvr_Search_PartitionInServer (pidObject, idSearchScope, szName, &status);
416 else if (ObjectType == TYPE_VOLUME)
417 rc = AfsAdmSvr_Search_VolumeInServer (pidObject, idSearchScope, szName, &status);
418 else
420 rc = FALSE;
421 status = ERROR_INVALID_PARAMETER;
423 break;
425 case itAGGREGATE:
426 if (ObjectType == TYPE_VOLUME)
427 rc = AfsAdmSvr_Search_VolumeInPartition (pidObject, idSearchScope, szName, &status);
428 else
430 rc = FALSE;
431 status = ERROR_INVALID_PARAMETER;
433 break;
435 break;
438 if (!rc && pStatus)
439 *pStatus = status;
441 if (!rc)
442 Print (dlERROR, TEXT("Client 0x%08lX: FindObject failed (status=0x%08lX)"), idClient, status);
443 else // (rc)
444 Print (dlDETAIL, TEXT("Client 0x%08lX: FindObject succeeded; returning idObject=0x%08lX"), idClient, *pidObject);
446 AfsAdmSvr_EndOperation (iOp);
447 return rc;
451 extern "C" int AfsAdmSvr_FindObjects (UINT_PTR idClient, ASID idSearchScope, ASOBJTYPE ObjectType, AFSADMSVR_SEARCH_REFRESH SearchRefresh, STRING szPattern, LPAFSADMSVR_SEARCH_PARAMS pSearchParams, LPASIDLIST *ppList, ULONG *pStatus)
453 BOOL rc = TRUE;
454 ULONG status = 0;
456 size_t iOp = AfsAdmSvr_BeginOperation (idClient);
458 Print (dlDETAIL, TEXT("Client 0x%08lX: FindObjects (scope=0x%08lX, type=%lu, pat='%s')"), idClient, idSearchScope, ObjectType, szPattern);
460 if (!AfsAdmSvr_fIsValidClient (idClient))
461 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
463 if (GetAsidType (idSearchScope) == itUNUSED)
464 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
466 // First see if we need to refresh this cell/server
468 if (!AfsAdmSvr_SearchRefresh (idSearchScope, ObjectType, SearchRefresh, &status))
469 return FALSE_(status,pStatus,iOp);
471 // Prepare an ASIDLIST, and call whatever subroutine is necessary to
472 // perform the actual search.
474 if ((*ppList = AfsAdmSvr_CreateAsidList()) == NULL)
475 return FALSE_(ERROR_NOT_ENOUGH_MEMORY,pStatus,iOp);
477 LPTSTR pszPattern = (szPattern && szPattern[0]) ? (LPTSTR)szPattern : NULL;
479 switch (GetAsidType (idSearchScope))
481 case itCELL:
482 if (ObjectType == TYPE_ANY)
483 rc = AfsAdmSvr_Search_AllInCell (ppList, idSearchScope, pszPattern, &status);
484 else if (ObjectType == TYPE_SERVER)
485 rc = AfsAdmSvr_Search_ServersInCell (ppList, idSearchScope, pszPattern, &status);
486 else if (ObjectType == TYPE_SERVICE)
487 rc = AfsAdmSvr_Search_ServicesInCell (ppList, idSearchScope, pszPattern, &status);
488 else if (ObjectType == TYPE_PARTITION)
489 rc = AfsAdmSvr_Search_PartitionsInCell (ppList, idSearchScope, pszPattern, &status);
490 else if (ObjectType == TYPE_VOLUME)
491 rc = AfsAdmSvr_Search_VolumesInCell (ppList, idSearchScope, pszPattern, &status);
492 else if (ObjectType == TYPE_USER)
493 rc = AfsAdmSvr_Search_UsersInCell (ppList, idSearchScope, pszPattern, &status);
494 else if (ObjectType == TYPE_GROUP)
495 rc = AfsAdmSvr_Search_GroupsInCell (ppList, idSearchScope, pszPattern, &status);
496 else
498 rc = FALSE;
499 status = ERROR_INVALID_PARAMETER;
501 break;
503 case itSERVER:
504 if (ObjectType == TYPE_ANY)
505 rc = AfsAdmSvr_Search_AllInServer (ppList, idSearchScope, pszPattern, &status);
506 else if (ObjectType == TYPE_SERVICE)
507 rc = AfsAdmSvr_Search_ServicesInServer (ppList, idSearchScope, pszPattern, &status);
508 else if (ObjectType == TYPE_PARTITION)
509 rc = AfsAdmSvr_Search_PartitionsInServer (ppList, idSearchScope, pszPattern, &status);
510 else if (ObjectType == TYPE_VOLUME)
511 rc = AfsAdmSvr_Search_VolumesInServer (ppList, idSearchScope, pszPattern, &status);
512 else
514 rc = FALSE;
515 status = ERROR_INVALID_PARAMETER;
517 break;
519 case itAGGREGATE:
520 if (ObjectType == TYPE_ANY)
521 rc = AfsAdmSvr_Search_VolumesInPartition (ppList, idSearchScope, pszPattern, &status);
522 else if (ObjectType == TYPE_VOLUME)
523 rc = AfsAdmSvr_Search_VolumesInPartition (ppList, idSearchScope, pszPattern, &status);
524 else
526 rc = FALSE;
527 status = ERROR_INVALID_PARAMETER;
529 break;
532 if (rc && (*ppList) && (pSearchParams))
533 AfsAdmSvr_Search_Advanced (ppList, pSearchParams);
535 if (!rc && (*ppList))
536 AfsAdmSvr_FreeAsidList (ppList);
537 if (!rc && pStatus)
538 *pStatus = status;
540 if (!rc)
541 Print (dlERROR, TEXT("Client 0x%08lX: FindObjects failed (status=0x%08lX)"), idClient, status);
542 else // (rc)
543 Print (dlDETAIL, TEXT("Client 0x%08lX: FindObjects succeeded; returning %lu item(s)"), idClient, (*ppList)->cEntries);
545 AfsAdmSvr_EndOperation (iOp);
546 return rc;
550 // AfsAdmSvr_GetObject
551 // AfsAdmSvr_GetObjects
552 // ...returns server-cached information about the specified object (or
553 // objects).
555 extern "C" int AfsAdmSvr_GetObject (UINT_PTR idClient, AFSADMSVR_GET_TYPE GetType, AFSADMSVR_GET_LEVEL GetLevel, ASID idObject, UINT_PTR verProperties, LPASOBJPROP pProperties, ULONG *pStatus)
557 size_t iOp = AfsAdmSvr_BeginOperation (idClient);
559 Print (dlDETAIL2, TEXT("Client 0x%08lX: GetObject (Type=%lu, Level=%lu, idObject=0x%08lX, ver=%ld)"), idClient, (LONG)GetType, (LONG)GetLevel, idObject, verProperties);
561 memset (pProperties, 0x00, sizeof(ASOBJPROP));
563 if (!AfsAdmSvr_fIsValidClient (idClient))
564 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
566 LPASOBJPROP pCurrentProperties;
567 if ((pCurrentProperties = AfsAdmSvr_GetCurrentProperties (idObject, pStatus)) == NULL)
569 Print (dlERROR, TEXT("Client 0x%08lX: GetObject failed; no properties"), idClient, idObject);
570 AfsAdmSvr_EndOperation (iOp);
571 return FALSE;
574 // At this point pCurrentProperties may just be rudimentary properties.
575 // If the user has requested GET_ALL_DATA, we'll have to get full properties.
577 if ( (GetLevel == GET_ALL_DATA) && (pCurrentProperties->verProperties < verPROP_FIRST_SCAN) )
579 if (!AfsAdmSvr_ObtainFullProperties (pCurrentProperties, pStatus))
581 Print (dlERROR, TEXT("Client 0x%08lX: GetObject failed; no full properties"), idClient, idObject);
582 AfsAdmSvr_EndOperation (iOp);
583 return FALSE;
587 // Now determine if we need to return anything at all; if the user specified
588 // RETURN_IF_OUT_OF_DATE, it's possible that there's no need to do so.
590 if ((pCurrentProperties->verProperties > verProperties) || (GetType == RETURN_DATA_ALWAYS))
592 memcpy (pProperties, pCurrentProperties, sizeof(ASOBJPROP));
595 Print (dlDETAIL2, TEXT("Client 0x%08lX: GetObject succeeded (idObject=0x%08lX)"), idClient, idObject);
596 AfsAdmSvr_EndOperation (iOp);
597 return TRUE;
601 extern "C" int AfsAdmSvr_GetObjects (UINT_PTR idClient, AFSADMSVR_GET_TYPE GetType, AFSADMSVR_GET_LEVEL GetLevel, LPASIDLIST pListObjects, LPASOBJPROPLIST *ppListObjectProperties, ULONG *pStatus)
603 size_t iOp = AfsAdmSvr_BeginOperation (idClient);
605 Print (dlDETAIL, TEXT("Client 0x%08lX: GetObjects (Type=%lu, Level=%lu, nObjects=%lu)"), idClient, (LONG)GetType, (LONG)GetLevel, (pListObjects) ? (pListObjects->cEntries) : 0);
607 if (!AfsAdmSvr_fIsValidClient (idClient))
608 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
610 *ppListObjectProperties = NULL;
611 for (size_t iObject = 0; iObject < pListObjects->cEntries; ++iObject)
613 ASOBJPROP ObjectProperties;
615 ULONG status;
616 if (AfsAdmSvr_GetObject (idClient, GetType, GetLevel, pListObjects->aEntries[ iObject ].idObject, pListObjects->aEntries[ iObject ].lParam, &ObjectProperties, &status))
618 if (ObjectProperties.idObject == pListObjects->aEntries[ iObject ].idObject)
620 if (!*ppListObjectProperties)
621 *ppListObjectProperties = AfsAdmSvr_CreateObjPropList();
623 if (*ppListObjectProperties)
624 AfsAdmSvr_AddToObjPropList (ppListObjectProperties, &ObjectProperties, 0);
629 Print (dlDETAIL, TEXT("Client 0x%08lX: GetObjects succeeded; returning %lu properties"), idClient, (*ppListObjectProperties) ? ((*ppListObjectProperties)->cEntries) : 0);
630 AfsAdmSvr_EndOperation (iOp);
631 return TRUE;
635 // AfsAdmSvr_RefreshObject
636 // AfsAdmSvr_RefreshObjects
637 // ...invalidates the server's cache of information about the specified
638 // object or objects.
640 extern "C" int AfsAdmSvr_RefreshObject (UINT_PTR idClient, ASID idObject, ULONG *pStatus)
642 size_t iOp = AfsAdmSvr_BeginOperation (idClient);
644 Print (dlDETAIL, TEXT("Client 0x%08lX: RefreshObject (idObject=0x%08lX)"), idClient, idObject);
646 if (!AfsAdmSvr_fIsValidClient (idClient))
647 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
649 if (!AfsAdmSvr_InvalidateObjectProperties (idObject, pStatus))
651 AfsAdmSvr_EndOperation (iOp);
652 return FALSE;
655 AfsAdmSvr_EndOperation (iOp);
656 return TRUE;
660 extern "C" int AfsAdmSvr_RefreshObjects (UINT_PTR idClient, LPASIDLIST pListObjects, ULONG *pStatus)
662 size_t iOp = AfsAdmSvr_BeginOperation (idClient);
664 Print (dlDETAIL, TEXT("Client 0x%08lX: RefreshObjects (nObjects=%lu)"), idClient, (pListObjects) ? (pListObjects->cEntries) : 0);
666 if (!AfsAdmSvr_fIsValidClient (idClient))
667 return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
669 for (size_t iObject = 0; iObject < pListObjects->cEntries; ++iObject)
671 ULONG status;
672 AfsAdmSvr_RefreshObject (idClient, pListObjects->aEntries[ iObject ].idObject, &status);
675 AfsAdmSvr_EndOperation (iOp);
676 return TRUE;
680 // AfsAdmSvr_CallbackHost
681 // ...provides a context in which the server can issue callback functions
682 // via the AfsAdmSvrCallBack_* routines, which the client must implement.
683 // This routine will only return if the server is shut down. It should
684 // be called on a dedicated thread by the client. (TaAfsAdmSvrClient.lib
685 // automatically handles this.)
687 extern "C" void AfsAdmSvr_CallbackHost (void)
689 AfsAdmSvr_CallbackManager();
694 // AfsAdmSvr_GetRandomKey
695 // ...returns a randomly-generated 8-byte encryption key
697 extern "C" int AfsAdmSvr_GetRandomKey (UINT_PTR idClient, ASID idCell, BYTE keyData[ ENCRYPTIONKEYLENGTH ], ULONG *pStatus)
699 if (!AfsAdmSvr_fIsValidClient (idClient))
700 return FALSE_(ERROR_INVALID_PARAMETER,pStatus);
702 return AfsClass_GetRandomKey ((LPIDENT)idCell, (LPENCRYPTIONKEY)keyData, pStatus);