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.

186 lines
5.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: session.hxx
  7. //
  8. // Contents: TSession interfaces.
  9. //
  10. // History: 3-30-97 MohamedN Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #pragma once
  14. #include "datasrc.hxx"
  15. #include <impiunk.hxx>
  16. #include <mparser.h>
  17. //+---------------------------------------------------------------------------
  18. //
  19. // Class: CDBSession
  20. //
  21. // Purpose: exposes ole-db session interfaces.
  22. //
  23. // History: 3-30-97 MohamedN Created
  24. //
  25. // Notes:
  26. //
  27. //----------------------------------------------------------------------------
  28. class CDBSession : public IOpenRowset,
  29. public IGetDataSource,
  30. public ISessionProperties,
  31. public IDBCreateCommand
  32. {
  33. public:
  34. CDBSession( CDataSrc & dataSrc,
  35. IUnknown * pUnkOuter,
  36. IUnknown ** ppUnkInner,
  37. IParserSession* pIPSession,
  38. HANDLE hToken );
  39. ~CDBSession(void);
  40. //
  41. // IUnknown methods
  42. //
  43. STDMETHOD(QueryInterface) ( THIS_ REFIID riid, LPVOID *ppiuk )
  44. {
  45. // Delegate to outer unknown if aggregated
  46. return _pUnkOuter->QueryInterface( riid, ppiuk );
  47. }
  48. STDMETHOD(RealQueryInterface) (THIS_ REFIID riid, LPVOID *ppiuk );
  49. STDMETHOD_(ULONG, AddRef) (THIS) { return _pUnkOuter->AddRef(); }
  50. STDMETHOD_(ULONG, Release) (THIS) { return _pUnkOuter->Release(); }
  51. //
  52. // IGetDataSource methods
  53. //
  54. STDMETHOD (GetDataSource) (THIS_ REFIID riid, IUnknown **ppDataSource );
  55. //
  56. // ISessionProperties methods
  57. //
  58. STDMETHOD (GetProperties) (THIS_
  59. ULONG cPropertySets,
  60. const DBPROPIDSET rgPropertySets[],
  61. ULONG* pcProperties,
  62. DBPROPSET** prgProperties);
  63. STDMETHOD (SetProperties) (THIS_
  64. ULONG cProperties,
  65. DBPROPSET rgProperties[]);
  66. //
  67. // ICreateCommand methods
  68. //
  69. STDMETHOD (CreateCommand) (THIS_ IUnknown*, REFIID, IUnknown **);
  70. //
  71. // IOpenRowset methods
  72. //
  73. STDMETHODIMP OpenRowset (IUnknown * pUnkOuter,
  74. DBID * pTableID,
  75. DBID * pIndexID,
  76. REFIID riid,
  77. ULONG cPropertySets,
  78. DBPROPSET rgPropertySets[],
  79. IUnknown ** ppRowset);
  80. //
  81. // Access Functions
  82. //
  83. IParserSession * GetParserSession() { return _xIPSession.GetPointer(); }
  84. CDataSrc * GetDataSrcPtr() { return &_dataSrc; }
  85. IUnknown * GetOuterUnk() { return _pUnkOuter; }
  86. HANDLE GetLogonToken() { return _xSessionToken.Get(); }
  87. private:
  88. LPUNKNOWN _pUnkOuter;
  89. CImpIUnknown<CDBSession> _impIUnknown;
  90. CDataSrc & _dataSrc;
  91. CMutexSem _mtxSess;
  92. CMSessProps _UtlProps;
  93. //
  94. // SQL Text Parser support
  95. //
  96. XInterface<IParserSession> _xIPSession;
  97. //
  98. // IOpenRowset helper
  99. //
  100. static SCODE SetOpenRowsetProperties(
  101. ICommandText* pICmdText,
  102. ULONG cPropertySets,
  103. DBPROPSET rgPropertySets[]);
  104. static SCODE MarkOpenRowsetProperties(
  105. ICommandText* pICmdText,
  106. ULONG cPropertySets,
  107. DBPROPSET rgPropertySets[]
  108. );
  109. static void MarkPropInError(
  110. ULONG cPropertySets,
  111. DBPROPSET * rgPropertySets,
  112. GUID * pguidPropSet,
  113. DBPROP * pProp );
  114. //
  115. // ISupportErrorInfo
  116. //
  117. CCIOleDBError _ErrorInfo;
  118. SHandle _xSessionToken;
  119. };
  120. //+---------------------------------------------------------------------------
  121. //
  122. // Class: CImpersonateSessionUser
  123. //
  124. // Purpose:
  125. //
  126. // History: 01-24-99 danleg Created
  127. //
  128. // Notes:
  129. //
  130. //----------------------------------------------------------------------------
  131. class CImpersonateSessionUser
  132. {
  133. public:
  134. CImpersonateSessionUser( HANDLE hToken = INVALID_HANDLE_VALUE );
  135. ~CImpersonateSessionUser();
  136. void Revert();
  137. private:
  138. void CachePrevToken();
  139. void Impersonate();
  140. HANDLE DupToken( HANDLE hToken );
  141. BOOL _fImpersonated;
  142. SHandle _xPrevToken;
  143. SHandle _xSessionToken;
  144. };