Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1053 lines
28 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996-1996
  5. //
  6. // File: rpc.c
  7. //
  8. // Contents: Various RPC function to accept client request
  9. //
  10. // History: 12-09-98 HueiWang Created
  11. // 05-26-98 HueiWang Move all code to TLSRpcXXX
  12. // API here is only for compatible with
  13. // NT40 Hydra
  14. //---------------------------------------------------------------------------
  15. #include "pch.cpp"
  16. #include "globals.h"
  17. #include "server.h"
  18. #include "init.h"
  19. //+------------------------------------------------------------------------
  20. error_status_t
  21. LSGetRevokeKeyPackList(
  22. /* [in] */ PCONTEXT_HANDLE phContext,
  23. /* [out][in] */ PDWORD pcbNumberOfKeyPack,
  24. /* [size_is][out][in] */ PDWORD pRevokeKeyPackList
  25. )
  26. /*
  27. Note : For backward compatible with NT40 Hydra only
  28. */
  29. {
  30. *pcbNumberOfKeyPack=0;
  31. return ERROR_SUCCESS;
  32. }
  33. //+------------------------------------------------------------------------
  34. error_status_t
  35. LSGetRevokeLicenseList(
  36. /* [in] */ PCONTEXT_HANDLE phContext,
  37. /* [out][in] */ PDWORD pcbNumberOfLicenses,
  38. /* [size_is][out][in] */ PDWORD pRevokeLicenseList
  39. )
  40. /*
  41. Note : For backward compatible with NT40 Hydra only
  42. */
  43. {
  44. *pcbNumberOfLicenses=0;
  45. return ERROR_SUCCESS;
  46. }
  47. //+------------------------------------------------------------------------
  48. error_status_t
  49. LSValidateLicense(
  50. /* [in] */ PCONTEXT_HANDLE phContext,
  51. /* [in] */ DWORD cbLicense,
  52. /* [size_is][in] */ BYTE __RPC_FAR *pbLicense
  53. )
  54. /*
  55. Note : For backward compatible with NT40 Hydra only
  56. */
  57. {
  58. RpcRaiseException(RPC_S_CANNOT_SUPPORT); // doesn't return
  59. return RPC_S_CANNOT_SUPPORT;
  60. }
  61. //+------------------------------------------------------------------------
  62. error_status_t
  63. LSConnect(
  64. /* [in] */ handle_t hRpcBinding,
  65. /* [out] */ PCONTEXT_HANDLE __RPC_FAR *pphContext
  66. )
  67. {
  68. return TLSRpcConnect( hRpcBinding, pphContext );
  69. }
  70. //-----------------------------------------------------------------------
  71. error_status_t
  72. LSSendServerCertificate(
  73. /* [in] */ PCONTEXT_HANDLE phContext,
  74. /* [in] */ DWORD cbCert,
  75. /* [size_is][in] */ PBYTE pbCert
  76. )
  77. {
  78. DWORD status = ERROR_SUCCESS;
  79. TLSRpcSendServerCertificate(
  80. phContext,
  81. cbCert,
  82. pbCert,
  83. &status
  84. );
  85. return status;
  86. }
  87. //+------------------------------------------------------------------------
  88. error_status_t
  89. LSDisconnect(
  90. /* [out][in] */ PPCONTEXT_HANDLE pphContext
  91. )
  92. {
  93. return TLSRpcDisconnect(pphContext);
  94. }
  95. //+------------------------------------------------------------------------
  96. error_status_t
  97. LSGetServerName(
  98. /* [in] */ PCONTEXT_HANDLE phContext,
  99. /* [size_is][string][out][in] */ LPTSTR szMachineName,
  100. /* [out][in] */ PDWORD pcbSize
  101. )
  102. /*
  103. Description :
  104. Return Server's Machine Name.
  105. Arguments:
  106. phContext - client context handle.
  107. szMachineName - Pointer to a buffer that receives a null-terminated
  108. string containing the computer name. The buffer size
  109. should be large enough to contain
  110. MAX_COMPUTERNAME_LENGTH + 1 characters.
  111. cbSize - Pointer to a DWORD variable. On input, the variable
  112. specifies the size, in bytes or characters, of the buffer.
  113. On output, the variable returns the number of bytes or characters
  114. copied to the destination buffer, not including the terminating
  115. null character.
  116. Returns:
  117. LSERVER_S_SUCCESS
  118. */
  119. {
  120. DWORD dwErrCode=ERROR_SUCCESS;
  121. TLSRpcGetServerName(
  122. phContext,
  123. szMachineName,
  124. pcbSize,
  125. &dwErrCode
  126. );
  127. return dwErrCode;
  128. }
  129. //+------------------------------------------------------------------------
  130. error_status_t
  131. LSGetServerScope(
  132. /* [in] */ PCONTEXT_HANDLE phContext,
  133. /* [size_is][string][out][in] */ LPTSTR szScopeName,
  134. /* [out][in] */ PDWORD pcbSize
  135. )
  136. /*
  137. Description:
  138. Return License Server's scope
  139. Arguments:
  140. IN phContext - Client context
  141. IN OUT szScopeName - return server's scope, must be at least
  142. MAX_COMPUTERNAME_LENGTH in length
  143. Return Value:
  144. LSERVER_S_SUCCESS or error code from WideCharToMultiByte()
  145. */
  146. {
  147. DWORD status=ERROR_SUCCESS;
  148. TLSRpcGetServerScope(
  149. phContext,
  150. szScopeName,
  151. pcbSize,
  152. &status
  153. );
  154. return status;
  155. }
  156. //+------------------------------------------------------------------------
  157. error_status_t
  158. LSGetInfo(
  159. /* [in] */ PCONTEXT_HANDLE phContext,
  160. /* [in] */ DWORD cbHSCert,
  161. /* [size_is][ref][in] */ PBYTE pHSCert,
  162. /* [ref][out] */ PDWORD pcbLSCert,
  163. /* [size_is][size_is][out] */ BYTE __RPC_FAR *__RPC_FAR *pLSCert,
  164. /* [ref][out] */ PDWORD pcbLSSecretKey,
  165. /* [size_is][size_is][out] */ BYTE __RPC_FAR *__RPC_FAR *pLSSecretKey
  166. )
  167. /*
  168. Description:
  169. Routine to exchange Hydra server's certificate and License server's
  170. certificate/private key for signing client machine's hardware ID.
  171. Arguments:
  172. IN phContext - client context handle
  173. IN cbHSCert - size of Hydra Server's certificate
  174. IN pHSCert - Hydra Server's certificate
  175. IN OUT pcbLSCert - return size of License Server's certificate
  176. OUT pLSCert - return License Server's certificate
  177. OUT pcbLSSecretKey - return size of License Server's private key.
  178. OUT pLSSecretKey - retrun License Server's private key
  179. Return Value:
  180. LSERVER_S_SUCCESS success
  181. LSERVER_E_INVALID_DATA Invalid hydra server certificate
  182. LSERVER_E_OUTOFMEMORY Can't allocate required memory
  183. TLS_E_INTERNAL Internal error occurred in License Server
  184. */
  185. {
  186. return TLSMapReturnCode(TLS_E_NOTSUPPORTED);;
  187. }
  188. //+------------------------------------------------------------------------
  189. error_status_t
  190. LSGetLastError(
  191. /* [in] */ PCONTEXT_HANDLE phContext,
  192. /* [in] */ DWORD cbBufferSize,
  193. /* [string][out][in] */ LPTSTR szBuffer
  194. )
  195. /*
  196. Description:
  197. Return error description text for client's last LSXXX call
  198. Arguments:
  199. IN phContext - Client context
  200. IN cbBufferSize - max. size of szBuffer
  201. IN OUT szBuffer - Pointer to a buffer to receive the
  202. null-terminated character string containing
  203. error description
  204. Note:
  205. Return ANSI error string.
  206. Returns:
  207. LSERVER_S_SUCCESS
  208. TLS_E_INTERNAL No error or can't find corresponding error
  209. description.
  210. Error code from WideCharToMultiByte().
  211. */
  212. {
  213. DWORD status;
  214. TLSRpcGetLastError(
  215. phContext,
  216. &cbBufferSize,
  217. szBuffer,
  218. &status
  219. );
  220. return status;
  221. }
  222. //+------------------------------------------------------------------------
  223. error_status_t
  224. LSIssuePlatformChallenge(
  225. /* [in] */ PCONTEXT_HANDLE phContext,
  226. /* [in] */ DWORD dwClientInfo,
  227. /* [ref][out] */ PCHALLENGE_CONTEXT pChallengeContext,
  228. /* [out] */ PDWORD pcbChallengeData,
  229. /* [size_is][size_is][out] */ BYTE __RPC_FAR *__RPC_FAR *pChallengeData
  230. )
  231. /*
  232. Description:
  233. Issue a platform challenge to hydra client.
  234. Arguments:
  235. IN phContext - client context handle
  236. IN dwClientInfo - client info.
  237. OUT pChallengeContext - pointer to client challenge context.
  238. OUT pcbChallengeData - size of challenge data.
  239. OUT pChallengeData - random client challenge data.
  240. Returns:
  241. LSERVER_S_SUCCESS
  242. LSERVER_E_OUTOFMEMORY
  243. LSERVER_E_INVALID_DATA Invalid client info.
  244. LSERVER_E_SERVER_BUSY
  245. */
  246. {
  247. DWORD status=ERROR_SUCCESS;
  248. TLSRpcIssuePlatformChallenge(
  249. phContext,
  250. dwClientInfo,
  251. pChallengeContext,
  252. pcbChallengeData,
  253. pChallengeData,
  254. &status
  255. );
  256. return status;
  257. }
  258. //+------------------------------------------------------------------------
  259. error_status_t
  260. LSAllocateConcurrentLicense(
  261. /* [in] */ PCONTEXT_HANDLE phContext,
  262. /* [string][in] */ LPTSTR szHydraServer,
  263. /* [in] */ LICENSE_REQUEST_TYPE __RPC_FAR *pRequest,
  264. /* [ref][out][in] */ LONG __RPC_FAR *dwQuantity
  265. )
  266. /*
  267. Description:
  268. Allocate concurrent licenses base on product.
  269. Arguments:
  270. IN phContext - client context handle
  271. IN szHydraServer - name of hydra server requesting concurrent licenses
  272. IN pRequest - product to request for concurrent license.
  273. IN OUT dwQuantity - See note
  274. Return Value:
  275. LSERVER_S_SUCCESS
  276. LSERVER_E_INVALID_DATA Invalid parameter.
  277. LSERVER_E_NO_PRODUCT request product not installed
  278. LSERVER_E_NO_LICNESE no available license for request product
  279. LSERVER_E_LICENSE_REVOKED Request license has been revoked
  280. LSERVER_E_LICENSE_EXPIRED Request license has expired
  281. LSERVER_E_CORRUPT_DATABASE Corrupt database
  282. LSERVER_E_INTERNAL_ERROR Internal error in license server
  283. Note:
  284. dwQuantity
  285. Input Output
  286. ------------------------- -----------------------------------------
  287. 0 Total number of concurrent license
  288. issued to hydra server.
  289. > 0, number of license Actual number of license allocated
  290. requested
  291. < 0, number of license Actual number of license returned, always
  292. to return positive value.
  293. */
  294. {
  295. RpcRaiseException(RPC_S_CANNOT_SUPPORT); // doesn't return
  296. return RPC_S_CANNOT_SUPPORT;
  297. }
  298. //+------------------------------------------------------------------------
  299. error_status_t
  300. LSIssueNewLicense(
  301. /* [in] */ PCONTEXT_HANDLE phContext,
  302. /* [in] */ CHALLENGE_CONTEXT ChallengeContext,
  303. /* [in] */ LICENSE_REQUEST_TYPE __RPC_FAR *pRequest_org,
  304. /* [string][in] */ LPTSTR szMachineName,
  305. /* [string][in] */ LPTSTR szUserName,
  306. /* [in] */ DWORD cbChallengeResponse,
  307. /* [size_is][in] */ PBYTE cbChallenge,
  308. /* [in] */ BOOL bAcceptTemporaryLicense,
  309. /* [out] */ PDWORD pcbLicense,
  310. /* [size_is][size_is][out] */ BYTE __RPC_FAR *__RPC_FAR *ppLicense
  311. )
  312. /*
  313. Description:
  314. Routine to issue new license to hydra client based on product requested,
  315. it returns existing license if client already has a license and the
  316. license is not expired/returned/revoked, if request product has not been
  317. installed, it will issue a temporary license, if license found is temporary
  318. or expired, it will tried to upgrade/re-issue a new license with latest
  319. version of requested product, if the existing license is temporary and
  320. no license can be issued, it returns LSERVER_E_LICENSE_EXPIRED
  321. Arguments:
  322. IN phContext - client context handle.
  323. IN ChallengeContext - client challenge context handle, return from
  324. call LSIssuePlatformChallenge()
  325. IN cbChallengeResponse - size of the client's response to license server's
  326. platform challenge.
  327. IN pbChallenge - client's response to license server's platform challenge
  328. OUT pcbLicense - size of return license.
  329. OUT ppLicense - return license, could be old license
  330. Return Value:
  331. LSERVER_S_SUCCESS
  332. LSERVER_E_OUTOFMEMORY
  333. LSERVER_E_SERVER_BUSY Server is busy to process request.
  334. LSERVER_E_INVALID_DATA Invalid platform challenge response.
  335. LSERVER_E_NO_LICENSE No license available.
  336. LSERVER_E_NO_PRODUCT Request product is not installed on server.
  337. LSERVER_E_LICENSE_REJECTED License request is rejected by cert. server
  338. LSERVER_E_LICENSE_REVOKED Old license found and has been revoked
  339. LSERVER_E_LICENSE_EXPIRED Request product's license has expired
  340. LSERVER_E_CORRUPT_DATABASE Corrupted database.
  341. LSERVER_E_INTERNAL_ERROR Internal error in license server
  342. LSERVER_I_PROXIMATE_LICENSE Closest match license returned.
  343. LSERVER_I_TEMPORARY_LICENSE Temporary license has been issued
  344. LSERVER_I_LICENSE_UPGRADED Old license has been upgraded.
  345. */
  346. {
  347. DWORD status=ERROR_SUCCESS;
  348. TLSLICENSEREQUEST RpcRequest;
  349. RequestToTlsRequest(pRequest_org, &RpcRequest);
  350. TLSRpcRequestNewLicense(
  351. phContext,
  352. ChallengeContext,
  353. &RpcRequest,
  354. szMachineName,
  355. szUserName,
  356. cbChallengeResponse,
  357. cbChallenge,
  358. bAcceptTemporaryLicense,
  359. pcbLicense,
  360. ppLicense,
  361. &status
  362. );
  363. return status;
  364. }
  365. //+------------------------------------------------------------------------
  366. error_status_t
  367. LSUpgradeLicense(
  368. /* [in] */ PCONTEXT_HANDLE phContext,
  369. /* [in] */ DWORD cbOldLicense,
  370. /* [size_is][in] */ PBYTE pbOldLicense,
  371. /* [in] */ DWORD dwClientInfo,
  372. /* [out] */ PDWORD pcbNewLicense,
  373. /* [size_is][size_is][out] */ PBYTE __RPC_FAR *ppbNewLicense
  374. )
  375. /*
  376. Description:
  377. Update an old license.
  378. Arguments:
  379. IN phContext - client context handle.
  380. IN cbOldLicense - size of license to be upgraded.
  381. IN pOldLicense - license to be upgrade.
  382. OUT pcbNewLicense - size of upgraded license
  383. OUT pNewLicense - upgraded license.
  384. Return Value:
  385. LSERVER_S_SUCCESS
  386. TLS_E_INTERNAL
  387. LSERVER_E_INTERNAL_ERROR
  388. LSERVER_E_INVALID_DATA old license is invalid.
  389. LSERVER_E_NO_LICENSE no available license
  390. LSERVER_E_NO_PRODUCT request product not install in current server.
  391. LSERVER_E_CORRUPT_DATABASE Corrupted database.
  392. LSERVER_E_LICENSE_REJECTED License request rejected by cert. server.
  393. LSERVER_E_SERVER_BUSY
  394. Note:
  395. Unused - just return error
  396. */
  397. {
  398. RpcRaiseException(RPC_S_CANNOT_SUPPORT); // doesn't return
  399. return RPC_S_CANNOT_SUPPORT;
  400. }
  401. //+------------------------------------------------------------------------
  402. error_status_t
  403. LSKeyPackEnumBegin(
  404. /* [in] */ PCONTEXT_HANDLE phContext,
  405. /* [in] */ DWORD dwSearchParm,
  406. /* [in] */ BOOL bMatchAll,
  407. /* [ref][in] */ LPLSKeyPackSearchParm lpSearchParm
  408. )
  409. /*
  410. Description:
  411. Function to begin enumerate through all key pack installed on server
  412. based on search criterial.
  413. Arguments:
  414. IN phContext - client context handle.
  415. IN dwSearchParm - search criterial.
  416. IN bMatchAll - match all search criterial.
  417. IN lpSearchParm - search parameter.
  418. Return Value:
  419. LSERVER_S_SUCCESS
  420. LSERVER_E_SERVER_BUSY Server is too busy to process request
  421. LSERVER_E_OUTOFMEMORY
  422. TLS_E_INTERNAL
  423. LSERVER_E_INTERNAL_ERROR
  424. LSERVER_E_INVALID_DATA Invalid data in search parameter
  425. LSERVER_E_INVALID_SEQUENCE Invalid calling sequence, likely, previous
  426. enumeration has not ended.
  427. */
  428. {
  429. DWORD status=ERROR_SUCCESS;
  430. TLSRpcKeyPackEnumBegin(
  431. phContext,
  432. dwSearchParm,
  433. bMatchAll,
  434. lpSearchParm,
  435. &status
  436. );
  437. return status;
  438. }
  439. //+------------------------------------------------------------------------
  440. DWORD
  441. LSKeyPackEnumNext(
  442. /* [in] */ PCONTEXT_HANDLE phContext,
  443. /* [ref][out] */ LPLSKeyPack lpKeyPack
  444. )
  445. /*
  446. Description:
  447. Return next key pack that match search criterial
  448. Arguments:
  449. IN phContext - client context handle
  450. OUT lpKeyPack - key pack that match search criterial
  451. Return Value:
  452. LSERVER_S_SUCCESS
  453. LSERVER_I_NO_MORE_DATA No more keypack match search criterial
  454. TLS_E_INTERNAL General error in license server
  455. LSERVER_E_INTERNAL_ERROR Internal error in license server
  456. LSERVER_E_SERVER_BUSY License server is too busy to process request
  457. LSERVER_E_OUTOFMEMORY Can't process request due to insufficient memory
  458. LSERVER_E_INVALID_SEQUENCE Invalid calling sequence, must call
  459. LSKeyPackEnumBegin().
  460. */
  461. {
  462. DWORD status=ERROR_SUCCESS;
  463. TLSRpcKeyPackEnumNext(
  464. phContext,
  465. lpKeyPack,
  466. &status
  467. );
  468. return status;
  469. }
  470. //+------------------------------------------------------------------------
  471. error_status_t
  472. LSKeyPackEnumEnd(
  473. /* [in] */ PCONTEXT_HANDLE phContext
  474. )
  475. /*
  476. Description:
  477. Routine to end an enumeration on key pack.
  478. Arguments:
  479. IN phContext - client context handle.
  480. Return Value:
  481. LSERVER_S_SUCCESS
  482. LSERVER_E_INTERNAL_ERROR Internal error occurred in license server
  483. TLS_E_INTERNAL General error occurred in license server
  484. LSERVER_E_INVALID_HANDLE Has not call LSKeyPackEnumBegin()
  485. */
  486. {
  487. DWORD status=ERROR_SUCCESS;
  488. TLSRpcKeyPackEnumEnd(phContext, &status);
  489. return status;
  490. }
  491. //+------------------------------------------------------------------------
  492. error_status_t
  493. LSKeyPackAdd(
  494. /* [in] */ PCONTEXT_HANDLE phContext,
  495. /* [ref][out][in] */ LPLSKeyPack lpKeypack
  496. )
  497. /*
  498. Description:
  499. Add a license key pack.
  500. Arguments:
  501. IN phContext - client context handle.
  502. IN OUT lpKeyPack - key pack to be added.
  503. Return Value:
  504. LSERVER_S_SUCCESS
  505. LSERVER_E_INTERNAL_ERROR
  506. TLS_E_INTERNAL
  507. LSERVER_E_SERVER_BUSY
  508. LSERVER_E_DUPLICATE Product already installed.
  509. LSERVER_E_INVALID_DATA
  510. LSERVER_E_CORRUPT_DATABASE
  511. Note:
  512. Just return an error - unused
  513. */
  514. {
  515. RpcRaiseException(RPC_S_CANNOT_SUPPORT); // doesn't return
  516. return RPC_S_CANNOT_SUPPORT;
  517. }
  518. //+------------------------------------------------------------------------
  519. error_status_t
  520. LSKeyPackSetStatus(
  521. /* [in] */ PCONTEXT_HANDLE phContext,
  522. /* [in] */ DWORD dwSetParam,
  523. /* [ref][in] */ LPLSKeyPack lpKeyPack
  524. )
  525. /*
  526. Description:
  527. Routine to activate/deactivated a key pack.
  528. Arguments:
  529. IN phContext - client context handle
  530. IN dwSetParam - type of key pack status to be set.
  531. IN lpKeyPack - new key pack status.
  532. Return Value:
  533. LSERVER_S_SUCCESS
  534. LSERVER_E_INTERNAL_ERROR
  535. TLS_E_INTERNAL
  536. LSERVER_E_INVALID_DATA
  537. LSERVER_E_SERVER_BUSY
  538. LSERVER_E_DATANOTFOUND Key pack is not in server
  539. LSERVER_E_CORRUPT_DATABASE
  540. */
  541. {
  542. #if !defined(ENFORCE_LICENSING) || defined(PRIVATE_DBG)
  543. DWORD status=ERROR_SUCCESS;
  544. TLSRpcKeyPackSetStatus(
  545. phContext,
  546. dwSetParam,
  547. lpKeyPack,
  548. &status
  549. );
  550. return status;
  551. #else
  552. return TLSMapReturnCode(TLS_E_NOTSUPPORTED);
  553. #endif
  554. }
  555. //+------------------------------------------------------------------------
  556. error_status_t
  557. LSLicenseEnumBegin(
  558. /* [in] */ PCONTEXT_HANDLE phContext,
  559. /* [in] */ DWORD dwSearchParm,
  560. /* [in] */ BOOL bMatchAll,
  561. /* [ref][in] */ LPLSLicenseSearchParm lpSearchParm
  562. )
  563. /*
  564. Description:
  565. Begin enumeration of license issued based on search criterial
  566. Arguments:
  567. IN phContext - client context handle
  568. IN dwSearchParm - license search criterial.
  569. IN bMatchAll - match all search criterial
  570. IN lpSearchParm - license(s) to be enumerated.
  571. Return Value:
  572. Same as LSKeyPackEnumBegin().
  573. */
  574. {
  575. DWORD status=ERROR_SUCCESS;
  576. TLSRpcLicenseEnumBegin(
  577. phContext,
  578. dwSearchParm,
  579. bMatchAll,
  580. lpSearchParm,
  581. &status
  582. );
  583. return status;
  584. }
  585. //+------------------------------------------------------------------------
  586. error_status_t
  587. LSLicenseEnumNext(
  588. /* [in] */ PCONTEXT_HANDLE phContext,
  589. /* [ref][out] */ LPLSLicense lpLicense
  590. )
  591. /*
  592. Description:
  593. Arguments:
  594. IN phContext - client context handle
  595. OUT lpLicense - license match search criterial.
  596. Return Value:
  597. Same as LSKeyPackEnumNext().
  598. */
  599. {
  600. DWORD status=ERROR_SUCCESS;
  601. TLSRpcLicenseEnumNext(phContext, lpLicense, &status);
  602. return status;
  603. }
  604. //+------------------------------------------------------------------------
  605. error_status_t
  606. LSLicenseEnumEnd(
  607. /* [in] */ PCONTEXT_HANDLE phContext
  608. )
  609. /*
  610. Description:
  611. End enumeration of issued licenses.
  612. Arguments:
  613. IN phContext - client context handle.
  614. Return Value:
  615. Same as LSKeyPackEnumEnd().
  616. */
  617. {
  618. DWORD status=ERROR_SUCCESS;
  619. TLSRpcLicenseEnumEnd(phContext, &status);
  620. return status;
  621. }
  622. //+------------------------------------------------------------------------
  623. error_status_t
  624. LSLicenseSetStatus(
  625. /* [in] */ PCONTEXT_HANDLE phContext,
  626. /* [in] */ DWORD dwSetParam,
  627. /* [in] */ LPLSLicense lpLicense
  628. )
  629. /*
  630. Description:
  631. Routine to set status of a issued license.
  632. Arguments:
  633. IN phContext - client context handle.
  634. IN dwSetParam -
  635. IN lpLicense -
  636. Return Value:
  637. Unused - just returns an error
  638. */
  639. {
  640. RpcRaiseException(RPC_S_CANNOT_SUPPORT); // doesn't return
  641. return RPC_S_CANNOT_SUPPORT;
  642. }
  643. //+------------------------------------------------------------------------
  644. error_status_t
  645. LSLicenseGetCert(
  646. /* [in] */ PCONTEXT_HANDLE phContext,
  647. /* [ref][in] */ LPLSLicense lpLicense,
  648. /* [out] */ LPDWORD cbCert,
  649. /* [size_is][size_is][out] */ PBYTE __RPC_FAR *pbCert
  650. )
  651. /*
  652. Description:
  653. Retrieve actual certificate issued to client.
  654. Arguments:
  655. IN phContext - client context handle
  656. IN lpLicense -
  657. OUT cbCert - size of certificate.
  658. OUT pbCert - actual certificate.
  659. Return Value:
  660. LSERVER_S_SUCCESS
  661. LSERVER_E_INTERNAL_ERROR
  662. TLS_E_INTERNAL
  663. LSERVER_E_INVALID_DATA
  664. LSERVER_E_DATANOTFOUND
  665. LSERVER_E_CORRUPT_DATABASE
  666. */
  667. {
  668. return LSERVER_S_SUCCESS;
  669. }
  670. //+------------------------------------------------------------------------
  671. error_status_t
  672. LSGetAvailableLicenses(
  673. /* [in] */ PCONTEXT_HANDLE phContext,
  674. /* [in] */ DWORD dwSearchParm,
  675. /* [ref][in] */ LPLSKeyPack lplsKeyPack,
  676. /* [ref][out] */ LPDWORD lpdwAvail
  677. )
  678. /*
  679. Description:
  680. Retrieve number of available license for a product.
  681. Arguments:
  682. IN phContext - client context.
  683. IN dwSearchParm -
  684. IN lplsKeyPack -
  685. OUT lpdwAvail -
  686. Return Value:
  687. LSERVER_S_SUCCESS
  688. LSERVER_E_INTERNAL_ERROR
  689. TLS_E_INTERNAL
  690. LSERVER_E_DATANOTFOUND
  691. LSERVER_E_INVALID_DATA
  692. LSERVER_E_CORRUPT_DATABASE
  693. */
  694. {
  695. DWORD status=ERROR_SUCCESS;
  696. TLSRpcGetAvailableLicenses(
  697. phContext,
  698. dwSearchParm,
  699. lplsKeyPack,
  700. lpdwAvail,
  701. &status
  702. );
  703. return status;
  704. }
  705. //+------------------------------------------------------------------------
  706. error_status_t
  707. LSGetServerCertificate(
  708. /* [in] */ PCONTEXT_HANDLE phContext,
  709. /* [in] */ BOOL bSignCert,
  710. /* [size_is][size_is][out] */ LPBYTE __RPC_FAR *ppCertBlob,
  711. /* [ref][out] */ LPDWORD lpdwCertBlobLen
  712. )
  713. /*
  714. Description:
  715. Get License Server's signature or exchange certificate
  716. Arguments:
  717. IN phContext - client context.
  718. IN bSignCert - TRUE if signature certificate, FALSE if exchange certificate
  719. OUT ppCertBlob - pointer to pointer to receive certificate.
  720. OUT lpdwCertBlobLen - size of certificate returned.
  721. Return Value:
  722. LSERVER_S_SUCCESS
  723. LSERVER_E_ACCESS_DENIED Client doesn't have required privilege
  724. LSERVER_E_NO_CERTIFICATE License Server hasn't register yet.
  725. */
  726. {
  727. #if ENFORCE_LICENSING
  728. DWORD status=ERROR_SUCCESS;
  729. TLSRpcGetServerCertificate(
  730. phContext,
  731. bSignCert,
  732. ppCertBlob,
  733. lpdwCertBlobLen,
  734. &status
  735. );
  736. return status;
  737. #else
  738. return TLSMapReturnCode(TLS_E_NOTSUPPORTED);
  739. #endif
  740. }
  741. //+------------------------------------------------------------------------
  742. error_status_t
  743. LSRegisterLicenseKeyPack(
  744. /* [in] */ PCONTEXT_HANDLE phContext,
  745. /* [size_is][in] */ LPBYTE pbCHCertBlob,
  746. /* [in] */ DWORD cbCHCertBlobSize,
  747. /* [size_is][in] */ LPBYTE pbRootCertBlob,
  748. /* [in] */ DWORD cbRootCertBlob,
  749. /* [size_is][in] */ LPBYTE lpKeyPackBlob,
  750. /* [in] */ DWORD dwKeyPackBlobLen
  751. )
  752. /*
  753. Description:
  754. Register (Add) a license key pack into License Server.
  755. Arguments:
  756. IN phContext - client context.
  757. IN pbCHCertBlob - CH's certificate.
  758. IN cbCHCertBlobSize - CH certificate size.
  759. IN pbRootCertBlob - Root's certificate.
  760. IN cbRootCertBlob - Size of Root's certificate.
  761. IN lpKeyPackBlob - pointer to encrypted license KeyPack blob.
  762. IN dwKeyPackBlobLen - size of keypack blob.
  763. Return Value:
  764. LSERVER_S_SUCCESS
  765. LSERVER_E_ACCESS_DENIED Client doesn't have required privilege
  766. LSERVER_E_NO_CERTIFICATE License Server hasn't register yet.
  767. LSERVER_E_INVALID_DATA Can't verify any of the certificate or
  768. can't decode license keypack blob.
  769. LSERVER_E_SERVER_BUSY Server is busy.
  770. LSERVER_E_DUPLICATE KeyPack already register
  771. LSERVER_E_ERROR_GENERAL General ODBC error.
  772. */
  773. {
  774. #if ENFORCE_LICENSING
  775. DWORD status=ERROR_SUCCESS;
  776. TLSRpcRegisterLicenseKeyPack(
  777. phContext,
  778. pbCHCertBlob,
  779. cbCHCertBlobSize,
  780. pbRootCertBlob,
  781. cbRootCertBlob,
  782. lpKeyPackBlob,
  783. dwKeyPackBlobLen,
  784. &status
  785. );
  786. return status;
  787. #else
  788. return TLSMapReturnCode(TLS_E_NOTSUPPORTED);
  789. #endif
  790. }
  791. //+------------------------------------------------------------------------
  792. error_status_t
  793. LSInstallCertificate(
  794. /* [in] */ PCONTEXT_HANDLE phContext,
  795. /* [in] */ DWORD dwCertType,
  796. /* [in] */ DWORD dwCertLevel,
  797. /* [in] */ DWORD cbSignatureCert,
  798. /* [size_is][in] */ PBYTE pbSignatureCert,
  799. /* [in] */ DWORD cbExchangeCert,
  800. /* [size_is][in] */ PBYTE pbExchangeCert
  801. )
  802. /*
  803. Description:
  804. Install CH, CA, or License Server's certificate issued by CA into
  805. License Server.
  806. Arguments:
  807. RETURN:
  808. ACCESS_DENIED No privilege
  809. LSERVER_E_INVALID_DATA Can't verify certificate
  810. LSERVER_E_DUPLICATE Certificate already installed
  811. LSERVER_I_CERTIFICATE_OVERWRITE Overwrite certificate.
  812. */
  813. {
  814. #if ENFORCE_LICENSING
  815. DWORD status=ERROR_SUCCESS;
  816. TLSRpcInstallCertificate(
  817. phContext,
  818. dwCertType,
  819. dwCertLevel,
  820. cbSignatureCert,
  821. pbSignatureCert,
  822. cbExchangeCert,
  823. pbExchangeCert,
  824. &status
  825. );
  826. return status;
  827. #else
  828. return TLSMapReturnCode(TLS_E_NOTSUPPORTED);
  829. #endif
  830. }