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.

250 lines
7.2 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. /*++
  3. Copyright (C) Microsoft Corporation
  4. Module Name: rapwz_profile.cpp
  5. Abstract:
  6. Implementation file for the CNewRAPWiz_EditProfile class.
  7. We implement the class needed to handle the first property page for a Policy node.
  8. Revision History:
  9. mmaguire 12/15/97 - created
  10. byao 1/22/98 Modified for Network Access Policy
  11. --*/
  12. //////////////////////////////////////////////////////////////////////////////
  13. #include "Precompiled.h"
  14. #include "rapwz_profile.h"
  15. #include "NapUtil.h"
  16. #include "PolicyNode.h"
  17. #include "PoliciesNode.h"
  18. #include "rasprof.h"
  19. #include "ChangeNotification.h"
  20. //+---------------------------------------------------------------------------
  21. //
  22. // Function: CNewRAPWiz_EditProfile
  23. //
  24. // Class: CNewRAPWiz_EditProfile
  25. //
  26. // Synopsis: class constructor
  27. //
  28. // Arguments: CPolicyNode *pPolicyNode - policy node for this property page
  29. // CIASAttrList *pAttrList -- attribute list
  30. // TCHAR* pTitle = NULL -
  31. //
  32. // Returns: Nothing
  33. //
  34. // History: Created Header byao 2/16/98 4:31:52 PM
  35. //
  36. //+---------------------------------------------------------------------------
  37. CNewRAPWiz_EditProfile::CNewRAPWiz_EditProfile(
  38. CRapWizardData* pWizData,
  39. LONG_PTR hNotificationHandle,
  40. CIASAttrList *pIASAttrList,
  41. TCHAR* pTitle, BOOL bOwnsNotificationHandle,
  42. bool isWin2k
  43. )
  44. : CIASWizard97Page<CNewRAPWiz_EditProfile, IDS_NEWRAPWIZ_EDITPROFILE_TITLE, IDS_NEWRAPWIZ_EDITPROFILE_SUBTITLE> ( hNotificationHandle, pTitle, bOwnsNotificationHandle ),
  45. m_spWizData(pWizData),
  46. m_isWin2k(isWin2k)
  47. {
  48. TRACE_FUNCTION("CNewRAPWiz_EditProfile::CNewRAPWiz_EditProfile");
  49. m_pIASAttrList = pIASAttrList;
  50. }
  51. //+---------------------------------------------------------------------------
  52. //
  53. // Function: CNewRAPWiz_EditProfile
  54. //
  55. // Class: CNewRAPWiz_EditProfile
  56. //
  57. // Synopsis: class destructor
  58. //
  59. // Returns: Nothing
  60. //
  61. // History: Created Header byao 2/16/98 4:31:52 PM
  62. //
  63. //+---------------------------------------------------------------------------
  64. CNewRAPWiz_EditProfile::~CNewRAPWiz_EditProfile()
  65. {
  66. TRACE_FUNCTION("CNewRAPWiz_EditProfile::~CNewRAPWiz_EditProfile");
  67. }
  68. //////////////////////////////////////////////////////////////////////////////
  69. /*++
  70. CNewRAPWiz_EditProfile::OnInitDialog
  71. --*/
  72. //////////////////////////////////////////////////////////////////////////////
  73. LRESULT CNewRAPWiz_EditProfile::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  74. {
  75. TRACE_FUNCTION("CNewRAPWiz_EditProfile::OnInitDialog");
  76. HRESULT hr = S_OK;
  77. BOOL fRet;
  78. CComPtr<IUnknown> spUnknown;
  79. CComPtr<IEnumVARIANT> spEnumVariant;
  80. long ulCount;
  81. ULONG ulCountReceived;
  82. SetModified(FALSE);
  83. return TRUE; // ISSUE: what do we need to be returning here?
  84. }
  85. //////////////////////////////////////////////////////////////////////////////
  86. /*++
  87. CNewRAPWiz_EditProfile::OnWizardFinish
  88. --*/
  89. //////////////////////////////////////////////////////////////////////////////
  90. BOOL CNewRAPWiz_EditProfile::OnWizardNext()
  91. {
  92. // reset the dirty bit
  93. SetModified(FALSE);
  94. return m_spWizData->GetNextPageId(((PROPSHEETPAGE*)(*this))->pszTemplate);
  95. }
  96. //////////////////////////////////////////////////////////////////////////////
  97. /*++
  98. CNewRAPWiz_EditProfile::OnQueryCancel
  99. --*/
  100. //////////////////////////////////////////////////////////////////////////////
  101. BOOL CNewRAPWiz_EditProfile::OnQueryCancel()
  102. {
  103. TRACE_FUNCTION("CNewRAPWiz_EditProfile::OnQueryCancel");
  104. return TRUE;
  105. }
  106. //////////////////////////////////////////////////////////////////////////////
  107. /*++
  108. CNewRAPWiz_EditProfile::OnEditProfile
  109. --*/
  110. //////////////////////////////////////////////////////////////////////////////
  111. //////////
  112. // Signature of the entry point to the profile editing DLL.
  113. //////////
  114. typedef HRESULT (APIENTRY *OPENRAS_IASPROFILEDLG)(
  115. LPCWSTR pszMachineName,
  116. ISdo* pProfile, // profile SDO pointer
  117. ISdoDictionaryOld* pDictionary, // dictionary SDO pointer
  118. BOOL bReadOnly, // if the dlg is for readonly
  119. DWORD dwTabFlags, // what to show
  120. void *pvData // additional data
  121. );
  122. LRESULT CNewRAPWiz_EditProfile::OnEditProfile(UINT uMsg, WPARAM wParam, HWND hwnd, BOOL& bHandled)
  123. {
  124. TRACE_FUNCTION("CNewRAPWiz_EditProfile::OnEditProfile");
  125. OPENRAS_IASPROFILEDLG pfnProfileEditor = NULL;
  126. HRESULT hr = S_OK;
  127. HMODULE hProfileDll = NULL;
  128. hProfileDll = LoadLibrary(_T("rasuser.dll"));
  129. if ( NULL == hProfileDll )
  130. {
  131. hr = HRESULT_FROM_WIN32(GetLastError());
  132. ErrorTrace(ERROR_NAPMMC_POLICYPAGE1, "LoadLibrary() failed, err = %x", hr);
  133. ShowErrorDialog(m_hWnd, IDS_ERROR_CANT_FIND_PROFILEDLL, NULL, hr);
  134. return 0;
  135. }
  136. pfnProfileEditor = (OPENRAS_IASPROFILEDLG) GetProcAddress(hProfileDll, "OpenRAS_IASProfileDlg");
  137. if ( NULL == pfnProfileEditor )
  138. {
  139. hr = HRESULT_FROM_WIN32(GetLastError());
  140. ErrorTrace(ERROR_NAPMMC_POLICYPAGE1, "GetProcAddress() failed, err = %x", hr);
  141. ShowErrorDialog(m_hWnd, IDS_ERROR_CANT_FIND_PROFILEAPI, NULL, hr);
  142. FreeLibrary(hProfileDll);
  143. return 0;
  144. }
  145. // findout if this is extending RRAS or IAS
  146. CPoliciesNode* pPoliciesNode = dynamic_cast<CPoliciesNode*>(m_spWizData->m_pPolicyNode->m_pParentNode);
  147. DWORD dwFlags = RAS_IAS_PROFILEDLG_SHOW_IASTABS;
  148. if(pPoliciesNode != NULL)
  149. {
  150. if(!pPoliciesNode->m_fExtendingIAS)
  151. dwFlags = RAS_IAS_PROFILEDLG_SHOW_RASTABS;
  152. }
  153. if(m_isWin2k)
  154. {
  155. dwFlags |= RAS_IAS_PROFILEDLG_SHOW_WIN2K;
  156. }
  157. //
  158. // now we do have this profile sdo, call the API
  159. //
  160. hr = pfnProfileEditor(
  161. m_spWizData->m_pPolicyNode->m_pszServerAddress,
  162. m_spWizData->m_spProfileSdo,
  163. m_spWizData->m_spDictionarySdo,
  164. FALSE,
  165. dwFlags,
  166. (void *)&(m_pIASAttrList->m_AttrList)
  167. );
  168. FreeLibrary(hProfileDll);
  169. DebugTrace(DEBUG_NAPMMC_POLICYPAGE1, "OpenRAS_IASProfileDlg() returned %x", hr);
  170. if ( FAILED(hr) )
  171. {
  172. return hr;
  173. }
  174. return hr;
  175. }
  176. //////////////////////////////////////////////////////////////////////////////
  177. /*++
  178. CNewRAPWiz_EditProfile::OnSetActive
  179. Return values:
  180. TRUE if the page can be made active
  181. FALSE if the page should be be skipped and the next page should be looked at.
  182. Remarks:
  183. If you want to change which pages are visited based on a user's
  184. choices in a previous page, return FALSE here as appropriate.
  185. --*/
  186. //////////////////////////////////////////////////////////////////////////////
  187. BOOL CNewRAPWiz_EditProfile::OnSetActive()
  188. {
  189. ATLTRACE(_T("# CNewRAPWiz_EditProfile::OnSetActive\n"));
  190. // MSDN docs say you need to use PostMessage here rather than SendMessage.
  191. ::PropSheet_SetWizButtons(GetParent(), PSWIZB_BACK | PSWIZB_NEXT);
  192. return TRUE;
  193. }