summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-12-21 16:19:46 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-12-21 17:03:30 +0100
commitc35f81148fb18ba070516edcbb4d614444899235 (patch)
treea7411001321a0745f161787fcc2be978e2c94e0a /extensions
parent9466e895b319fc695cc326b37ee773e14b465c0a (diff)
Use sal::systools::CoInitializeGuard and sal::systools::ThrowIfFailed
Change-Id: Ifb40e7672671df03b5ffc89905ad1e7b68451b68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127232 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'extensions')
-rw-r--r--extensions/source/config/WinUserInfo/WinUserInfoBe.cxx21
1 files changed, 5 insertions, 16 deletions
diff --git a/extensions/source/config/WinUserInfo/WinUserInfoBe.cxx b/extensions/source/config/WinUserInfo/WinUserInfoBe.cxx
index a412769ee639..ce4d147220c2 100644
--- a/extensions/source/config/WinUserInfo/WinUserInfoBe.cxx
+++ b/extensions/source/config/WinUserInfo/WinUserInfoBe.cxx
@@ -90,33 +90,22 @@ public:
{
try
{
- struct CoInitializeGuard
- {
- CoInitializeGuard()
- {
- if (HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); FAILED(hr))
- throw sal::systools::ComError("CoInitializeEx failed", hr);
- }
- ~CoInitializeGuard() { CoUninitialize(); }
- } aCoInitializeGuard;
+ sal::systools::CoInitializeGuard aCoInitializeGuard(COINIT_APARTMENTTHREADED);
auto pADsys = sal::systools::COMReference<IADsADSystemInfo>().CoCreateInstance(
CLSID_ADSystemInfo, nullptr, CLSCTX_INPROC_SERVER);
smartBSTR sUserDN;
- HRESULT hr = pADsys->get_UserName(&sUserDN.ptr);
- if (FAILED(hr))
- throw sal::systools::ComError("get_UserName failed", hr);
+ sal::systools::ThrowIfFailed(pADsys->get_UserName(&sUserDN.ptr), "get_UserName failed");
// If this user is an AD user, then without an active connection to the domain, all the
// above will succeed, and m_sUserDN will be correctly initialized, but the following
// call to ADsGetObject will fail, and we will attempt reading cached values.
m_sUserDN = o3tl::toU(sUserDN.ptr);
OUString sLdapUserDN = "LDAP://" + m_sUserDN;
sal::systools::COMReference<IADsUser> pUser;
- hr = ADsGetObject(o3tl::toW(sLdapUserDN.getStr()), IID_IADsUser,
- reinterpret_cast<void**>(&pUser));
- if (FAILED(hr))
- throw sal::systools::ComError("ADsGetObject failed", hr);
+ sal::systools::ThrowIfFailed(ADsGetObject(o3tl::toW(sLdapUserDN.getStr()), IID_IADsUser,
+ reinterpret_cast<void**>(&pUser)),
+ "ADsGetObject failed");
// Fetch all the required information right now, when we know to have access to AD
// (later the connection may already be lost)
m_aMap[givenname] = Str(pUser, &IADsUser::get_FirstName);