summaryrefslogtreecommitdiff
path: root/extensions/source/config/ldap
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2009-09-08 04:57:32 +0000
committerOliver Bolte <obo@openoffice.org>2009-09-08 04:57:32 +0000
commit26aa928bf97652c8df13798f6ff3ce1df058f626 (patch)
tree64fe59a48897407b4320a1bd128cfb62f93adfb2 /extensions/source/config/ldap
parentba8012a2cf500b13ac3cd54acc2ef36b1a82fbcb (diff)
CWS-TOOLING: integrate CWS oj18
2009-08-21 15:08:49 +0200 oj r275263 : wrong check 2009-08-21 08:56:01 +0200 oj r275215 : missing not 2009-08-20 07:27:13 +0200 oj r275164 : use new method from global 2009-08-19 10:22:35 +0200 oj r275138 : call GetLocale instead of pLocale 2009-08-18 10:39:32 +0200 oj r275082 : missing header include 2009-08-18 10:09:44 +0200 oj r275081 : new methods at global 2009-08-18 10:09:00 +0200 oj r275080 : unused var 2009-08-18 08:59:04 +0200 oj r275078 : move files from classes to xml 2009-08-17 14:58:16 +0200 oj r275056 : CWS-TOOLING: rebase CWS oj18 to trunk@275001 (milestone: DEV300:m55) 2009-08-17 13:29:44 +0200 oj r275047 : compile error 2009-08-17 13:27:47 +0200 oj r275045 : compile error 2009-08-17 11:44:54 +0200 oj r275040 : add dep 2009-07-22 14:26:05 +0200 oj r274240 : move unused services into fwl 2009-07-22 14:25:35 +0200 oj r274239 : move unused services into fwl 2009-07-22 13:47:45 +0200 oj r274233 : remove some unused code 2009-07-22 09:06:20 +0200 oj r274219 : export dbtoolsclient dbcharsethelper for sc 2009-07-22 08:48:58 +0200 oj r274218 : create NumberFormatter on demand 2009-07-22 08:39:23 +0200 oj r274217 : change char to sal_Char 2009-07-22 07:33:34 +0200 oj r274214 : export dbtoolsclient dbcharsethelper for sc 2009-07-22 07:30:04 +0200 oj r274213 : late init of numberformatter and breakiterator 2009-07-22 07:28:55 +0200 oj r274212 : export dbtoolsclient dbcharsethelper for sc 2009-07-21 13:43:28 +0200 oj r274196 : check if quick start is enbaled 2009-07-21 13:40:09 +0200 oj r274195 : check config entry for UiEventsLogger 2009-07-21 13:37:40 +0200 oj r274194 : code refactoring, remove of duplicate code and some late inits and removale of not needed files 2009-07-21 13:35:38 +0200 oj r274193 : code refactoring, remove of duplicate code and some late inits and removale of not needed files 2009-07-21 13:33:41 +0200 oj r274192 : doc meta data will now be created on demand 2009-07-21 13:13:40 +0200 oj r274187 : load ldap functions on demand 2009-07-21 13:03:17 +0200 oj r274183 : late init of TransliterationImpl 2009-07-21 12:36:10 +0200 oj r274180 : late init of charClass
Diffstat (limited to 'extensions/source/config/ldap')
-rw-r--r--extensions/source/config/ldap/ldapaccess.cxx89
-rw-r--r--extensions/source/config/ldap/ldapaccess.hxx35
-rw-r--r--extensions/source/config/ldap/ldapuserprof.cxx6
-rw-r--r--extensions/source/config/ldap/ldapuserprofilebe.cxx29
-rw-r--r--extensions/source/config/ldap/makefile.mk1
5 files changed, 122 insertions, 38 deletions
diff --git a/extensions/source/config/ldap/ldapaccess.cxx b/extensions/source/config/ldap/ldapaccess.cxx
index 7c4a690cd16f..a850a441c5fe 100644
--- a/extensions/source/config/ldap/ldapaccess.cxx
+++ b/extensions/source/config/ldap/ldapaccess.cxx
@@ -40,14 +40,30 @@
namespace extensions { namespace config { namespace ldap {
-
+oslModule LdapConnection::s_Ldap_Module = NULL;
+t_ldap_unbind_s LdapConnection::s_p_unbind_s = NULL;
+t_ldap_simple_bind_s LdapConnection::s_p_simple_bind_s = NULL;
+t_ldap_set_option LdapConnection::s_p_set_option = NULL;
+t_ldap_err2string LdapConnection::s_p_err2string = NULL;
+t_ldap_init LdapConnection::s_p_init = NULL;
+t_ldap_msgfree LdapConnection::s_p_msgfree = NULL;
+t_ldap_get_dn LdapConnection::s_p_get_dn = NULL;
+t_ldap_first_entry LdapConnection::s_p_first_entry = NULL;
+t_ldap_search_s LdapConnection::s_p_search_s = NULL;
+t_ldap_value_free LdapConnection::s_p_value_free = NULL;
+t_ldap_get_values LdapConnection::s_p_get_values = NULL;
+t_ldap_memfree LdapConnection::s_p_memfree = NULL;
//------------------------------------------------------------------------------
typedef int LdapErrCode;
//------------------------------------------------------------------------------
struct LdapMessageHolder
{
LdapMessageHolder() : msg(0) {}
- ~LdapMessageHolder() { if (msg) ldap_msgfree(msg); }
+ ~LdapMessageHolder()
+ {
+ if (msg)
+ (*LdapConnection::s_p_msgfree)(msg);
+ }
LDAPMessage * msg;
@@ -66,7 +82,7 @@ void LdapConnection::disconnect()
{
if (mConnection != NULL)
{
- ldap_unbind_s(mConnection) ;
+ (*s_p_unbind_s)(mConnection) ;
mConnection = NULL;
}
}
@@ -85,11 +101,11 @@ static void checkLdapReturnCode(const sal_Char *aOperation,
{
message.appendAscii(aOperation).appendAscii(": ") ;
}
- message.appendAscii(ldap_err2string(aRetCode)).appendAscii(" (") ;
+ message.appendAscii((*LdapConnection::s_p_err2string)(aRetCode)).appendAscii(" (") ;
sal_Char *stub = NULL ;
#ifndef LDAP_OPT_SIZELIMIT // for use with OpenLDAP
- ldap_get_lderrno(aConnection, NULL, &stub) ;
+ (*s_p_get_lderrno)(aConnection, NULL, &stub) ;
#endif
if (stub != NULL)
{
@@ -99,7 +115,7 @@ static void checkLdapReturnCode(const sal_Char *aOperation,
// string itself. At any rate freeing it seems to
// cause some undue problems at least on Windows.
// This call is thus disabled for the moment.
- //ldap_memfree(stub) ;
+ //(*s_p_memfree)(stub) ;
}
else { message.appendAscii(kNoSpecificMessage) ; }
message.appendAscii(")") ;
@@ -126,20 +142,20 @@ void LdapConnection::connectSimple()
initConnection() ;
// Set Protocol V3
int version = LDAP_VERSION3;
- ldap_set_option(mConnection,
+ (*s_p_set_option)(mConnection,
LDAP_OPT_PROTOCOL_VERSION,
&version);
#ifdef LDAP_X_OPT_CONNECT_TIMEOUT // OpenLDAP doesn't support this and the func
/* timeout is specified in milliseconds -> 4 seconds*/
int timeout = 4000;
- ldap_set_option( mConnection,
+ (*s_p_set_option)( mConnection,
LDAP_X_OPT_CONNECT_TIMEOUT,
&timeout );
#endif
// Do the bind
- LdapErrCode retCode = ldap_simple_bind_s(mConnection,
+ LdapErrCode retCode = (*s_p_simple_bind_s)(mConnection,
mLdapDefinition.mAnonUser ,
mLdapDefinition.mAnonCredentials) ;
@@ -160,7 +176,7 @@ void LdapConnection::initConnection()
if (mLdapDefinition.mPort == 0) mLdapDefinition.mPort = LDAP_PORT;
- mConnection = ldap_init(mLdapDefinition.mServer,
+ mConnection = (*s_p_init)(mLdapDefinition.mServer,
mLdapDefinition.mPort) ;
if (mConnection == NULL)
{
@@ -186,7 +202,7 @@ void LdapConnection::initConnection()
rtl::OString aUserDn =findUserDn( rtl::OUStringToOString(aUser, RTL_TEXTENCODING_ASCII_US));
LdapMessageHolder result;
- LdapErrCode retCode = ldap_search_s(mConnection,
+ LdapErrCode retCode = (*s_p_search_s)(mConnection,
aUserDn,
LDAP_SCOPE_BASE,
"(objectclass=*)",
@@ -228,21 +244,21 @@ void LdapConnection::initConnection()
sal_Char * attributes [2];
attributes[0]= const_cast<sal_Char *>(LDAP_NO_ATTRS);
attributes[1]= NULL;
- LdapErrCode retCode = ldap_search_s(mConnection,
+ LdapErrCode retCode = (*s_p_search_s)(mConnection,
mLdapDefinition.mBaseDN,
LDAP_SCOPE_SUBTREE,
filter.makeStringAndClear(), attributes, 0, &result.msg) ;
checkLdapReturnCode("FindUserDn", retCode,mConnection) ;
rtl::OString userDn ;
- LDAPMessage *entry = ldap_first_entry(mConnection, result.msg) ;
+ LDAPMessage *entry = (*s_p_first_entry)(mConnection, result.msg) ;
if (entry != NULL)
{
- sal_Char *charsDn = ldap_get_dn(mConnection, entry) ;
+ sal_Char *charsDn = (*s_p_get_dn)(mConnection, entry) ;
userDn = charsDn ;
- ldap_memfree(charsDn) ;
+ (*s_p_memfree)(charsDn) ;
}
else
{
@@ -264,7 +280,7 @@ rtl::OString LdapConnection::getSingleAttribute(
attributes [0] = aAttribute ;
attributes [1] = 0 ;
LdapMessageHolder result ;
- LdapErrCode retCode = ldap_search_s(mConnection,
+ LdapErrCode retCode = (*s_p_search_s)(mConnection,
aDn,
LDAP_SCOPE_BASE,
"(objectclass=*)",
@@ -277,22 +293,57 @@ rtl::OString LdapConnection::getSingleAttribute(
return value ;
}
checkLdapReturnCode("GetSingleAttribute", retCode, mConnection) ;
- LDAPMessage *entry = ldap_first_entry(mConnection, result.msg) ;
+ LDAPMessage *entry = (*s_p_first_entry)(mConnection, result.msg) ;
if (entry != NULL)
{
- sal_Char **values = ldap_get_values(mConnection, entry,
+ sal_Char **values = (*s_p_get_values)(mConnection, entry,
aAttribute) ;
if (values != NULL)
{
if (*values != NULL) { value = *values ; }
- ldap_value_free(values) ;
+ (*s_p_value_free)(values) ;
}
}
return value ;
}
+extern "C" { static void SAL_CALL thisModule() {} }
+void LdapConnection::loadModule()
+{
+ if ( !s_Ldap_Module )
+ {
+#if defined(WIN) || defined(WNT)
+ const ::rtl::OUString sModuleName(RTL_CONSTASCII_USTRINGPARAM("nsldap32v50.dll"));
+#else
+#ifdef WITH_OPENLDAP
+ const ::rtl::OUString sModuleName(RTL_CONSTASCII_USTRINGPARAM("libldap.so"));
+#else
+ const ::rtl::OUString sModuleName(RTL_CONSTASCII_USTRINGPARAM("libldap50.so"));
+#endif
+#endif
+
+ // load the dbtools library
+ s_Ldap_Module = osl_loadModuleRelative(&thisModule, sModuleName.pData, 0);
+ if ( s_Ldap_Module != NULL )
+ {
+ s_p_unbind_s = (t_ldap_unbind_s)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_unbind_s").pData));
+ s_p_simple_bind_s = (t_ldap_simple_bind_s)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_simple_bind_s").pData));
+ s_p_set_option = (t_ldap_set_option)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_set_option").pData));
+ s_p_err2string = (t_ldap_err2string)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_err2string").pData));
+ s_p_init = (t_ldap_init)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_init").pData));
+ s_p_msgfree = (t_ldap_msgfree)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_msgfree").pData));
+ s_p_get_dn = (t_ldap_get_dn)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_get_dn").pData));
+ s_p_first_entry = (t_ldap_first_entry)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_first_entry").pData));
+ s_p_search_s = (t_ldap_search_s)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_search_s").pData));
+ s_p_value_free = (t_ldap_value_free)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_value_free").pData));
+ s_p_get_values = (t_ldap_get_values)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_get_values").pData));
+ s_p_memfree = (t_ldap_memfree)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_memfree").pData));
+ }
+ }
+}
+
//------------------------------------------------------------------------------
} } } // extensions.config.ldap
diff --git a/extensions/source/config/ldap/ldapaccess.hxx b/extensions/source/config/ldap/ldapaccess.hxx
index 9017162c0c5e..47022bb0d615 100644
--- a/extensions/source/config/ldap/ldapaccess.hxx
+++ b/extensions/source/config/ldap/ldapaccess.hxx
@@ -34,10 +34,9 @@
#include "wrapldapinclude.hxx"
#include <com/sun/star/ldap/LdapGenericException.hpp>
-#ifndef _COM_SUN_STAR_LDAP_LDAP_CONNECTIONEXCEPTION_HPP_
#include <com/sun/star/ldap/LdapConnectionException.hpp>
-#endif // _COM_SUN_STAR_LDAP_LDAP_CONNECTIONEXCEPTION_HPP_
#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <osl/module.h>
namespace extensions { namespace config { namespace ldap {
@@ -50,6 +49,18 @@ namespace ldap = css::ldap ;
struct LdapUserProfile;
class LdapUserProfileMap;
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_unbind_s)( LDAP *ld );
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_simple_bind_s)( LDAP *ld, const char *who, const char *passwd );
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_set_option)( LDAP *ld, int option, const void *optdata );
+typedef LDAP_API(char *) (LDAP_CALL *t_ldap_err2string)( int err );
+typedef LDAP_API(LDAP *) (LDAP_CALL *t_ldap_init)( const char *defhost, int defport );
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_msgfree)( LDAPMessage *lm );
+typedef LDAP_API(char *) (LDAP_CALL *t_ldap_get_dn)( LDAP *ld, LDAPMessage *entry );
+typedef LDAP_API(LDAPMessage *) (LDAP_CALL *t_ldap_first_entry)( LDAP *ld, LDAPMessage *chain );
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_search_s)( LDAP *ld, const char *base, int scope, const char *filter, char **attrs, int attrsonly, LDAPMessage **res );
+typedef LDAP_API(void) (LDAP_CALL *t_ldap_value_free)( char **vals );
+typedef LDAP_API(char **) (LDAP_CALL *t_ldap_get_values)( LDAP *ld, LDAPMessage *entry, const char *target );
+typedef LDAP_API(void) (LDAP_CALL *t_ldap_memfree)( void *p );
//------------------------------------------------------------------------------
/** Struct containing the information on LDAP connection */
struct LdapDefinition
@@ -75,6 +86,7 @@ struct LdapDefinition
/** Class encapulating all LDAP functionality */
class LdapConnection
{
+ friend struct LdapMessageHolder;
public:
/** Default constructor */
@@ -124,6 +136,12 @@ public:
throw (lang::IllegalArgumentException,
ldap::LdapConnectionException,
ldap::LdapGenericException);
+
+ void loadModule();
+
+ static t_ldap_err2string s_p_err2string;
+ static t_ldap_value_free s_p_value_free;
+ static t_ldap_get_values s_p_get_values;
private:
void initConnection()
@@ -142,6 +160,19 @@ private:
/** LDAP connection object */
LDAP* mConnection ;
LdapDefinition mLdapDefinition;
+
+ static oslModule s_Ldap_Module;
+ static t_ldap_unbind_s s_p_unbind_s;
+ static t_ldap_simple_bind_s s_p_simple_bind_s;
+ static t_ldap_set_option s_p_set_option;
+ static t_ldap_init s_p_init;
+ static t_ldap_msgfree s_p_msgfree;
+ static t_ldap_get_dn s_p_get_dn;
+ static t_ldap_first_entry s_p_first_entry;
+ static t_ldap_search_s s_p_search_s;
+
+ static t_ldap_memfree s_p_memfree;
+
} ;
//------------------------------------------------------------------------------
}} }
diff --git a/extensions/source/config/ldap/ldapuserprof.cxx b/extensions/source/config/ldap/ldapuserprof.cxx
index 7475af4e8fcf..3a031ddae211 100644
--- a/extensions/source/config/ldap/ldapuserprof.cxx
+++ b/extensions/source/config/ldap/ldapuserprof.cxx
@@ -31,7 +31,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_extensions.hxx"
#include "ldapuserprof.hxx"
-
+#include "ldapaccess.hxx"
namespace extensions { namespace config { namespace ldap {
//==============================================================================
@@ -127,14 +127,14 @@ void LdapUserProfileMap::ldapToUserProfile(LDAP *aConnection,
for (sal_uInt32 j = 0 ;
j < mMapping [i].mLdapAttributes.size() ; ++ j)
{
- values = ldap_get_values(aConnection, aEntry,
+ values = (*LdapConnection::s_p_get_values)(aConnection, aEntry,
mMapping [i].mLdapAttributes [j]) ;
if (values != NULL)
{
aProfile.mProfile[i].mValue = rtl::OStringToOUString(
*values, RTL_TEXTENCODING_UTF8);
- ldap_value_free(values);
+ (*LdapConnection::s_p_value_free)(values);
break;
}
}
diff --git a/extensions/source/config/ldap/ldapuserprofilebe.cxx b/extensions/source/config/ldap/ldapuserprofilebe.cxx
index 13cd3ff2070d..330834c5b414 100644
--- a/extensions/source/config/ldap/ldapuserprofilebe.cxx
+++ b/extensions/source/config/ldap/ldapuserprofilebe.cxx
@@ -112,27 +112,30 @@ LdapUserProfileBe::LdapUserProfileBe( const uno::Reference<uno::XComponentContex
OSL_ENSURE(!bReentrantCall, "configuration: Ldap Backend constructor called reentrantly - probably a registration error.");
if (!bReentrantCall)
- try
{
- bReentrantCall = true ;
- if (! readLdapConfiguration(aDefinition) )
+ try
{
- throw backend::BackendSetupException(
- rtl::OUString::createFromAscii("LdapUserProfileBe- LDAP not configured"),
- NULL, uno::Any());
+ bReentrantCall = true ;
+ if (! readLdapConfiguration(aDefinition) )
+ {
+ throw backend::BackendSetupException(
+ rtl::OUString::createFromAscii("LdapUserProfileBe- LDAP not configured"),
+ NULL, uno::Any());
+ }
+
+ bReentrantCall = false ;
+ }
+ catch (uno::Exception&)
+ {
+ bReentrantCall = false;
+ throw;
}
-
- bReentrantCall = false ;
- }
- catch (uno::Exception&)
- {
- bReentrantCall = false;
- throw;
}
}
try
{
+ mLdapSource->mConnection.loadModule();
mLdapSource->mConnection.connectSimple(aDefinition);
//Set the UserDN
mUserDN = mLdapSource->mConnection.findUserDn(
diff --git a/extensions/source/config/ldap/makefile.mk b/extensions/source/config/ldap/makefile.mk
index acd47ab9e281..5ff3da4d21de 100644
--- a/extensions/source/config/ldap/makefile.mk
+++ b/extensions/source/config/ldap/makefile.mk
@@ -82,7 +82,6 @@ SHL1DEF=$(MISC)$/$(SHL1TARGET).def
SHL1LIBS=$(LIB1TARGET)
SHL1IMPLIB=i$(SHL1TARGET)
SHL1STDLIBS= \
- $(LDAPSDKLIB) \
$(CPPUHELPERLIB) \
$(CPPULIB) \
$(SALHELPERLIB) \