在 Vista 中利用远程协助

发布于 2024-08-18 17:02:27 字数 255 浏览 4 评论 0原文

在 Windows XP 上,有一种已知的方法可以创建远程协助票证。

http://msdn.microsoft.com/en-us/library/ms811079。 aspx

但在 Vista 上这似乎不起作用。如何在 Vista 或 Windows 7 上执行此操作?

On Windows XP there is a known way to create a Remote Assistance Ticket.

http://msdn.microsoft.com/en-us/library/ms811079.aspx

But on Vista this does not appear to work. How does one do this on Vista or Windows 7?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

↙厌世 2024-08-25 17:02:27

事实证明有两种方法。 Microsoft API 称为 IRASrv,记录如下:

http: //msdn.microsoft.com/en-us/library/cc240176(PROT.10).aspx

另一种方法是简单地调用 msra.exe。使用密码和新手参数(例如 msra.exe /saveasfile testfile thepassword)。但是,这确实会提示用户输入密码对话框。

以下是调用 IRASrv 接口并生成远程协助连接字符串的示例代码。

COSERVERINFO            si; ::ZeroMemory( &si, sizeof( si ) );
MULTI_QI                qi; ::ZeroMemory( &qi, sizeof( qi ) );

HRESULT hr = S_OK;

BSTR bstrUserName     = SysAllocString(L"jon");
BSTR bstrDomainName   = SysAllocString(L"");
BSTR bstrPasswordStr     = SysAllocString(L"testpass");

// Get the security information entered by the user
_bstr_t bstrUser(bstrUserName);
_bstr_t bstrDomain(bstrDomainName);
_bstr_t bstrPassword(bstrPasswordStr);

// Set AuthIdentity
SEC_WINNT_AUTH_IDENTITY_W AuthIdentity = {
    (unsigned short*)bstrUserName,
    bstrUser.length(),
    (unsigned short*)bstrDomainName,
    bstrDomain.length(),
    (unsigned short*)bstrPasswordStr,
    bstrPassword.length(),
    SEC_WINNT_AUTH_IDENTITY_UNICODE 
};
COAUTHINFO AuthInfo = {
    RPC_C_AUTHN_WINNT, 
    RPC_C_AUTHZ_DEFAULT, 
    NULL, 
    RPC_C_AUTHN_LEVEL_PKT_PRIVACY,  // The authentication level used
    RPC_C_IMP_LEVEL_IMPERSONATE, 
    (COAUTHIDENTITY*)&AuthIdentity,
    EOAC_NONE 
};

si.pAuthInfo = &AuthInfo;
si.pwszName = bstrMachineName;
qi.pIID     = &(__uuidof(RAServerLib::IRASrv));

hr = ::CoCreateInstanceEx(
    __uuidof(RAServerLib::RASrv), NULL, CLSCTX_REMOTE_SERVER, 
    &si, 1, &qi );
if (FAILED(hr))
{
    return hr;
}
CComPtr<RAServerLib::IRASrv> prasrv;
hr = qi.pItf->QueryInterface(__uuidof(RAServerLib::IRASrv), (void**)&prasrv);
if (FAILED(hr))
{
    return hr;
}

LPWSTR pstr=NULL;

hr = prasrv->raw_GetNoviceUserInfo(&pstr);
if (FAILED(hr))
{
    return hr;
}
    pstr contains the Remote Assistance Connection String (type 2)

There turns out to be two ways. The Microsoft API is called IRASrv and is documented here:

http://msdn.microsoft.com/en-us/library/cc240176(PROT.10).aspx

Another way is to simply call msra.exe. with password and novice params (e.g. msra.exe /saveasfile testfile thepassword). However that does prompt the user with the password dialog.

Here is example code for calling the IRASrv interface and generating a Remote Assistance Connection String.

COSERVERINFO            si; ::ZeroMemory( &si, sizeof( si ) );
MULTI_QI                qi; ::ZeroMemory( &qi, sizeof( qi ) );

HRESULT hr = S_OK;

BSTR bstrUserName     = SysAllocString(L"jon");
BSTR bstrDomainName   = SysAllocString(L"");
BSTR bstrPasswordStr     = SysAllocString(L"testpass");

// Get the security information entered by the user
_bstr_t bstrUser(bstrUserName);
_bstr_t bstrDomain(bstrDomainName);
_bstr_t bstrPassword(bstrPasswordStr);

// Set AuthIdentity
SEC_WINNT_AUTH_IDENTITY_W AuthIdentity = {
    (unsigned short*)bstrUserName,
    bstrUser.length(),
    (unsigned short*)bstrDomainName,
    bstrDomain.length(),
    (unsigned short*)bstrPasswordStr,
    bstrPassword.length(),
    SEC_WINNT_AUTH_IDENTITY_UNICODE 
};
COAUTHINFO AuthInfo = {
    RPC_C_AUTHN_WINNT, 
    RPC_C_AUTHZ_DEFAULT, 
    NULL, 
    RPC_C_AUTHN_LEVEL_PKT_PRIVACY,  // The authentication level used
    RPC_C_IMP_LEVEL_IMPERSONATE, 
    (COAUTHIDENTITY*)&AuthIdentity,
    EOAC_NONE 
};

si.pAuthInfo = &AuthInfo;
si.pwszName = bstrMachineName;
qi.pIID     = &(__uuidof(RAServerLib::IRASrv));

hr = ::CoCreateInstanceEx(
    __uuidof(RAServerLib::RASrv), NULL, CLSCTX_REMOTE_SERVER, 
    &si, 1, &qi );
if (FAILED(hr))
{
    return hr;
}
CComPtr<RAServerLib::IRASrv> prasrv;
hr = qi.pItf->QueryInterface(__uuidof(RAServerLib::IRASrv), (void**)&prasrv);
if (FAILED(hr))
{
    return hr;
}

LPWSTR pstr=NULL;

hr = prasrv->raw_GetNoviceUserInfo(&pstr);
if (FAILED(hr))
{
    return hr;
}
    pstr contains the Remote Assistance Connection String (type 2)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文