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.

175 lines
5.9 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. AccountsLib.h
  5. Abstract:
  6. This file contains the declaration of the classes responsible for managing
  7. user and group accounts.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 03/26/2000
  10. created
  11. ******************************************************************************/
  12. #if !defined(__INCLUDED___PCH___ACCOUNTSLIB_H___)
  13. #define __INCLUDED___PCH___ACCOUNTSLIB_H___
  14. ////////////////////////////////////////////////////////////////////////////////
  15. #include <MPC_config.h>
  16. //
  17. // From HelpServiceTypeLib.idl
  18. //
  19. #include <HelpServiceTypeLib.h>
  20. #include <TrustedScripts.h>
  21. ////////////////////////////////////////////////////////////////////////////////
  22. class CPCHAccounts
  23. {
  24. void CleanUp();
  25. public:
  26. CPCHAccounts();
  27. ~CPCHAccounts();
  28. HRESULT CreateGroup( /*[in]*/ LPCWSTR szGroup, /*[in]*/ LPCWSTR szComment = NULL );
  29. HRESULT CreateUser ( /*[in]*/ LPCWSTR szUser , /*[in]*/ LPCWSTR szPassword, /*[in]*/ LPCWSTR szFullName = NULL, /*[in]*/ LPCWSTR szComment = NULL );
  30. HRESULT DeleteGroup( /*[in]*/ LPCWSTR szGroup );
  31. HRESULT DeleteUser ( /*[in]*/ LPCWSTR szUser );
  32. HRESULT ChangeUserStatus( /*[in]*/ LPCWSTR szUser, /*[in]*/ bool fEnable );
  33. HRESULT LogonUser( /*[in]*/ LPCWSTR szUser, /*[in]*/ LPCWSTR szPassword, /*[out]*/ HANDLE& hToken );
  34. };
  35. ////////////////////////////////////////////////////////////////////////////////
  36. class CPCHUserProcess : public CComObjectRootEx<MPC::CComSafeMultiThreadModel> // Just to have locking...
  37. {
  38. public:
  39. class UserEntry
  40. {
  41. friend class CPCHUserProcess;
  42. CComBSTR m_bstrUser; // Account associated with the vendor.
  43. DWORD m_dwSessionID; // Terminal Server session.
  44. CComBSTR m_bstrVendorID; // ID of the vendor.
  45. CComBSTR m_bstrPublicKey; // Text representation of the vendor's public key.
  46. GUID m_guid; // Used for establishing the connection.
  47. CComPtr<IPCHSlaveProcess> m_spConnection; // Live object.
  48. HANDLE m_hToken; // User token.
  49. HANDLE m_hProcess; // Process handle.
  50. HANDLE* m_phEvent; // To notify activator.
  51. ////////////////////
  52. void Cleanup();
  53. HRESULT Clone ( /*[in ]*/ const UserEntry& ue );
  54. HRESULT Connect ( /*[out]*/ HANDLE& hEvent );
  55. HRESULT SendActivation( /*[out]*/ HANDLE& hEvent );
  56. private: // Disable copy operations.
  57. UserEntry( /*[in]*/ const UserEntry& ue );
  58. UserEntry& operator=( /*[in]*/ const UserEntry& ue );
  59. public:
  60. UserEntry();
  61. ~UserEntry();
  62. ////////////////////
  63. bool operator==( /*[in]*/ const UserEntry& ue ) const;
  64. bool operator==( /*[in]*/ const GUID& guid ) const;
  65. HRESULT InitializeForVendorAccount( /*[in]*/ BSTR bstrUser, /*[in]*/ BSTR bstrVendorID, /*[in]*/ BSTR bstrPublicKey );
  66. HRESULT InitializeForImpersonation( /*[in]*/ HANDLE hToken = NULL );
  67. const CComBSTR& GetPublicKey() { return m_bstrPublicKey; }
  68. };
  69. private:
  70. typedef std::list< UserEntry* > List;
  71. typedef List::iterator Iter;
  72. typedef List::const_iterator IterConst;
  73. ////////////////////////////////////////
  74. List m_lst;
  75. void Shutdown();
  76. UserEntry* Lookup( /*[in]*/ const UserEntry& ue, /*[in]*/ bool fRelease );
  77. public:
  78. CPCHUserProcess();
  79. ~CPCHUserProcess();
  80. ////////////////////////////////////////////////////////////////////////////////
  81. static CPCHUserProcess* s_GLOBAL;
  82. static HRESULT InitializeSystem();
  83. static void FinalizeSystem ();
  84. ////////////////////////////////////////////////////////////////////////////////
  85. HRESULT Remove ( /*[in]*/ const UserEntry& ue );
  86. HRESULT Connect( /*[in]*/ const UserEntry& ue, /*[out]*/ IPCHSlaveProcess* *spConnection );
  87. HRESULT RegisterHost( /*[in]*/ BSTR bstrID, /*[in]*/ IPCHSlaveProcess* pObj );
  88. //
  89. // Static method to handle communication between slave and master.
  90. //
  91. static HRESULT SendResponse( /*[in]*/ DWORD dwArgc, /*[in]*/ LPCWSTR* lpszArgv );
  92. };
  93. ////////////////////////////////////////////////////////////////////////////////
  94. class ATL_NO_VTABLE CPCHSlaveProcess : // Hungarian: pchsd
  95. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  96. public IDispatchImpl< IPCHSlaveProcess, &IID_IPCHSlaveProcess, &LIBID_HelpServiceTypeLib >
  97. {
  98. CComBSTR m_bstrVendorID;
  99. CComBSTR m_bstrPublicKey;
  100. CPCHScriptWrapper_Launcher* m_ScriptLauncher;
  101. public:
  102. BEGIN_COM_MAP(CPCHSlaveProcess)
  103. COM_INTERFACE_ENTRY(IDispatch)
  104. COM_INTERFACE_ENTRY(IPCHSlaveProcess)
  105. END_COM_MAP()
  106. CPCHSlaveProcess();
  107. virtual ~CPCHSlaveProcess();
  108. public:
  109. // IPCHSlaveProcess
  110. STDMETHOD(Initialize)( /*[in]*/ BSTR bstrVendorID, /*[in]*/ BSTR bstrPublicKey );
  111. STDMETHOD(CreateInstance)( /*[in]*/ REFCLSID rclsid, /*[in]*/ IUnknown* pUnkOuter, /*[out]*/ IUnknown* *ppvObject );
  112. STDMETHOD(CreateScriptWrapper)( /*[in]*/ REFCLSID rclsid, /*[in]*/ BSTR bstrCode, /*[in]*/ BSTR bstrURL, /*[out]*/ IUnknown* *ppvObject );
  113. STDMETHOD(OpenBlockingStream)( /*[in]*/ BSTR bstrURL, /*[out]*/ IUnknown* *ppvObject );
  114. STDMETHOD(IsNetworkAlive)( /*[out]*/ VARIANT_BOOL* pfRetVal );
  115. STDMETHOD(IsDestinationReachable)( /*[in]*/ BSTR bstrDestination, /*[out]*/ VARIANT_BOOL *pvbVar );
  116. };
  117. ////////////////////////////////////////////////////////////////////////////////
  118. #endif // !defined(__INCLUDED___PCH___ACCOUNTSLIB_H___)