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.

228 lines
5.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995-1996.
  5. //
  6. // File:
  7. // remact.hxx
  8. //
  9. // Contents:
  10. //
  11. // Definitions for binding handle cache to remote machines.
  12. //
  13. // History:
  14. //
  15. //--------------------------------------------------------------------------
  16. // wrapper\epts.c
  17. extern "C" {
  18. extern PROTSEQ_INFO gaProtseqInfo[];
  19. }
  20. class CRemoteMachineList;
  21. class CRemoteMachine;
  22. class CMachineBinding;
  23. extern CRemoteMachineList * gpRemoteMachineList;
  24. extern CSharedLock * gpRemoteMachineLock;
  25. const USHORT AUTHN_ANY = 0xffff;
  26. //
  27. // CRemoteMachineList
  28. //
  29. class CRemoteMachineList : public CList
  30. {
  31. public:
  32. CRemoteMachineList() :
  33. _dwCacheSize(0),
  34. _dwMaxCacheSize(gdwRemoteBindingHandleCacheMaxSize)
  35. {}
  36. CRemoteMachine* GetOrAdd(IN WCHAR * pwszMachine);
  37. HRESULT FlushSpecificBindings(WCHAR* pszMachine);
  38. void TryToFlushIdleOrTooOldElements();
  39. private:
  40. // private methods
  41. void RemoveOldestCacheElement();
  42. // private data
  43. DWORD _dwCacheSize; // count of elements in list
  44. DWORD _dwMaxCacheSize; // max size of list cache
  45. };
  46. //
  47. // CRemoteMachine
  48. //
  49. class CRemoteMachine : public CListElement
  50. {
  51. friend class CRemoteMachineList;
  52. public:
  53. CRemoteMachine( IN WCHAR * pwszMachine, IN WCHAR * pwszScmSPN );
  54. ~CRemoteMachine();
  55. ULONG AddRef();
  56. ULONG Release();
  57. HRESULT
  58. Activate(
  59. IN ACTIVATION_PARAMS * pActParams,
  60. IN WCHAR * pwszPathForServer
  61. );
  62. RPC_STATUS PickAuthnAndActivate(
  63. IN ACTIVATION_PARAMS * pActParams,
  64. IN WCHAR * pwszPathForServer,
  65. IN handle_t * pBinding,
  66. IN USHORT AuthnSvc,
  67. IN DWORD AuthnLevel,
  68. IN USHORT ProtseqId,
  69. OUT HRESULT * phr );
  70. CMachineBinding *
  71. LookupBinding(
  72. IN USHORT AuthnSvc,
  73. IN DWORD AuthnLevel,
  74. IN COAUTHINFO * pAuthInfo OPTIONAL
  75. );
  76. void
  77. InsertBinding(
  78. IN handle_t hBinding,
  79. IN USHORT ProtseqId,
  80. IN USHORT AuthnSvc,
  81. IN unsigned long ulMarshaledTargetInfoLength,
  82. IN unsigned char * pMarshaledTargetInfo,
  83. IN DWORD AuthnLevel,
  84. IN COAUTHINFO * pAuthInfo OPTIONAL
  85. );
  86. void
  87. FlushBindings();
  88. void FlushBindingsNoLock();
  89. void
  90. RemoveBinding(
  91. IN CMachineBinding * pMachineBinding
  92. );
  93. private:
  94. HRESULT
  95. GetAuthnLevel(
  96. IN ACTIVATION_PARAMS * pActParams,
  97. OUT DWORD * pdwDefaultAuthnLevel
  98. );
  99. WCHAR* _pwszMachine;
  100. WCHAR* _pwszScmSPN;
  101. CDualStringArray* _dsa;
  102. CList _BindingList;
  103. ULONG _ulRefCount;
  104. BOOL _fUseOldActivationInterface;
  105. DWORD _dwLastUsedTickCount;
  106. DWORD _dwTickCountAtCreate;
  107. };
  108. class CMachineBinding : public CListElement, public CReferencedObject
  109. {
  110. friend class CRemoteMachine;
  111. public:
  112. CMachineBinding(
  113. IN handle_t hBinding,
  114. IN USHORT ProtseqId,
  115. IN USHORT AuthnSvc,
  116. IN DWORD AuthnLevel,
  117. IN COAUTHINFO * pAuthInfo OPTIONAL
  118. );
  119. ~CMachineBinding();
  120. BOOL
  121. Equal(
  122. IN USHORT AuthnSvc,
  123. IN DWORD AuthnLevel,
  124. IN COAUTHINFO * pAuthInfo OPTIONAL
  125. );
  126. RPC_STATUS SetMarshaledTargetInfo(unsigned long ulMarshaledTargetInfoLength, unsigned char *pMarshaledTargetInfo);
  127. RPC_STATUS GetMarshaledTargetInfo(unsigned long *pulMarshaledTargetInfoLength, unsigned char **pucMarshaledTargetInfo);
  128. private:
  129. handle_t _hBinding;
  130. USHORT _ProtseqId;
  131. USHORT _AuthnSvc;
  132. DWORD _AuthnLevel;
  133. COAUTHINFO * _pAuthInfo;
  134. unsigned long _ulMarshaledTargetInfoLength;
  135. unsigned char * _pMarshaledTargetInfo;
  136. };
  137. HRESULT
  138. RemoteActivationCall(
  139. IN ACTIVATION_PARAMS * pActParams,
  140. IN WCHAR * pwszServerName
  141. );
  142. RPC_STATUS
  143. CallRemoteMachine(
  144. IN handle_t hBinding,
  145. IN USHORT ProtseqId,
  146. IN ACTIVATION_PARAMS * pActParams,
  147. IN WCHAR * pwszPathForServer,
  148. IN WCHAR * pwszMachine,
  149. IN BOOL fUseOldActivationInterface,
  150. OUT HRESULT * phr
  151. );
  152. RPC_STATUS
  153. CallNewRemoteActivation(
  154. handle_t hBinding,
  155. USHORT ProtseqId,
  156. ACTIVATION_PARAMS * pActParams,
  157. WCHAR * pwszPathForServer,
  158. WCHAR * pwszMachine,
  159. HRESULT * phr
  160. );
  161. RPC_STATUS
  162. CallOldRemoteActivation(
  163. handle_t hBinding,
  164. USHORT ProtseqId,
  165. ACTIVATION_PARAMS * pActParams,
  166. WCHAR * pwszPathForServer,
  167. WCHAR * pwszMachine,
  168. HRESULT * phr
  169. );
  170. RPC_STATUS
  171. CreateRemoteBinding(
  172. IN WCHAR * pwszMachine,
  173. IN int ProtseqIndex,
  174. OUT handle_t * phBinding
  175. );
  176. BOOL
  177. EqualAuthInfo(
  178. IN COAUTHINFO * pAuthInfo,
  179. IN COAUTHINFO * pAuthInfoOther
  180. );
  181. HRESULT
  182. CopyAuthInfo(
  183. IN COAUTHINFO * pAuthInfoSrc,
  184. IN COAUTHINFO ** ppAutInfoDest
  185. );
  186. HRESULT
  187. CopyAuthIdentity(
  188. IN COAUTHIDENTITY* pAuthIdentSrc,
  189. IN COAUTHIDENTITY** ppAuthIdentDest
  190. );