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
13 #include <afs/param.h>
16 #include "TaAfsAdmSvrInternal.h"
20 * ROUTINES ___________________________________________________________________
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.
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
))
45 Print (TEXT("Connected to client %s (ID 0x%08lX)"), AfsAdmSvr_GetClientName (*pidClient
), *pidClient
);
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
)
61 if (!AfsAdmSvr_fIsValidClient (idClient
))
62 return Leave_FALSE_(ERROR_INVALID_PARAMETER
, pStatus
);
64 AfsAdmSvr_PingClient (idClient
);
70 // AfsAdmSvr_Disconnect
71 // ...releases and invalidates the cookie representing the calling process.
73 extern "C" int AfsAdmSvr_Disconnect (UINT_PTR idClient
, ULONG
*pStatus
)
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
);
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
)
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
);
115 AfsAppLib_UnixTimeToSystemTime (pstExpiration
, dateExpirationQuery
);
117 AfsAdmSvr_EndOperation (iOp
);
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
)
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
);
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
)
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
;
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
);
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
)
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
);
193 if ((lpCell
= ((LPIDENT
)idCell
)->OpenCell (&status
)) == NULL
)
194 return FALSE_(ERROR_INVALID_PARAMETER
,pStatus
,iOp
);
196 lpCell
->SetCurrentCredentials ((PVOID
)hCreds
);
199 AfsAdmSvr_EndOperation (iOp
);
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
);
222 AfsAdmSvr_EndOperation (iOp
);
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
);
236 if ((pch
= (LPTSTR
)lstrrchr (pszErrorText
, TEXT('('))) != NULL
)
238 while (lstrlen(pszErrorText
) && pszErrorText
[ lstrlen(pszErrorText
)-1 ] == TEXT(' '))
239 pszErrorText
[ lstrlen(pszErrorText
)-1 ] = TEXT('\0');
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"));
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);
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
);
300 if ((lpiCell
= CELL::OpenCell ((LPTSTR
)pszCellName
, (PVOID
)hCreds
, pStatus
)) == NULL
)
302 AfsAdmSvr_EndOperation (iOp
);
306 Print (dlDETAIL
, TEXT("Client 0x%08lX: OpenCell succeeded (idCell=0x%08lX)"), idClient
, lpiCell
);
308 *pidCell
= (ASID
)lpiCell
;
309 AfsAdmSvr_EndOperation (iOp
);
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
);
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
)
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.
373 rc
= AfsAdmSvr_Search_OneUser (pidObject
, idSearchScope
, szName
, &status
);
377 rc
= AfsAdmSvr_Search_OneGroup (pidObject
, idSearchScope
, szName
, &status
);
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
))
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
);
407 status
= ERROR_INVALID_PARAMETER
;
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
);
421 status
= ERROR_INVALID_PARAMETER
;
426 if (ObjectType
== TYPE_VOLUME
)
427 rc
= AfsAdmSvr_Search_VolumeInPartition (pidObject
, idSearchScope
, szName
, &status
);
431 status
= ERROR_INVALID_PARAMETER
;
442 Print (dlERROR
, TEXT("Client 0x%08lX: FindObject failed (status=0x%08lX)"), idClient
, status
);
444 Print (dlDETAIL
, TEXT("Client 0x%08lX: FindObject succeeded; returning idObject=0x%08lX"), idClient
, *pidObject
);
446 AfsAdmSvr_EndOperation (iOp
);
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
)
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
))
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
);
499 status
= ERROR_INVALID_PARAMETER
;
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
);
515 status
= ERROR_INVALID_PARAMETER
;
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
);
527 status
= ERROR_INVALID_PARAMETER
;
532 if (rc
&& (*ppList
) && (pSearchParams
))
533 AfsAdmSvr_Search_Advanced (ppList
, pSearchParams
);
535 if (!rc
&& (*ppList
))
536 AfsAdmSvr_FreeAsidList (ppList
);
541 Print (dlERROR
, TEXT("Client 0x%08lX: FindObjects failed (status=0x%08lX)"), idClient
, status
);
543 Print (dlDETAIL
, TEXT("Client 0x%08lX: FindObjects succeeded; returning %lu item(s)"), idClient
, (*ppList
)->cEntries
);
545 AfsAdmSvr_EndOperation (iOp
);
550 // AfsAdmSvr_GetObject
551 // AfsAdmSvr_GetObjects
552 // ...returns server-cached information about the specified object (or
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
);
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
);
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
);
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
;
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
);
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
);
655 AfsAdmSvr_EndOperation (iOp
);
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
)
672 AfsAdmSvr_RefreshObject (idClient
, pListObjects
->aEntries
[ iObject
].idObject
, &status
);
675 AfsAdmSvr_EndOperation (iOp
);
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
);