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.

273 lines
6.8 KiB

  1. #include "stdafx.h"
  2. #include "objects.h"
  3. #include "maindoc.h"
  4. #include "resource.h"
  5. #include "grpcrtit.h"
  6. #include "delgrpit.h"
  7. /***********************************************************
  8. Function:
  9. Arguments:
  10. Return:
  11. Purpose:
  12. Author(s):
  13. Revision:
  14. Date:
  15. ***********************************************************/
  16. COleDsGroup::COleDsGroup( )
  17. {
  18. }
  19. /***********************************************************
  20. Function:
  21. Arguments:
  22. Return:
  23. Purpose:
  24. Author(s):
  25. Revision:
  26. Date:
  27. ***********************************************************/
  28. COleDsGroup::COleDsGroup( IUnknown *pIUnk): COleDsObject( pIUnk )
  29. {
  30. BOOL bContainer;
  31. IADsContainer* pContainer;
  32. HRESULT hResult;
  33. hResult = pIUnk->QueryInterface( IID_IADsContainer, (void**)&pContainer );
  34. bContainer = SUCCEEDED( hResult );
  35. if( SUCCEEDED( hResult ) )
  36. pContainer->Release( );
  37. m_bHasChildren = bContainer;
  38. m_bSupportAdd = bContainer;
  39. m_bSupportMove = bContainer;
  40. m_bSupportCopy = bContainer;
  41. }
  42. /***********************************************************
  43. Function:
  44. Arguments:
  45. Return:
  46. Purpose:
  47. Author(s):
  48. Revision:
  49. Date:
  50. ***********************************************************/
  51. COleDsGroup::~COleDsGroup( )
  52. {
  53. }
  54. /***********************************************************
  55. Function:
  56. Arguments:
  57. Return:
  58. Purpose:
  59. Author(s):
  60. Revision:
  61. Date:
  62. ***********************************************************/
  63. DWORD COleDsGroup::GetChildren( DWORD* pTokens,
  64. DWORD dwMaxChildren,
  65. CDialog* pQueryStatus,
  66. BOOL* pFilters,
  67. DWORD dwFilters )
  68. {
  69. HRESULT hResult;
  70. IADsGroup* pIGroup;
  71. //IOleDsGroupOperations* pIGroupOper;
  72. MEMBERS* pIMembers;
  73. if( NULL == m_pIUnk )
  74. {
  75. ASSERT( FALSE );
  76. return 0L;
  77. }
  78. hResult = m_pIUnk->QueryInterface( IID_IADsGroup, (void**) &pIGroup );
  79. if( FAILED( hResult ) )
  80. {
  81. TRACE( _T("ERROR!!! Group object does not return IID_IADsGroup interface\n") );
  82. return 0L;
  83. }
  84. COleDsObject::GetChildren( pTokens, dwMaxChildren, pQueryStatus,
  85. pFilters, dwFilters );
  86. //hResult = pIGroup->QueryInterface( IID_IADsGroupOperations, (void**)&pIGroupOper );
  87. if( SUCCEEDED( hResult ) )
  88. {
  89. hResult = pIGroup->Members( &pIMembers );
  90. if( SUCCEEDED( hResult ) )
  91. {
  92. COleDsObject::GetChildren( pIMembers );
  93. pIMembers->Release( );
  94. }
  95. else
  96. {
  97. TRACE( _T("ERROR!!! Members fails for Group object\n") );
  98. }
  99. //pIGroupOper->Release( );
  100. }
  101. else
  102. {
  103. TRACE( _T("ERROR!!! GeneralInfo fails for Group object\n") );
  104. }
  105. pIGroup->Release( );
  106. return m_dwCount;
  107. }
  108. /***********************************************************
  109. Function:
  110. Arguments:
  111. Return:
  112. Purpose:
  113. Author(s):
  114. Revision:
  115. Date:
  116. ***********************************************************/
  117. HRESULT COleDsGroup::DeleteItem ( COleDsObject* pObject )
  118. {
  119. return ContainerDeleteItem( pObject );
  120. CDeleteGroupItem aDeleteItem;
  121. BSTR bstrName;
  122. //IOleDsGroupOperations* pIGroupOperations = NULL;
  123. IADsGroup* pIGroup = NULL;
  124. HRESULT hResult;
  125. CString strFullName;
  126. CString strQualifiedName;
  127. CString strItemType;
  128. MakeQualifiedName( strQualifiedName, m_strOleDsPath, m_dwType );
  129. strFullName = pObject->GetOleDsPath( );
  130. strItemType = pObject->GetClass( );
  131. aDeleteItem.m_strItemName = strFullName;
  132. aDeleteItem.m_strParent = strQualifiedName;
  133. aDeleteItem.m_strItemType = strItemType;
  134. if( aDeleteItem.DoModal( ) != IDOK )
  135. {
  136. return E_FAIL;
  137. }
  138. while( TRUE )
  139. {
  140. hResult = m_pIUnk->QueryInterface( IID_IADsGroup,
  141. (void**)&pIGroup );
  142. ASSERT( SUCCEEDED( hResult ) );
  143. if( FAILED( hResult ) )
  144. {
  145. break;
  146. }
  147. //hResult = m_pIUnk->QueryInterface( IID_IADsGroupOperations,
  148. // (void**)&pIGroupOperations );
  149. //ASSERT( SUCCEEDED( hResult ) );
  150. //if( FAILED( hResult ) )
  151. //{
  152. // break;
  153. //}
  154. bstrName = AllocBSTR( aDeleteItem.m_strItemName.GetBuffer( 128 ) );
  155. //hResult = pIGroupOperations->Remove( bstrName );
  156. hResult = pIGroup->Remove( bstrName );
  157. SysFreeString( bstrName );
  158. break;
  159. }
  160. //if( NULL != pIGroupOperations )
  161. //{
  162. // pIGroupOperations->Release( );
  163. //}
  164. if( NULL != pIGroup )
  165. {
  166. pIGroup->Release( );
  167. }
  168. return hResult;
  169. }
  170. /***********************************************************
  171. Function:
  172. Arguments:
  173. Return:
  174. Purpose:
  175. Author(s):
  176. Revision:
  177. Date:
  178. ***********************************************************/
  179. HRESULT COleDsGroup::AddItem( )
  180. {
  181. return ContainerAddItem( );
  182. CGroupCreateItem aCreateItem;
  183. BSTR bstrName;
  184. //IOleDsGroupOperations* pIGroupOperations = NULL;
  185. IADsGroup* pIGroup = NULL;
  186. HRESULT hResult;
  187. CString strQualifiedName;
  188. MakeQualifiedName( strQualifiedName, m_strOleDsPath, m_dwType );
  189. aCreateItem.m_strParent = strQualifiedName;
  190. aCreateItem.m_strItemType = _T("NA");
  191. if( aCreateItem.DoModal( ) != IDOK )
  192. {
  193. return E_FAIL;
  194. }
  195. bstrName = AllocBSTR( aCreateItem.m_strNewItemName.GetBuffer(128) );
  196. while( TRUE )
  197. {
  198. hResult = m_pIUnk->QueryInterface( IID_IADsGroup, (void**)&pIGroup );
  199. ASSERT( SUCCEEDED( hResult ) );
  200. if( FAILED( hResult ) )
  201. {
  202. break;
  203. }
  204. //hResult = m_pIUnk->QueryInterface( IID_IADsGroupOperations, (void**)&pIGroupOperations );
  205. //ASSERT( SUCCEEDED( hResult ) );
  206. //if( FAILED( hResult ) )
  207. //{
  208. // break;
  209. //}
  210. hResult = pIGroup->Add( bstrName );
  211. break;
  212. }
  213. SysFreeString( bstrName );
  214. //if( NULL != pIGroupOperations )
  215. //{
  216. // pIGroupOperations->Release( );
  217. //}
  218. if( NULL != pIGroup )
  219. {
  220. pIGroup->Release( );
  221. }
  222. return hResult;
  223. }