how to remote connect to isa server 2000?

Bonjour,

TSw avait énoncé :
Quote:
Is there any way to bind to msfpccom (FPCDS.Root) on remote machine from c#?
On localhost Marshal.BindToMoniker("new:FPC.Root") works ok, but I was not
able to figure out how to connect to remote machine...

Someone on this forum give me tips to connect the fcp.root on a remote
machine.
Based on his code, this is how I've got it to work with VC++ 6.0 (an
VC++5.0) :
(It's part of a "work in progess" program to manage blacklists on ISA)

m_local is BOOL mapped to check box wether I'm on the ISA or on remote
machine
m_Server is a CString mapped to EditBox that contains the name of the
ISA server
The remote machine should have the ISA management tools installed, in
order to have the good entries in the register
-------------------------------------------------------
//some declarations

#include <objbase.h>
#include <atlconv.h>

#define _WIN32_WINNT 0x0400
#define UNICODE
#define INITGUID

#import "c:/program files/microsoft ISA Server/MSFPCCOM.DLL"
using namespace FPCLib;

..../...

BOOL Connected = false;
WCHAR psz[100];
HRESULT hr;
COSERVERINFO info;
MULTI_QI qis;
IFPC* pUnk = NULL;
BOOL ResultFound=false;

IFPCPtr fpcRoot;
IFPCArraysPtr fpcArrays;
IFPCArrayPtr fpcArray;
IFPCServersPtr fpcServers;
IFPCServerPtr fpcServer;
IFPCEnterprisePtr fpcEnterprise;
IFPCDestinationSetsPtr fpcDestinationSets;
IFPCDestinationSetPtr fpcDestinationSet;
IFPCDestinationPtr fpcDestination;

..../...

//Here is the connection part
void CMyDialogDlg::OnConnect()
{
// TODO: Add your control notification handler code here

USES_CONVERSION;
BeginWaitCursor();
if ( !Connected ) {

hr = CoInitializeEx(NULL,COINIT_APARTMENTTHREADED);

if (SUCCEEDED(hr)) {


wcscpy(psz,T2W((LPCTSTR)m_Server));

memset(&info, 0, sizeof(info));
info.pwszName = psz;

const IID IIDFPC = __uuidof(FPC);
const IID iid = __uuidof(IFPC);

qis.hr = 0;
qis.pIID = &iid;
qis.pItf = NULL;

////////// Using CreateInstance or CoCreateInstanceEx according to
m_Local

try {
if (!m_Local) {

CoCreateInstanceEx(IIDFPC, NULL, CLSCTX_REMOTE_SERVER, &info, 1,
&qis);

pUnk = (IFPC*)qis.pItf;
hr = qis.hr;
}else{

hr = fpcRoot.CreateInstance("FPC.Root");

}

if (FAILED (hr)){ MessageBox("Failed to connect to the specified
server") ; CoUninitialize() ; goto exit; }

if (!m_Local) fpcRoot.Attach(pUnk, true);

//At this point the fpcRoot should be a pointer on ISA COM Object
// and all functions should work

hr = fpcRoot->Refresh();

if (SUCCEEDED(hr)){

Connected = true;
FpcArrayType Type;
char ServerType[3][20] = { "Standard Edition","Stand
Alone","Array"};

hr = fpcRoot->get_Type(&Type);

fpcArrays = fpcRoot->Arrays;
short j=1;
fpcArray=fpcArrays->Item (_variant_t( j) );
fpcDestinationSets=fpcArray->PolicyElements->DestinationSets;
..../...

--------------------------
Hope it helps...

--
Alni

你可能感兴趣的:(c,server,object,null,vc++,tools)