本文整理汇总了C++中zimbra::util::ScopedInterface::CreateMsgService方法的典型用法代码示例。如果您正苦于以下问题:C++ ScopedInterface::CreateMsgService方法的具体用法?C++ ScopedInterface::CreateMsgService怎么用?C++ ScopedInterface::CreateMsgService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zimbra::util::ScopedInterface
的用法示例。
在下文中一共展示了ScopedInterface::CreateMsgService方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateProfile
HRESULT ExchangeAdmin::CreateProfile(wstring strProfileName, wstring strMailboxName, wstring
strPassword)
{
HRESULT hr = S_OK;
Zimbra::Util::ScopedBuffer<char> strServer;
Zimbra::Util::ScopedBuffer<char> strMBName;
Zimbra::Util::ScopedBuffer<char> strProfName;
Zimbra::Util::ScopedBuffer<char> strProfPwd;
Zimbra::Util::ScopedInterface<IMsgServiceAdmin> pSvcAdmin;
Zimbra::Util::ScopedInterface<IMAPITable> pMsgSvcTable;
Zimbra::Util::ScopedRowSet pSvcRows;
SPropValue rgval[2] = { 0 };
SPropValue sProps = { 0 };
SRestriction sres;
WCHAR errDescrption[256] = {};
// Columns to get from HrQueryAllRows.
enum { iSvcName, iSvcUID, cptaSvc };
SizedSPropTagArray(cptaSvc, sptCols) = { cptaSvc, PR_SERVICE_NAME, PR_SERVICE_UID };
WtoA((LPWSTR)strProfileName.c_str(), strProfName.getref());
WtoA((LPWSTR)strPassword.c_str(), strProfPwd.getref());
// create new profile
if (FAILED(hr = m_pProfAdmin->CreateProfile((LPTSTR)strProfName.get(),
(LPTSTR)strProfPwd.get(), NULL, 0)))
{
throw ExchangeAdminException(hr, L"CreateProfile(): CreateProfile Failed.",
ERR_CREATE_EXCHPROFILE, __LINE__, __FILE__);
}
// Get an IMsgServiceAdmin interface off of the IProfAdmin interface.
if (FAILED(hr = m_pProfAdmin->AdminServices((LPTSTR)strProfName.get(),
(LPTSTR)strProfPwd.get(), NULL, 0, pSvcAdmin.getptr())))
{
wcscpy(errDescrption, L"CreateProfile(): AdminServices Failed.");
goto CRT_PROFILE_EXIT;
}
// Create the new message service for Exchange.
if (FAILED(hr = pSvcAdmin->CreateMsgService((LPTSTR)"MSEMS", (LPTSTR)"MSEMS", NULL, NULL)))
{
wcscpy(errDescrption, L"CreateProfile(): CreateMsgService Failed.");
goto CRT_PROFILE_EXIT;
}
// Need to obtain the entry id for the new service. This can be done by getting the message service table
// and getting the entry that corresponds to the new service.
if (FAILED(hr = pSvcAdmin->GetMsgServiceTable(0, pMsgSvcTable.getptr())))
{
wcscpy(errDescrption, L"CreateProfile(): GetMsgServiceTable Failed.");
goto CRT_PROFILE_EXIT;
}
sres.rt = RES_CONTENT;
sres.res.resContent.ulFuzzyLevel = FL_FULLSTRING;
sres.res.resContent.ulPropTag = PR_SERVICE_NAME;
sres.res.resContent.lpProp = &sProps;
sProps.ulPropTag = PR_SERVICE_NAME;
sProps.Value.lpszA = "MSEMS";
// Query the table to obtain the entry for the newly created message service.
if (FAILED(hr = HrQueryAllRows(pMsgSvcTable.get(), (LPSPropTagArray) & sptCols, NULL, NULL,
0, pSvcRows.getptr())))
{
wcscpy(errDescrption, L"CreateProfile(): HrQueryAllRows Failed.");
goto CRT_PROFILE_EXIT;
}
// Set up a SPropValue array for the properties that you have to configure.
if (pSvcRows->cRows > 0)
{
// First, the exchange server name.
ZeroMemory(&rgval[0], sizeof (SPropValue));
rgval[0].ulPropTag = PR_PROFILE_UNRESOLVED_SERVER;
WtoA((LPWSTR)m_strServer.c_str(), strServer.getref());
rgval[0].Value.lpszA = (LPSTR)strServer.get();
// Next, the user's AD name.
ZeroMemory(&rgval[1], sizeof (SPropValue));
rgval[1].ulPropTag = PR_PROFILE_UNRESOLVED_NAME;
WtoA((LPWSTR)strMailboxName.c_str(), strMBName.getref());
rgval[1].Value.lpszA = (LPSTR)strMBName.get();
// Configure the message service by using the previous properties.
// int trials = 10;
int trials = 2;
int itrTrials = 0;
hr = 0x81002746; // WSAECONNRESET
while ((hr == 0x81002746) && (itrTrials < trials))
{
hr = pSvcAdmin->ConfigureMsgService(
(LPMAPIUID)pSvcRows->aRow->lpProps[iSvcUID].Value.bin.lpb, NULL, 0, 2, rgval);
//if (hr == 0x81002746)
// Sleep(30000);
//Sleep(10000);
itrTrials++;
}
if (FAILED(hr))
{
/* =
* pSvcAdmin->ConfigureMsgService((LPMAPIUID)pSvcRows->aRow->lpProps[iSvcUID].
* Value.bin.lpb,NULL, 0, 2, rgval)))*/
wcscpy(errDescrption, L"CreateProfile(): ConfigureMsgService Failed.");
goto CRT_PROFILE_EXIT;
//.........这里部分代码省略.........