UINT_PTR AfsAppLib_SetCredentials (LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword, ULONG *pStatus) { UINT_PTR hCreds = 0; ULONG status = 0; UINT_PTR idClient; if ((idClient = AfsAppLib_GetAdminServerClientID()) != 0) { hCreds = asc_CredentialsSet (idClient, pszCell, pszUser, pszPassword, &status); } else if (OpenClientLibrary()) { char szCellA[ cchRESOURCE ]; char szUserA[ cchRESOURCE ]; char szPasswordA[ cchRESOURCE ]; CopyStringToAnsi (szCellA, pszCell); CopyStringToAnsi (szUserA, pszUser); CopyStringToAnsi (szPasswordA, pszPassword); afsclient_TokenGetNew (szCellA, szUserA, szPasswordA, (PVOID *)&hCreds, (afs_status_p)&status); CloseClientLibrary(); } if (hCreds) { PostMessage (AfsAppLib_GetMainWindow(), WM_REFRESHED_CREDENTIALS, 0, (LPARAM)hCreds); } if (!hCreds && pStatus) *pStatus = status; return hCreds; }
// AfsAdmSvr_SetCredentials // ...obtains new AFS credentials within the administrative server process // on behalf of the specified user. if successful, returns a nonzero // token {hCreds}, suitable for use in AfsAdmSvr_OpenCell(). // extern "C" UINT_PTR AfsAdmSvr_SetCredentials (UINT_PTR idClient, STRING pszCell, STRING pszUser, STRING pszPassword, ULONG *pStatus) { ULONG status; size_t iOp = AfsAdmSvr_BeginOperation (idClient); Print (dlDETAIL, TEXT("Client 0x%08lX: SetCredentials (%s,%s)"), idClient, pszCell, pszUser); if (!AfsAdmSvr_fIsValidClient (idClient)) return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp); const char *pszCellSet = (pszCell && *pszCell) ? (const char *)pszCell : NULL; UINT_PTR hCreds; if (!afsclient_TokenGetNew (pszCellSet, (const char *)pszUser, (const char *)pszPassword, (PVOID *)&hCreds, (afs_status_p)&status)) return FALSE_(status,pStatus,iOp); AfsAdmSvr_EndOperation (iOp); return hCreds; }