本文整理汇总了C++中zimbra::util::ScopedInterface::CreateDSObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ScopedInterface::CreateDSObject方法的具体用法?C++ ScopedInterface::CreateDSObject怎么用?C++ ScopedInterface::CreateDSObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zimbra::util::ScopedInterface
的用法示例。
在下文中一共展示了ScopedInterface::CreateDSObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateExchangeMailBox
//.........这里部分代码省略.........
wstring wstrMail;
size_t nPosMail = strLogonMail.find(_T("@"), 0);
wstrMail = strLogonMail.substr(nPosMail);
wstrMail = lpwstrNewUser + wstrMail;
LPWSTR upnval = (LPWSTR)wstrMail.c_str();
uPNValue.dwType = ADSTYPE_CASE_IGNORE_STRING;
uPNValue.CaseIgnoreString = upnval;
Zimbra::Util::ScopedInterface<IDirectoryObject> pDirContainer;
Zimbra::Util::ScopedInterface<IDispatch> pDisp;
Zimbra::Util::ScopedInterface<IADsUser> pIADNewUser;
wstring wstrLoggedUserName(LogonUserDN);
size_t snPos = 0;
size_t enPos = 0;
if ((snPos = wstrLoggedUserName.find(L"CN=")) != wstring::npos)
{
if ((enPos = wstrLoggedUserName.find(L",", snPos)) != wstring::npos)
wstrLoggedUserName = wstrLoggedUserName.substr(snPos + 3, (enPos - (snPos + 3)));
}
// get dir container
if (FAILED(hr = ADsOpenObject(wstrADSPath.c_str(), wstrLoggedUserName.c_str(),
lpwstrLogonUsrPwd, ADS_SECURE_AUTHENTICATION, IID_IDirectoryObject,
(void **)pDirContainer.getptr())))
throw ExchangeAdminException(hr, L"CreateExchangeMailBox(): ADsOpenObject Failed.",
ERR_CREATE_EXCHMBX, __LINE__, __FILE__);
wstring wstrUserCN = L"CN=";
wstrUserCN += lpwstrNewUser;
dloge("CreateDSObject: %S",wstrUserCN.c_str());
if (FAILED(hr = pDirContainer->CreateDSObject((LPWSTR)wstrUserCN.c_str(), attrInfo, dwAttrs,
pDisp.getptr())))
throw ExchangeAdminException(hr, L"CreateExchangeMailBox(): CreateDSObject Failed.",
ERR_CREATE_EXCHMBX,__LINE__, __FILE__);
if (FAILED(hr = pDisp->QueryInterface(IID_IADsUser, (void **)pIADNewUser.getptr())))
throw ExchangeAdminException(hr, L"CreateExchangeMailBox(): QueryInterface Failed.",
ERR_CREATE_EXCHMBX, __LINE__, __FILE__);
CComVariant varProp;
varProp.Clear();
// set samAccount
varProp = lpwstrNewUser;
if (FAILED(hr = pIADNewUser->Put(CComBSTR(L"sAMAccountName"), varProp)))
throw ExchangeAdminException(hr,L"CreateExchangeMailBox(): Put(sAMAccountName) Failed.",
ERR_CREATE_EXCHMBX, __LINE__, __FILE__);
if(FAILED(hr = pIADNewUser->SetInfo()))
throw ExchangeAdminException(hr,L"CreateExchangeMailBox(): Put(sAMAccountName) Failed.",
ERR_CREATE_EXCHMBX, __LINE__, __FILE__);
// set userAccountControl
varProp.Clear();
hr = pIADNewUser->Get(CComBSTR(L"userAccountControl"), &varProp);
varProp = varProp.lVal & ~(ADS_UF_ACCOUNTDISABLE);
if (FAILED(hr = pIADNewUser->Put(CComBSTR(L"userAccountControl"), varProp)))
throw ExchangeAdminException(hr,L"CreateExchangeMailBox(): Put(userAccountControl) Failed.",
ERR_CREATE_EXCHMBX, __LINE__, __FILE__);
if(FAILED(hr = pIADNewUser->SetInfo()))
ThrowSetInfoException(hr, L"SetInfo - Put(userAccountControl) Failed.");
// set Account enabled
if (FAILED(hr = pIADNewUser->put_AccountDisabled(VARIANT_FALSE)))
{
throw