|
|
//---------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1992 - 1995
//
// File: cgroup.cxx
//
// Contents: Group object
//
// History: 11-1-95 krishnag Created.
//
//----------------------------------------------------------------------------
#include "procs.hxx"
#pragma hdrstop
#include "winnt.hxx"
// Class CWinNTLocalGroupCollection
DEFINE_IDispatch_Implementation(CWinNTLocalGroupCollection)
CWinNTLocalGroupCollection::CWinNTLocalGroupCollection(): _ParentType(0), _DomainName(NULL), _ServerName(NULL), _lpServerName(NULL), _pDispMgr(NULL) { VariantInit(&_vFilter); ENLIST_TRACKING(CWinNTLocalGroupCollection); }
HRESULT CWinNTLocalGroupCollection::CreateGroupCollection( BSTR Parent, ULONG ParentType, BSTR DomainName, BSTR ServerName, BSTR GroupName, ULONG GroupType, REFIID riid, CWinNTCredentials& Credentials, void **ppvObj ) { CWinNTLocalGroupCollection FAR * pGroup = NULL; HRESULT hr = S_OK;
hr = AllocateGroupCollectionObject(&pGroup); BAIL_ON_FAILURE(hr);
hr = pGroup->InitializeCoreObject( Parent, GroupName, LOCALGROUP_CLASS_NAME, NULL, CLSID_WinNTGroup, ADS_OBJECT_UNBOUND ); BAIL_ON_FAILURE(hr);
hr = ADsAllocString( DomainName, &pGroup->_DomainName); BAIL_ON_FAILURE(hr);
hr = ADsAllocString( ServerName, &pGroup->_ServerName); BAIL_ON_FAILURE(hr);
pGroup->_ParentType = ParentType; pGroup->_GroupType = GroupType;
pGroup->_Credentials = Credentials; hr = pGroup->_Credentials.Ref(ServerName, DomainName, ParentType); BAIL_ON_FAILURE(hr);
hr = pGroup->QueryInterface(riid, ppvObj); BAIL_ON_FAILURE(hr);
pGroup->Release(); RRETURN(hr);
error: delete pGroup;
RRETURN_EXP_IF_ERR(hr);
}
CWinNTLocalGroupCollection::~CWinNTLocalGroupCollection( ) { VariantClear( &_vFilter);
if(_DomainName) { ADsFreeString(_DomainName); }
if(_ServerName) { ADsFreeString(_ServerName); }
delete _pDispMgr; }
STDMETHODIMP CWinNTLocalGroupCollection::QueryInterface( REFIID iid, LPVOID FAR* ppv ) { if (ppv == NULL) { RRETURN(E_POINTER); }
if (IsEqualIID(iid, IID_IUnknown)) { *ppv = (IADsMembers FAR *) this; } else if (IsEqualIID(iid, IID_IADsMembers)) { *ppv = (IADsMembers FAR *) this; } else if (IsEqualIID(iid, IID_IDispatch)) { *ppv = (IADsMembers FAR *) this; } else if (IsEqualIID(iid, IID_ISupportErrorInfo)) { *ppv = (ISupportErrorInfo FAR *) this; } else { *ppv = NULL; return E_NOINTERFACE; } AddRef(); return NOERROR; }
STDMETHODIMP CWinNTLocalGroupCollection::InterfaceSupportsErrorInfo( THIS_ REFIID riid ) { if (IsEqualIID(riid, IID_IADsMembers)) { RRETURN(S_OK); } else { RRETURN(S_FALSE); } }
STDMETHODIMP CWinNTLocalGroupCollection::get_Count(long FAR* retval) { RRETURN_EXP_IF_ERR(E_NOTIMPL); }
STDMETHODIMP CWinNTLocalGroupCollection::get_Filter(THIS_ VARIANT FAR* pVar) { HRESULT hr; VariantInit(pVar); hr = VariantCopy(pVar, &_vFilter); RRETURN_EXP_IF_ERR(hr); }
STDMETHODIMP CWinNTLocalGroupCollection::put_Filter(THIS_ VARIANT Var) { HRESULT hr; hr = VariantCopy(&_vFilter, &Var); RRETURN_EXP_IF_ERR(hr); }
STDMETHODIMP CWinNTLocalGroupCollection::get__NewEnum( THIS_ IUnknown * FAR* retval ) { HRESULT hr; IUnknown FAR* punkEnum=NULL; IEnumVARIANT * penum = NULL;
*retval = NULL;
hr = CWinNTLocalGroupCollectionEnum::Create( (CWinNTLocalGroupCollectionEnum **)&penum, _Parent, _ParentType, _ADsPath, _DomainName, _ServerName, _Name, _GroupType, _vFilter, _Credentials ); BAIL_ON_FAILURE(hr);
hr = penum->QueryInterface( IID_IUnknown, (VOID FAR* FAR*)retval ); BAIL_ON_FAILURE(hr);
if (penum) { penum->Release(); }
RRETURN(NOERROR);
error:
if (penum) { delete penum; }
RRETURN_EXP_IF_ERR(hr); }
HRESULT CWinNTLocalGroupCollection::AllocateGroupCollectionObject( CWinNTLocalGroupCollection ** ppGroup ) { CWinNTLocalGroupCollection FAR * pGroup = NULL; CAggregatorDispMgr FAR * pDispMgr = NULL; HRESULT hr = S_OK;
pGroup = new CWinNTLocalGroupCollection(); if (pGroup == NULL) { hr = E_OUTOFMEMORY; } BAIL_ON_FAILURE(hr);
pDispMgr = new CAggregatorDispMgr; if (pDispMgr == NULL) { hr = E_OUTOFMEMORY; } BAIL_ON_FAILURE(hr);
hr = LoadTypeInfoEntry(pDispMgr, LIBID_ADs, IID_IADsMembers, (IADsMembers *)pGroup, DISPID_NEWENUM ); BAIL_ON_FAILURE(hr);
pGroup->_pDispMgr = pDispMgr; *ppGroup = pGroup;
RRETURN(hr);
error: delete pDispMgr;
RRETURN(hr);
}
|