请教CoCreateInstanceEx产生E_ACCESSDENIED的原因
Client : 机器名client1
激活代码为:
HRESULT hr;
hr = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_CONNECT,
RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, 0);
MULTI_QI qi = {&IID_ICalculator, 0, 0};
OLECHAR* szDomain = _T("server1");
OLECHAR* szRmtSvr = _T("192.168.19.106");
OLECHAR* szUser = _T("username");
OLECHAR* szPwd = _T("password");
COAUTHIDENTITY authId;
COAUTHINFO authInfo;
COSERVERINFO svrInfo;
authId.Domain = (USHORT*)szDomain;
authId.DomainLength = _tcslen(szDomain);
authId.User = (USHORT*)szUser;
authId.UserLength = _tcslen(szUser);
authId.Password = (USHORT*)szPwd;
authId.PasswordLength = _tcslen(szPwd);
authId.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
authInfo.pwszServerPrincName = NULL;
authInfo.dwAuthnSvc = RPC_C_AUTHN_WINNT;
authInfo.dwAuthnLevel = RPC_C_AUTHN_LEVEL_CONNECT;
authInfo.dwCapabilities = EOAC_NONE;
authInfo.dwImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE;
authInfo.pAuthIdentityData = &authId;
authInfo.dwAuthzSvc = RPC_C_AUTHZ_NAME;
svrInfo.dwReserved1 = NULL;
svrInfo.dwReserved2 = NULL;
svrInfo.pwszName = szRmtSvr;
svrInfo.pAuthInfo = &authInfo;
hr = CoCreateInstanceEx(CLSID_Calculator, NULL, CLSCTX_REMOTE_SERVER,
//&svr,
svrInfo,
1, &qi);
server: 服务器禁用guest用户,机器名为server1,ip为192.168.19.106,有一个用户id为username,
代码为:
SOLE_AUTHENTICATION_SERVICE *pacAuth = new SOLE_AUTHENTICATION_SERVICE;
pacAuth->dwAuthnSvc = RPC_C_AUTHN_WINNT;
pacAuth->dwAuthzSvc = RPC_C_AUTHZ_NAME;
pacAuth->pPrincipalName = NULL;
pacAuth->hr = S_OK;
hr = CoInitializeSecurity( NULL, 1, pacAuth, NULL, RPC_C_AUTHN_LEVEL_CONNECT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, 0);
问题:在client, 我明明是用username发送CoCreateInstanceEx,但是在服务器端用事件查看器发现,client是用guest激活dcom的,由于服务器禁用guest用户,所以导致不能激活成功
请问:怎么样设置才能在服务器上用client传递的用户名和密码激活DCOM?