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.

184 lines
5.7 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: config.cpp
  7. //
  8. // Contents: Cert Server client implementation
  9. //
  10. // History: 24-Aug-96 vich created
  11. //
  12. //---------------------------------------------------------------------------
  13. #include "pch.cpp"
  14. #pragma hdrstop
  15. #include "csdisp.h"
  16. #include "configp.h"
  17. #include "config.h"
  18. #include <limits.h>
  19. //+--------------------------------------------------------------------------
  20. // CCertConfig::~CCertConfig -- destructor
  21. //
  22. // free memory associated with this instance
  23. //+--------------------------------------------------------------------------
  24. CCertConfig::~CCertConfig()
  25. {
  26. }
  27. //+--------------------------------------------------------------------------
  28. // CCertConfig::Reset -- load config data, reset to indexed entry, return count
  29. //
  30. // Load the configuration data if not already loaded. To reload the data after
  31. // the data have changed, CCertConfig must be released and reinstantiated.
  32. //
  33. // Resets the current config entry to the Certification Authority configuration
  34. // listed in the configuration file, indexed by the Index parameter. 0 indexes
  35. // the first configuration.
  36. //
  37. // Upon successful completion, *pCount will be set to the number of Certificate
  38. // Authority configurations listed in the configuration file.
  39. //
  40. // Returns S_FALSE if no entries are available at or after the passed Index.
  41. // Returns S_OK on success.
  42. //+--------------------------------------------------------------------------
  43. STDMETHODIMP
  44. CCertConfig::Reset(
  45. /* [in] */ LONG Index,
  46. /* [retval][out] */ LONG __RPC_FAR *pCount)
  47. {
  48. HRESULT hr;
  49. hr = CCertConfigPrivate::Reset(Index, pCount);
  50. return(_SetErrorInfo(hr, L"CCertConfig::Reset"));
  51. }
  52. //+--------------------------------------------------------------------------
  53. // CCertConfig::Next -- skip to next config entry
  54. //
  55. // Changes the current config entry to the next Certification Authority
  56. // configuration listed in the configuration file.
  57. //
  58. // Upon successful completion, *pIndex will be set to the index of Certificate
  59. // Authority configurations listed in the configuration file.
  60. //
  61. // Returns S_FALSE if no more entries are available. *pIndex is set to -1.
  62. // Returns S_OK on success. *pIndex is set to index the current configuration.
  63. //+--------------------------------------------------------------------------
  64. STDMETHODIMP
  65. CCertConfig::Next(
  66. /* [retval][out] */ LONG __RPC_FAR *pIndex)
  67. {
  68. HRESULT hr;
  69. hr = CCertConfigPrivate::Next(pIndex);
  70. return(_SetErrorInfo(hr, L"CCertConfig::Next"));
  71. }
  72. //+--------------------------------------------------------------------------
  73. // CCertConfig::GetField -- return a field from the current config entry.
  74. //
  75. // pstrOut points to a BSTR string filled in by this routine. If *pstrOut is
  76. // non-NULL and this method is successful, the old string is freed. If any
  77. // value other than S_OK is returned, the string pointer will not be modified.
  78. //
  79. // Upon successful completion, *pstrOut will point to a string that contains
  80. // the requested field from the current config entry.
  81. //
  82. // When the caller no longer needs the string, it must be freed by calling
  83. // SysFreeString().
  84. //
  85. // Returns S_OK on success.
  86. //+--------------------------------------------------------------------------
  87. STDMETHODIMP
  88. CCertConfig::GetField(
  89. /* [in] */ BSTR const strFieldName,
  90. /* [retval][out] */ BSTR __RPC_FAR *pstrOut)
  91. {
  92. HRESULT hr;
  93. hr = CCertConfigPrivate::GetField(strFieldName, pstrOut);
  94. return(_SetErrorInfo(hr, L"CCertConfig::GetField"));
  95. }
  96. //+--------------------------------------------------------------------------
  97. // CCertConfig::GetConfig -- select a certificate issuer, return config data.
  98. //
  99. // pstrOut points to a BSTR string filled in by this routine. If *pstrOut is
  100. // non-NULL and this method is successful, the old string is freed. If any
  101. // value other than S_OK is returned, the string pointer will not be modified.
  102. //
  103. // Flags must be set to 0.
  104. //
  105. // Upon successful completion, *pstrOut will point to a string that contains
  106. // the server name and Certification Authority name.
  107. //
  108. // When the caller no longer needs the string, it must be freed by calling
  109. // SysFreeString().
  110. //
  111. // Returns S_OK on success.
  112. //+--------------------------------------------------------------------------
  113. STDMETHODIMP
  114. CCertConfig::GetConfig(
  115. /* [in] */ LONG Flags,
  116. /* [retval][out] */ BSTR __RPC_FAR *pstrOut)
  117. {
  118. HRESULT hr;
  119. hr = CCertConfigPrivate::GetConfig(Flags, pstrOut);
  120. return(_SetErrorInfo(hr, L"CCertConfig::GetConfig"));
  121. }
  122. //+--------------------------------------------------------------------------
  123. // CCertConfig::SetSharedFolder -- set the shared folder
  124. //
  125. // strSharedFolder is the new shared folder directory path.
  126. //
  127. // Returns S_OK on success.
  128. //+--------------------------------------------------------------------------
  129. HRESULT
  130. CCertConfig::SetSharedFolder(
  131. /* [in] */ const BSTR strSharedFolder)
  132. {
  133. HRESULT hr;
  134. hr = CCertConfigPrivate::SetSharedFolder(strSharedFolder);
  135. return(_SetErrorInfo(hr, L"CCertConfig::SetSharedFolder"));
  136. }
  137. HRESULT
  138. CCertConfig::_SetErrorInfo(
  139. IN HRESULT hrError,
  140. IN WCHAR const *pwszDescription)
  141. {
  142. CSASSERT(FAILED(hrError) || S_OK == hrError || S_FALSE == hrError);
  143. if (FAILED(hrError))
  144. {
  145. HRESULT hr;
  146. hr = DispatchSetErrorInfo(
  147. hrError,
  148. pwszDescription,
  149. wszCLASS_CERTCONFIG,
  150. &IID_ICertConfig);
  151. CSASSERT(hr == hrError);
  152. }
  153. return(hrError);
  154. }