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.

210 lines
5.2 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // rasuser.cpp
  8. //
  9. // SYNOPSIS
  10. //
  11. // Define and Implement the application class for RASUser component
  12. //
  13. //////////////////////////////////////////////////////////////////////////////
  14. #include "stdafx.h"
  15. #include "resource.h"
  16. #include "initguid.h"
  17. #include "rasdial.h"
  18. #include "Dialin.h"
  19. #include "sharesdo.h"
  20. // tfscore -- for registering extension snapin
  21. #include "std.h"
  22. #include "compont.h"
  23. #include "compdata.h"
  24. #include "register.h"
  25. #include <atlimpl.cpp>
  26. #include <ntverp.h>
  27. CComModule _Module;
  28. BEGIN_OBJECT_MAP(ObjectMap)
  29. OBJECT_ENTRY(CLSID_RasDialin, CRasDialin)
  30. END_OBJECT_MAP()
  31. class CRasdialApp : public CWinApp
  32. {
  33. public:
  34. virtual BOOL InitInstance();
  35. virtual int ExitInstance();
  36. };
  37. CRasdialApp theApp;
  38. BOOL CRasdialApp::InitInstance()
  39. {
  40. _Module.Init(ObjectMap, m_hInstance);
  41. g_pSdoServerPool = NULL;
  42. return CWinApp::InitInstance();
  43. }
  44. int CRasdialApp::ExitInstance()
  45. {
  46. _Module.Term();
  47. return CWinApp::ExitInstance();
  48. }
  49. /////////////////////////////////////////////////////////////////////////////
  50. // Used to determine whether the DLL can be unloaded by OLE
  51. STDAPI DllCanUnloadNow(void)
  52. {
  53. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  54. return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
  55. }
  56. /////////////////////////////////////////////////////////////////////////////
  57. // Returns a class factory to create an object of the requested type
  58. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  59. {
  60. return _Module.GetClassObject(rclsid, riid, ppv);
  61. }
  62. /////////////////////////////////////////////////////////////////////////////
  63. // DllRegisterServer - Adds entries to the system registry
  64. /* extern */ const CLSID CLSID_LocalUser =
  65. { /* 5d6179c8-17ec-11d1-9aa9-00c04fd8fe93 */
  66. 0x5d6179c8,
  67. 0x17ec,
  68. 0x11d1,
  69. {0x9a, 0xa9, 0x00, 0xc0, 0x4f, 0xd8, 0xfe, 0x93}
  70. };
  71. /* extern */ const GUID NODETYPE_User =
  72. { /* 5d6179cc-17ec-11d1-9aa9-00c04fd8fe93 */
  73. 0x5d6179cc,
  74. 0x17ec,
  75. 0x11d1,
  76. {0x9a, 0xa9, 0x00, 0xc0, 0x4f, 0xd8, 0xfe, 0x93}
  77. };
  78. /* extern */ const GUID NODETYPE_LocalSecRootFolder =
  79. { /* 5d6179d3-17ec-11d1-9aa9-00c04fd8fe93 */
  80. 0x5d6179d3,
  81. 0x17ec,
  82. 0x11d1,
  83. {0x9a, 0xa9, 0x00, 0xc0, 0x4f, 0xd8, 0xfe, 0x93}
  84. };
  85. /* extern */ const GUID NODETYPE_DsAdminDomain =
  86. { /* 19195a5b-6da0-11d0-afd3-00c04fd930c9 */
  87. 0x19195a5b,
  88. 0x6da0,
  89. 0x11d0,
  90. {0xaf, 0xd3, 0x00, 0xc0, 0x4f, 0xd9, 0x30, 0xc9}
  91. };
  92. STDAPI DllRegisterServer(void)
  93. {
  94. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  95. // registers object, typelib and all interfaces in typelib
  96. HRESULT hr = _Module.RegisterServer(FALSE);
  97. if (FAILED(hr))
  98. {
  99. return hr;
  100. }
  101. // registers the object with Admin property page for User Object
  102. #ifdef _REGDS
  103. if(S_OK == hr)
  104. hr = CRasDialin::RegisterAdminPropertyPage(true);
  105. #endif
  106. hr = SELFREG_E_CLASS;
  107. CString strDesc;
  108. BOOL loaded = strDesc.LoadString(IDS_SNAPIN_DESC);
  109. if (!loaded)
  110. {
  111. return hr;
  112. }
  113. CString strIndirectPrefix = L"@rasuser.dll,-";
  114. CString strIndirectPostFix;
  115. wchar_t postFix[33];
  116. _ltow(IDS_SNAPIN_DESC, postFix, 10);
  117. CString strIndirect = strIndirectPrefix + postFix;
  118. // register it as extension to localsecurity snapin
  119. //
  120. hr = RegisterSnapinGUID(&CLSID_RasDialin,
  121. &CLSID_RasDialin, // fake, no about for now
  122. &CLSID_RasDialin,
  123. strDesc,
  124. LVER_PRODUCTVERSION_STR,
  125. FALSE,
  126. strIndirect
  127. );
  128. if (FAILED(hr))
  129. {
  130. return hr;
  131. }
  132. hr = RegisterAsRequiredExtensionGUID(
  133. &NODETYPE_User,
  134. &CLSID_RasDialin,
  135. strDesc,
  136. EXTENSION_TYPE_PROPERTYSHEET,
  137. NULL
  138. );
  139. if (FAILED(hr))
  140. {
  141. return hr;
  142. }
  143. hr = RegisterAsRequiredExtensionGUID(
  144. &NODETYPE_LocalSecRootFolder,
  145. &CLSID_RasDialin,
  146. strDesc,
  147. EXTENSION_TYPE_NAMESPACE,
  148. NULL
  149. );
  150. if (FAILED(hr))
  151. {
  152. return hr;
  153. }
  154. hr = RegisterAsRequiredExtensionGUID(
  155. &NODETYPE_DsAdminDomain,
  156. &CLSID_RasDialin,
  157. strDesc,
  158. EXTENSION_TYPE_NAMESPACE,
  159. NULL
  160. );
  161. return hr;
  162. }
  163. /////////////////////////////////////////////////////////////////////////////
  164. // DllUnregisterServer - Removes entries from the system registry
  165. STDAPI DllUnregisterServer(void)
  166. {
  167. // Note: on purpose, the snapin nodes are not unregistered because
  168. // they are part of the OS (dialin tab).
  169. _Module.UnregisterServer();
  170. #ifdef _REGDS
  171. if(FAILED(CRasDialin::RegisterAdminPropertyPage(false)))
  172. return SELFREG_E_CLASS;
  173. #endif
  174. return S_OK;
  175. }