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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wishfly

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值