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.

286 lines
6.2 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows, Copyright (C) Microsoft Corporation, 2000
  3. File: Settings.cpp
  4. Contents: Implementation of CSettings class.
  5. Remarks:
  6. History: 11-15-99 dsie created
  7. ------------------------------------------------------------------------------*/
  8. #include "StdAfx.h"
  9. #include "CAPICOM.h"
  10. #include "Settings.h"
  11. ///////////////
  12. //
  13. // Global
  14. //
  15. VARIANT_BOOL g_bPromptCertificateUI = VARIANT_TRUE;
  16. CAPICOM_ACTIVE_DIRECTORY_SEARCH_LOCATION g_ADSearchLocation = CAPICOM_SEARCH_ANY;
  17. ////////////////////////////////////////////////////////////////////////////////
  18. //
  19. // CSettings
  20. //
  21. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  22. Function : CSettings::get_EnablePromptForCertificateUI
  23. Synopsis : Get current EnablePromptForCertificateUI setting.
  24. Parameter: VARIANT_BOOL * pVal - Pointer to VARIANT_BOOL to receive result.
  25. Remark :
  26. ------------------------------------------------------------------------------*/
  27. STDMETHODIMP CSettings::get_EnablePromptForCertificateUI (VARIANT_BOOL * pVal)
  28. {
  29. HRESULT hr = S_OK;
  30. DebugTrace("Entering CSettings::get_EnablePromptForCertificateUI().\n");
  31. try
  32. {
  33. //
  34. // Lock access to this object.
  35. //
  36. m_Lock.Lock();
  37. //
  38. // Check parameters.
  39. //
  40. if (NULL == pVal)
  41. {
  42. hr = E_INVALIDARG;
  43. DebugTrace("Error [%#x]: Parameter pVal is NULL.\n", hr);
  44. goto ErrorExit;
  45. }
  46. //
  47. // Return it.
  48. //
  49. *pVal = g_bPromptCertificateUI;
  50. }
  51. catch(...)
  52. {
  53. hr = E_POINTER;
  54. DebugTrace("Exception: invalid parameter.\n");
  55. goto ErrorExit;
  56. }
  57. UnlockExit:
  58. //
  59. // Unlock access to this object.
  60. //
  61. m_Lock.Unlock();
  62. DebugTrace("Leaving CSettings::get_EnablePromptForCertificateUI().\n");
  63. return hr;
  64. ErrorExit:
  65. //
  66. // Sanity check.
  67. //
  68. ATLASSERT(FAILED(hr));
  69. ReportError(hr);
  70. goto UnlockExit;
  71. }
  72. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  73. Function : CSettings::put_EnablePromptForCertificateUI
  74. Synopsis : Set EnablePromptForCertificateUI setting.
  75. Parameter: VARIANT_BOOL newVal - VARIANT_TRUE to enable UI or VARAINT_FALSE
  76. to disable.
  77. Remark :
  78. ------------------------------------------------------------------------------*/
  79. STDMETHODIMP CSettings::put_EnablePromptForCertificateUI (VARIANT_BOOL newVal)
  80. {
  81. HRESULT hr = S_OK;
  82. DebugTrace("Entering CSettings::put_EnablePromptForCertificateUI().\n");
  83. //
  84. // Lock access to this object.
  85. //
  86. m_Lock.Lock();
  87. //
  88. // Set it.
  89. //
  90. g_bPromptCertificateUI = newVal ? VARIANT_TRUE : VARIANT_FALSE;
  91. //
  92. // Unlock access to this object.
  93. //
  94. m_Lock.Unlock();
  95. DebugTrace("Leaving CSettings::put_EnablePromptForCertificateUI().\n");
  96. return hr;
  97. }
  98. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  99. Function : CSettings::get_ActiveDirectorySearchLocation
  100. Synopsis : Get current ActiveDirectorySearchLocation setting.
  101. Parameter: CAPICOM_ACTIVE_DIRECTORY_SEARCH_LOCATION * pVal - Pointer to variable
  102. to receive result.
  103. Remark :
  104. ------------------------------------------------------------------------------*/
  105. STDMETHODIMP CSettings::get_ActiveDirectorySearchLocation (
  106. CAPICOM_ACTIVE_DIRECTORY_SEARCH_LOCATION * pVal)
  107. {
  108. HRESULT hr = S_OK;
  109. DebugTrace("Entering CSettings::get_ActiveDirectorySearchLocation().\n");
  110. //
  111. // Lock access to this object.
  112. //
  113. m_Lock.Lock();
  114. try
  115. {
  116. //
  117. // Check parameters.
  118. //
  119. if (NULL == pVal)
  120. {
  121. hr = E_INVALIDARG;
  122. DebugTrace("Error [%#x]: Parameter pVal is NULL.\n", hr);
  123. goto ErrorExit;
  124. }
  125. //
  126. // Return it.
  127. //
  128. *pVal = g_ADSearchLocation;
  129. }
  130. catch(...)
  131. {
  132. hr = E_POINTER;
  133. DebugTrace("Exception: invalid parameter.\n");
  134. goto ErrorExit;
  135. }
  136. UnlockExit:
  137. //
  138. // Unlock access to this object.
  139. //
  140. m_Lock.Unlock();
  141. DebugTrace("Leaving CSettings::get_ActiveDirectorySearchLocation().\n");
  142. return hr;
  143. ErrorExit:
  144. //
  145. // Sanity check.
  146. //
  147. ATLASSERT(FAILED(hr));
  148. ReportError(hr);
  149. goto UnlockExit;
  150. }
  151. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  152. Function : CSettings::put_ActiveDirectorySearchLocation
  153. Synopsis : Set ActiveDirectorySearchLocation setting.
  154. Parameter: CAPICOM_ACTIVE_DIRECTORY_SEARCH_LOCATION newVal - AD search location.
  155. Remark :
  156. ------------------------------------------------------------------------------*/
  157. STDMETHODIMP CSettings::put_ActiveDirectorySearchLocation (
  158. CAPICOM_ACTIVE_DIRECTORY_SEARCH_LOCATION newVal)
  159. {
  160. HRESULT hr = S_OK;
  161. DebugTrace("Entering CSettings::put_ActiveDirectorySearchLocation().\n");
  162. //
  163. // Lock access to this object.
  164. //
  165. m_Lock.Lock();
  166. //
  167. // Make sure parameter is valid.
  168. //
  169. switch (newVal)
  170. {
  171. case CAPICOM_SEARCH_ANY:
  172. case CAPICOM_SEARCH_GLOBAL_CATALOG:
  173. case CAPICOM_SEARCH_DEFAULT_DOMAIN:
  174. {
  175. break;
  176. }
  177. default:
  178. {
  179. hr = E_INVALIDARG;
  180. DebugTrace("Error [%#x]: Unknown search location (%#x).\n", hr, newVal);
  181. goto ErrorExit;
  182. }
  183. }
  184. //
  185. // Set it.
  186. //
  187. g_ADSearchLocation = newVal;
  188. UnlockExit:
  189. //
  190. // Unlock access to this object.
  191. //
  192. m_Lock.Unlock();
  193. DebugTrace("Leaving CSettings::put_ActiveDirectorySearchLocation().\n");
  194. return hr;
  195. ErrorExit:
  196. //
  197. // Sanity check.
  198. //
  199. ATLASSERT(FAILED(hr));
  200. ReportError(hr);
  201. goto UnlockExit;
  202. }