DSCNOBJ.CPP

// DSConnObj.cpp : Implementation of CDSConnApp and DLL registration. 

#include "stdafx.h"
#include "DSConn.h"
#include "DSCnObj.h"
#include "activeds.h"

/////////////////////////////////////////////////////////////////////////////
//

STDMETHODIMP CDsconnObject::InterfaceSupportsErrorInfo(REFIID riid)
{
static const IID* arr[] =
{
&IID_IDsconn,
};

for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
{
if (InlineIsEqualGUID(*arr[i],riid))
return S_OK;
}
return S_FALSE;
}

STDMETHODIMP CDsconnObject::get_Path (BSTR* retval)
{
if (Path != NULL)
*retval = SysAllocString(Path);
else
*retval = NULL;
return S_OK;
}

STDMETHODIMP CDsconnObject::put_Path (BSTR ObjectPath)
{
SysReAllocString(&Path, ObjectPath);
return S_OK;
}

STDMETHODIMP CDsconnObject::get_CurrentObject (IUnknown** retval)
{

HRESULT hr;

//DebugBreak();
OutputDebugString(TEXT("DS control: Object Fetched\n"));

//hr = ADsGetObject(L"WinNT:\\\\Redmond\\Jimharr",
hr = ADsGetObject(Path,
IID_IDispatch,(void **)retval);
if (SUCCEEDED(hr)) {
OutputDebugString(TEXT("DS control: Object Fetched - Returning Object\n"));
} else {
OutputDebugString(TEXT("DS control: Object Fetched - E_FAIL\n"));
return E_FAIL;
}
return S_OK;
}


STDMETHODIMP CDsconnObject::get_Object(BSTR ADsPath,
IUnknown** retval)
{
HRESULT hr;

// DebugBreak();
OutputDebugString(TEXT("DS control: Get Object\n"));

SysReAllocString(&Path,ADsPath);

hr = ADsGetObject(Path,IID_IDispatch,(void **)retval);
if (SUCCEEDED(hr)) {
OutputDebugString(TEXT("DS control: GetObject - Returning Object\n"));
} else {
OutputDebugString(TEXT("DS control: Get Object - E_FAIL\n"));
return hr;
}
return S_OK;
}