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.

387 lines
12 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. exports.cpp
  5. Abstract:
  6. Provides APIs to enter and remove license certificates from the system.
  7. The clientele consists of LICCPA.CPL (the licensing control panel applet)
  8. and LLSMGR.EXE (License Manager), and it may also be used directly by setup
  9. programs.
  10. Author:
  11. Jeff Parham (jeffparh) 13-Dec-1995
  12. Revision History:
  13. --*/
  14. #include "stdafx.h"
  15. #include "ccfapi.h"
  16. #ifdef OBSOLETE
  17. #include "paper.h"
  18. #endif // OBSOLETE
  19. #include "nlicdlg.h"
  20. ///////////////////////////////////////////////////////////////////////////////
  21. // CCF API //
  22. ///////////////
  23. DWORD APIENTRY CCFCertificateEnterUI( HWND hWndParent, LPCSTR pszServerName, LPCSTR pszProductName, LPCSTR pszVendor, DWORD dwFlags, LPCSTR pszSourceToUse )
  24. /*++
  25. Routine Description:
  26. Display a dialog allowing the user to enter a license certificate
  27. into the system.
  28. Arguments:
  29. hWndParent (HWND)
  30. HWND to the client's main window, for use as the parent window to any
  31. opened dialogs. May be NULL.
  32. pszServerName (LPCSTR)
  33. Name of the server for which licenses are to be installed. Note that
  34. this may not be the same as the server on which licenses are actually
  35. installed, as, for example, per seat licenses are always installed on
  36. the enterprise server. A NULL value indicates the local server.
  37. pszProductName (LPCSTR)
  38. Product for which licenses are to be installed. A NULL value indicates
  39. that the user should be allowed to choose.
  40. pszVendor (LPCSTR)
  41. Name of the vendor of the product. This value should be NULL if
  42. pszProductName is NULL, and should be non-NULL if pszProductName is
  43. non-NULL.
  44. dwFlags (DWORD)
  45. A bitfield containing one or more of the following:
  46. CCF_ENTER_FLAG_PER_SEAT_ONLY
  47. Allow the user to enter only per seat licenses. Not valid in
  48. combination with CCF_ENTER_FLAG_PER_SERVER_ONLY.
  49. CCF_ENTER_FLAG_PER_SERVER_ONLY
  50. Allow the user to enter only per server licenses. Not valid in
  51. combination with CCF_ENTER_FLAG_PER_SEAT_ONLY.
  52. pszSourceToUse (LPCSTR)
  53. Name of the secure certificate source to use to install the certificate,
  54. e.g., "Paper". A NULL value indicates that the user should be allowed
  55. to choose.
  56. Return Value:
  57. ERROR_SUCCESS (A certificate was successfully entered into the system.)
  58. ERROR_CANCELLED (The user cancelled without installing a certificate.)
  59. other Win error
  60. --*/
  61. {
  62. AFX_MANAGE_STATE( AfxGetStaticModuleState() );
  63. DWORD dwError;
  64. dwError = theApp.CertificateEnter( hWndParent, pszServerName, pszProductName, pszVendor, dwFlags, pszSourceToUse );
  65. return dwError;
  66. }
  67. //////////////////////////////////////////////////////////////////////////////
  68. DWORD APIENTRY CCFCertificateRemoveUI( HWND hWndParent, LPCSTR pszServerName, LPCSTR pszProductName, LPCSTR pszVendor, DWORD dwFlags, LPCSTR pszSourceToUse )
  69. /*++
  70. Routine Description:
  71. Display a dialog allowing the user to remove one or more license
  72. certificates from the system.
  73. Arguments:
  74. hWndParent (HWND)
  75. HWND to the client's main window, for use as the parent window to any
  76. opened dialogs. May be NULL.
  77. pszServerName (LPCSTR)
  78. Name of the server on which licenses are to be removed. A NULL value
  79. indicates the local server.
  80. pszProductName (LPCSTR)
  81. Product for which licenses are to be removed. A NULL value indicates
  82. that the user should be allowed to remove licenses from any product.
  83. pszVendor (LPCSTR)
  84. Name of the vendor of the product. This value should be NULL if
  85. pszProductName is NULL, and should be non-NULL if pszProductName is
  86. non-NULL.
  87. dwFlags (DWORD)
  88. Certificate removal options. As of this writing, no flags are
  89. supported.
  90. pszSourceToUse (LPCSTR)
  91. Name of the secure certificate source by which licenses are to be
  92. removed, e.g., "Paper". A NULL value indicates that the user should
  93. be allowed to remove licenses that were installed with any source.
  94. Return Value:
  95. ERROR_SUCCESS
  96. Win error
  97. --*/
  98. {
  99. AFX_MANAGE_STATE( AfxGetStaticModuleState() );
  100. DWORD dwError;
  101. dwError = theApp.CertificateRemove( hWndParent, pszServerName, pszProductName, pszVendor, dwFlags, pszSourceToUse );
  102. return dwError;
  103. }
  104. ///////////////////////////////////////////////////////////////////////////////
  105. // Certificate Source -- No Certificate //
  106. ////////////////////////////////////////////
  107. DWORD APIENTRY NoCertificateEnter( HWND hWnd,
  108. LPCSTR pszServerName,
  109. LPCSTR pszProductName,
  110. LPCSTR pszVendor,
  111. DWORD dwFlags )
  112. /*++
  113. Routine Description:
  114. Display a dialog allowing the user to enter a license certificate
  115. into the system with no certificate (3.51-style).
  116. Arguments:
  117. hWndParent (HWND)
  118. HWND to the client's main window, for use as the parent window to any
  119. opened dialogs. May be NULL.
  120. pszServerName (LPCSTR)
  121. Name of the server for which licenses are to be installed. Note that
  122. this may not be the same as the server on which licenses are actually
  123. installed, as, for example, per seat licenses are always installed on
  124. the enterprise server. A NULL value indicates the local server.
  125. pszProductName (LPCSTR)
  126. Product for which licenses are to be installed. A NULL value indicates
  127. that the user should be allowed to choose.
  128. pszVendor (LPCSTR)
  129. Name of the vendor of the product. This value should be NULL if
  130. pszProductName is NULL, and should be non-NULL if pszProductName is
  131. non-NULL.
  132. dwFlags (DWORD)
  133. A bitfield containing one or more of the following:
  134. CCF_ENTER_FLAG_PER_SEAT_ONLY
  135. Allow the user to enter only per seat licenses. Not valid in
  136. combination with CCF_ENTER_FLAG_PER_SERVER_ONLY.
  137. CCF_ENTER_FLAG_PER_SERVER_ONLY
  138. Allow the user to enter only per server licenses. Not valid in
  139. combination with CCF_ENTER_FLAG_PER_SEAT_ONLY.
  140. Return Value:
  141. ERROR_SUCCESS (A certificate was successfully entered into the system.)
  142. ERROR_CANCELLED (The user cancelled without installing a certificate.)
  143. other Win error
  144. --*/
  145. {
  146. AFX_MANAGE_STATE( AfxGetStaticModuleState() );
  147. CNewLicenseDialog dlg( CWnd::FromHandle( hWnd ) );
  148. return dlg.CertificateEnter( pszServerName, pszProductName, pszVendor, dwFlags );
  149. }
  150. //////////////////////////////////////////////////////////////////////////////
  151. DWORD APIENTRY NoCertificateRemove( HWND hWnd,
  152. LPCSTR pszServerName,
  153. DWORD dwFlags,
  154. DWORD dwLicenseLevel,
  155. LPVOID pvLicenseInfo )
  156. /*++
  157. Routine Description:
  158. Remove licenses previously installed via 3.51 or NoCertificateEnter().
  159. Arguments:
  160. hWndParent (HWND)
  161. HWND to the client's main window, for use as the parent window to any
  162. opened dialogs. May be NULL.
  163. pszServerName (LPCSTR)
  164. Name of the server on which licenses are to be removed. A NULL value
  165. indicates the local server.
  166. dwFlags (DWORD)
  167. Certificate removal options. As of this writing, no flags are
  168. supported.
  169. dwLicenseLevel (DWORD)
  170. Level of the LLS_LICENSE_INFO_X structure pointed to by pvLicenseInfo.
  171. pvLicenseInfo (LPVOID)
  172. Points to a LLS_LICENSE_INFO_X (where X is determined by dwLicenseLevel)
  173. describing the licenses to be removed.
  174. Return Value:
  175. ERROR_SUCCESS
  176. Win error
  177. --*/
  178. {
  179. AFX_MANAGE_STATE( AfxGetStaticModuleState() );
  180. DWORD dwError;
  181. if ( 1 != dwLicenseLevel )
  182. {
  183. dwError = ERROR_INVALID_LEVEL;
  184. }
  185. else
  186. {
  187. CNewLicenseDialog dlg( CWnd::FromHandle( hWnd ) );
  188. dwError = dlg.CertificateRemove( pszServerName, dwFlags, (PLLS_LICENSE_INFO_1) pvLicenseInfo );
  189. }
  190. return dwError;
  191. }
  192. #ifdef OBSOLETE
  193. ///////////////////////////////////////////////////////////////////////////////
  194. // Certificate Source -- Paper Certificate //
  195. ///////////////////////////////////////////////
  196. DWORD APIENTRY PaperCertificateEnter( HWND hWnd,
  197. LPCSTR pszServerName,
  198. LPCSTR pszProductName,
  199. LPCSTR pszVendor,
  200. DWORD dwFlags )
  201. /*++
  202. Routine Description:
  203. Display a dialog allowing the user to enter a license certificate
  204. into the system with a paper certificate.
  205. Arguments:
  206. hWndParent (HWND)
  207. HWND to the client's main window, for use as the parent window to any
  208. opened dialogs. May be NULL.
  209. pszServerName (LPCSTR)
  210. Name of the server for which licenses are to be installed. Note that
  211. this may not be the same as the server on which licenses are actually
  212. installed, as, for example, per seat licenses are always installed on
  213. the enterprise server. A NULL value indicates the local server.
  214. pszProductName (LPCSTR)
  215. Product for which licenses are to be installed. A NULL value indicates
  216. that the user should be allowed to choose.
  217. pszVendor (LPCSTR)
  218. Name of the vendor of the product. This value should be NULL if
  219. pszProductName is NULL, and should be non-NULL if pszProductName is
  220. non-NULL.
  221. dwFlags (DWORD)
  222. A bitfield containing one or more of the following:
  223. CCF_ENTER_FLAG_PER_SEAT_ONLY
  224. Allow the user to enter only per seat licenses. Not valid in
  225. combination with CCF_ENTER_FLAG_PER_SERVER_ONLY.
  226. CCF_ENTER_FLAG_PER_SERVER_ONLY
  227. Allow the user to enter only per server licenses. Not valid in
  228. combination with CCF_ENTER_FLAG_PER_SEAT_ONLY.
  229. Return Value:
  230. ERROR_SUCCESS (A certificate was successfully entered into the system.)
  231. ERROR_CANCELLED (The user cancelled without installing a certificate.)
  232. other Win error
  233. --*/
  234. {
  235. AFX_MANAGE_STATE( AfxGetStaticModuleState() );
  236. DWORD dwError;
  237. if ( !!pszProductName != !!pszVendor )
  238. {
  239. // they must both be NULL or both have values
  240. dwError = ERROR_INVALID_PARAMETER;
  241. }
  242. else
  243. {
  244. CPaperSourceDlg dlg( CWnd::FromHandle( hWnd ) );
  245. dwError = dlg.CertificateEnter( pszServerName, pszProductName, pszVendor, dwFlags );
  246. }
  247. return dwError;
  248. }
  249. //////////////////////////////////////////////////////////////////////////////
  250. DWORD APIENTRY PaperCertificateRemove( HWND hWnd,
  251. LPCSTR pszServerName,
  252. DWORD dwFlags,
  253. DWORD dwLicenseLevel,
  254. LPVOID pvLicenseInfo )
  255. /*++
  256. Routine Description:
  257. Remove licenses previously installed via PaperCertificateEnter().
  258. Arguments:
  259. hWndParent (HWND)
  260. HWND to the client's main window, for use as the parent window to any
  261. opened dialogs. May be NULL.
  262. pszServerName (LPCSTR)
  263. Name of the server on which licenses are to be removed. A NULL value
  264. indicates the local server.
  265. dwFlags (DWORD)
  266. Certificate removal options. As of this writing, no flags are
  267. supported.
  268. dwLicenseLevel (DWORD)
  269. Level of the LLS_LICENSE_INFO_X structure pointed to by pvLicenseInfo.
  270. pvLicenseInfo (LPVOID)
  271. Points to a LLS_LICENSE_INFO_X (where X is determined by dwLicenseLevel)
  272. describing the licenses to be removed.
  273. Return Value:
  274. ERROR_SUCCESS
  275. Win error
  276. --*/
  277. {
  278. AFX_MANAGE_STATE( AfxGetStaticModuleState() );
  279. DWORD dwError;
  280. if ( 1 != dwLicenseLevel )
  281. {
  282. dwError = ERROR_INVALID_LEVEL;
  283. }
  284. else
  285. {
  286. CPaperSourceDlg dlg( CWnd::FromHandle( hWnd ) );
  287. dwError = dlg.CertificateRemove( pszServerName, dwFlags, (PLLS_LICENSE_INFO_1) pvLicenseInfo );
  288. }
  289. return dwError;
  290. }
  291. #endif // OBSOLETE