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.

245 lines
9.6 KiB

  1. // Row.h : Declaration of the CRow
  2. #if (!defined(BUILD_FOR_NT40))
  3. #ifndef __ROW_H_
  4. #define __ROW_H_
  5. #define DBGUID_ROWURL {0x0C733AB6L,0x2A1C,0x11CE,{0xAD,0xE5,0x00,0xAA,0x00,0x44,0x77,0x3D}}
  6. #define NT_SEC_DESC_ATTR L"ntsecuritydescriptor"
  7. extern const OLEDBDECLSPEC DBID DBROWCOL_ROWURL = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)0};
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CRow
  10. //
  11. class ATL_NO_VTABLE CRow :
  12. INHERIT_TRACKING,
  13. public CComObjectRootEx<CComMultiThreadModel>,
  14. public CComCoClass<CRow, &CLSID_Row>,
  15. public ISupportErrorInfo,
  16. public IRow,
  17. public IColumnsInfo2,
  18. public IConvertType,
  19. public IGetSession
  20. {
  21. public:
  22. CRow()
  23. {
  24. m_pUnkMarshaler = NULL;
  25. m_pSession = NULL;
  26. m_pSourceRowset = NULL;
  27. m_hRow = DB_NULL_HROW;
  28. m_cMaxColumns = -1;
  29. m_pAttrInfo = NULL;
  30. }
  31. DECLARE_GET_CONTROLLING_UNKNOWN()
  32. BEGIN_COM_MAP(CRow)
  33. COM_INTERFACE_ENTRY(IRow)
  34. COM_INTERFACE_ENTRY(IColumnsInfo2)
  35. COM_INTERFACE_ENTRY(IColumnsInfo)
  36. COM_INTERFACE_ENTRY(IGetSession)
  37. COM_INTERFACE_ENTRY(IConvertType)
  38. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  39. END_COM_MAP()
  40. HRESULT FinalConstruct()
  41. {
  42. m_cSourceRowsetColumns = 0;
  43. m_pSourceRowsetColumnInfo = NULL;
  44. m_pSourceRowsetStringsBuffer = NULL;
  45. m_pRowProvider = NULL;
  46. RRETURN( CoCreateFreeThreadedMarshaler(
  47. GetControllingUnknown(), &m_pUnkMarshaler.p));
  48. }
  49. void FinalRelease()
  50. {
  51. //Release Free Threaded Marshaler.
  52. m_pUnkMarshaler.Release();
  53. //If this is a row in a rowset, free rowset
  54. //column info and release the row handle.
  55. if (m_pSourceRowset)
  56. {
  57. if (m_cSourceRowsetColumns)
  58. {
  59. CoTaskMemFree(m_pSourceRowsetColumnInfo);
  60. CoTaskMemFree(m_pSourceRowsetStringsBuffer);
  61. }
  62. auto_rel<IRowset> pRowset;
  63. HRESULT hr = m_pSourceRowset->QueryInterface(__uuidof(IRowset),
  64. (void **)&pRowset);
  65. if (FAILED(hr) || !pRowset)
  66. return;
  67. pRowset->ReleaseRows(1, &m_hRow, NULL, NULL, NULL);
  68. m_pRowProvider = NULL;
  69. }
  70. if(m_pAttrInfo)
  71. FreeADsMem(m_pAttrInfo);
  72. }
  73. CComPtr<IUnknown> m_pUnkMarshaler;
  74. // ISupportsErrorInfo
  75. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  76. // IRow
  77. STDMETHOD(GetColumns)(
  78. /* [in] */ DBORDINAL cColumns,
  79. /* [size_is][out][in] */ DBCOLUMNACCESS rgColumns[ ]);
  80. STDMETHOD(GetSourceRowset)(
  81. /* [in] */ REFIID riid,
  82. /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
  83. /* [out] */ HROW *phRow);
  84. STDMETHOD(Open)(
  85. /* [unique][in] */ IUnknown *pUnkOuter,
  86. /* [in] */ DBID *pColumnID,
  87. /* [in] */ REFGUID rguidColumnType,
  88. /* [in] */ DWORD dwBindFlags,
  89. /* [in] */ REFIID riid,
  90. /* [iid_is][out] */ IUnknown **ppUnk);
  91. //IColumnsInfo2 : IColumnsInfo
  92. STDMETHOD(GetColumnInfo)(
  93. /* [out][in] */ DBORDINAL *pcColumns,
  94. /* [size_is][size_is][out] */ DBCOLUMNINFO **prgInfo,
  95. /* [out] */ OLECHAR **ppStringsBuffer);
  96. STDMETHOD(MapColumnIDs)(
  97. /* [in] */ DBORDINAL cColumnIDs,
  98. /* [size_is][in] */ const DBID rgColumnIDs[ ],
  99. /* [size_is][out] */ DBORDINAL rgColumns[ ]);
  100. STDMETHOD(GetRestrictedColumnInfo)(
  101. /* [in] */ DBORDINAL cColumnIDMasks,
  102. /* [in] */ const DBID rgColumnIDMasks[ ],
  103. /* [in] */ DWORD dwFlags,
  104. /* [out][in] */ DBORDINAL *pcColumns,
  105. /* [size_is][size_is][out] */ DBID **prgColumnIDs,
  106. /* [size_is][size_is][out] */ DBCOLUMNINFO **prgColumnInfo,
  107. /* [out] */ OLECHAR **ppStringsBuffer);
  108. //IConvertType
  109. STDMETHOD(CanConvert)(
  110. /* [in] */ DBTYPE wFromType,
  111. /* [in] */ DBTYPE wToType,
  112. /* [in] */ DBCONVERTFLAGS dwConvertFlags);
  113. //IGetSession
  114. STDMETHOD(GetSession)(
  115. REFIID riid,
  116. IUnknown **ppunkSession);
  117. //Internal methods
  118. //public
  119. public:
  120. //Initializes a standalone CRow object.
  121. STDMETHOD(Initialize)( PWSTR pwszURL,
  122. IUnknown *pUnkSession,
  123. IAuthenticate* pAuthenticate,
  124. DWORD dwBindFlags,
  125. BOOL fIsTearOff,
  126. BOOL fGetColInfoFromRowset,
  127. CCredentials *pSessCreds,
  128. bool fBind = TRUE
  129. );
  130. //Initializes a CRow object that represents a Row in a Rowset.
  131. STDMETHOD(Initialize) ( PWSTR pwszURL,
  132. IUnknown* pUnkSession,
  133. IUnknown* pUnkSourceRowset,
  134. HROW hRow,
  135. PWSTR pwszUserName,
  136. PWSTR pwszPassword,
  137. DWORD dwBindFlags,
  138. BOOL fIsTearOff,
  139. BOOL fGetColInfoFromRowset,
  140. CRowProvider *pRowProvider
  141. );
  142. public:
  143. private:
  144. //Internal methods
  145. //Function to check if a given column name
  146. //matches one of the source rowset's columns.
  147. //If a match is found, it returns the index
  148. //into the source rowset column array.
  149. int IsSourceRowsetColumn(PWCHAR pwszColumnName);
  150. //Functions to check if a given column name matches
  151. //Column ID Mask criteria.
  152. bool fMatchesMaskCriteria(PWCHAR pwszColumnName,
  153. ULONG cColumnIDMasks,
  154. const DBID rgColumnIDMasks[ ]);
  155. bool fMatchesMaskCriteria(DBID columnid,
  156. ULONG cColumnIDMasks,
  157. const DBID rgColumnIDMasks[ ]);
  158. //Function to check if a property is multi-valued.
  159. HRESULT GetSchemaAttributes(
  160. PWCHAR pwszColumnName,
  161. VARIANT_BOOL *pfMultiValued,
  162. long *plMaxRange
  163. );
  164. //Function to get size and DBTYPE of a property
  165. HRESULT GetTypeAndSize(
  166. ADSTYPE dwADsType,
  167. CComBSTR& bstrPropName,
  168. DBTYPE* pdbType,
  169. ULONG* pulSise
  170. );
  171. //Function to get the root of schema tree eg. "LDAP://Schema"
  172. //This function gets this from m_pADsobj using ADSI functions
  173. //and stores the string in m_bstrSchemaRoot.
  174. HRESULT GetSchemaRoot();
  175. //Function to get columns from source rowset if this is a tear-off row.
  176. HRESULT GetSourceRowsetColumns(
  177. ULONG cColumns,
  178. DBCOLUMNACCESS rgColumns[ ],
  179. ULONG *pcErrors
  180. );
  181. //Function to get the status from HRESULT
  182. DBSTATUS StatusFromHRESULT(HRESULT hr);
  183. HRESULT GetSecurityDescriptor(DBCOLUMNACCESS *pColumn,
  184. BOOL fMultiValued);
  185. int IgnorecbMaxLen(DBTYPE wType);
  186. auto_rel<IADs> m_pADsObj;
  187. CCredentials m_objCredentials;
  188. CComBSTR m_objURL;
  189. CComBSTR m_bstrSchemaRoot;
  190. auto_cs m_autocs;
  191. auto_rel<IUnknown> m_pSession;
  192. auto_rel<IUnknown> m_pSourceRowset;
  193. HROW m_hRow;
  194. DWORD m_dwBindFlags;
  195. DBORDINAL m_cSourceRowsetColumns;
  196. DBCOLUMNINFO *m_pSourceRowsetColumnInfo;
  197. OLECHAR *m_pSourceRowsetStringsBuffer;
  198. CRowProvider *m_pRowProvider;
  199. BOOL m_fIsTearOff;
  200. BOOL m_fGetColInfoFromRowset;
  201. PADS_ATTR_INFO m_pAttrInfo;
  202. LONG m_cMaxColumns;
  203. };
  204. #endif //__ROW_H_
  205. #endif