/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
LdapUserProfileBe::LdapUserProfileBe( const uno::Reference<uno::XComponentContext>& xContext)
: BackendBase(m_aMutex)
{
LdapDefinition aDefinition;
OUString loggedOnUser; // true initially to handle reentrant call; will become false if readLdapConfiguration fails bool bHaveLdapConfiguration = true;
// This whole rigmarole is to prevent an infinite recursion where reading // the configuration for the backend would create another instance of the // backend, which would try and read the configuration which would...
{ static osl::Mutex aInitMutex;
osl::MutexGuard aInitGuard(aInitMutex);
staticbool bReentrantCall; // = false
OSL_ENSURE(!bReentrantCall, "configuration: Ldap Backend constructor called reentrantly - probably a registration error.");
if (!bReentrantCall)
{
bReentrantCall = true ;
comphelper::ScopeGuard aReentrantCallGuard([]() { bReentrantCall = false; }); // Don't throw on fail: this will crash if LDAP is misconfigured, and user opens // Expert Configuration dialog. Instead, just don't fill data_, which will make the // backend return empty values. This happens in SvtUserOptions::Impl::GetValue_Impl // anyway even in throwing scenario, but doing it here also improves performance // because of avoiding repeated attempts to create the backend.
bHaveLdapConfiguration = readLdapConfiguration(
xContext, &aDefinition, &loggedOnUser); if (!bHaveLdapConfiguration)
SAL_WARN("extensions.config", "LdapUserProfileBackend: LDAP not configured");
}
}
if (bHaveLdapConfiguration)
{
LdapConnection connection;
connection.connectSimple(aDefinition);
connection.getUserProfile(loggedOnUser, &data_);
}
}
if (!getLdapStringParam(xChildAccess, u"Server"_ustr, definition->mServer)) returnfalse; if (!getLdapStringParam(xChildAccess, u"BaseDN"_ustr, definition->mBaseDN)) returnfalse;
definition->mPort=0;
xChildAccess->getByName(u"Port"_ustr) >>= definition->mPort ; if (definition->mPort == 0) returnfalse;
if (!getLdapStringParam(xAccess, u"UserObjectClass"_ustr, definition->mUserObjectClass)) returnfalse; if (!getLdapStringParam(xAccess, u"UserUniqueAttribute"_ustr, definition->mUserUniqueAttr)) returnfalse;
getLdapStringParam(xAccess, u"SearchUser"_ustr, definition->mAnonUser);
getLdapStringParam(xAccess, u"SearchPassword"_ustr, definition->mAnonCredentials);
} catch (const uno::Exception&)
{
TOOLS_WARN_EXCEPTION("extensions.config", "LdapUserProfileBackend: access to configuration data failed"); returnfalse;
}
osl::Security aSecurityContext; if (!aSecurityContext.getUserName(*loggedOnUser))
SAL_WARN("extensions.config", "LdapUserProfileBackend - could not get Logged on user from system");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.