diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-07-18 13:34:48 +0200 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-07-18 13:34:48 +0200 |
commit | ea9689723754628718507a23d1f6d3a26bac32e0 (patch) | |
tree | 60660801dd11aa5b23531f2ec8b246f3d597d15d /extensions/source | |
parent | b79115518b9d68cf280cde717634e6f2f2e4ee72 (diff) |
First step to proper handling of character encodings in windows ldap backend
Change-Id: Id28174af5c28346fc363e3f62a8004ce0cf98c6a
Diffstat (limited to 'extensions/source')
-rw-r--r-- | extensions/source/config/ldap/ldapaccess.cxx | 24 | ||||
-rw-r--r-- | extensions/source/config/ldap/ldapaccess.hxx | 14 | ||||
-rw-r--r-- | extensions/source/config/ldap/ldapuserprofilebe.cxx | 6 | ||||
-rw-r--r-- | extensions/source/config/ldap/ldapuserprofilebe.hxx | 2 |
4 files changed, 22 insertions, 24 deletions
diff --git a/extensions/source/config/ldap/ldapaccess.cxx b/extensions/source/config/ldap/ldapaccess.cxx index 674ddc72d9ce..fefef068f5e4 100644 --- a/extensions/source/config/ldap/ldapaccess.cxx +++ b/extensions/source/config/ldap/ldapaccess.cxx @@ -138,8 +138,8 @@ void LdapConnection::connectSimple() // Do the bind LdapErrCode retCode = ldap_simple_bind_s(mConnection, - CONST_PCHAR_CAST mLdapDefinition.mAnonUser.getStr(), - CONST_PCHAR_CAST mLdapDefinition.mAnonCredentials.getStr()) ; + CONST_PCHAR_CAST rtl::OUStringToOString( mLdapDefinition.mAnonUser, RTL_TEXTENCODING_UTF8 ).getStr(), + CONST_PCHAR_CAST rtl::OUStringToOString( mLdapDefinition.mAnonCredentials, RTL_TEXTENCODING_UTF8 ).getStr()) ; checkLdapReturnCode("SimpleBind", retCode, mConnection) ; } @@ -158,14 +158,14 @@ void LdapConnection::initConnection() if (mLdapDefinition.mPort == 0) mLdapDefinition.mPort = LDAP_PORT; - mConnection = ldap_init(CONST_PCHAR_CAST mLdapDefinition.mServer.getStr(), + mConnection = ldap_init(CONST_PCHAR_CAST rtl::OUStringToOString( mLdapDefinition.mServer, RTL_TEXTENCODING_UTF8 ).getStr(), mLdapDefinition.mPort) ; if (mConnection == NULL) { rtl::OUStringBuffer message ; message.appendAscii("Cannot initialise connection to LDAP server ") ; - message.appendAscii(mLdapDefinition.mServer.getStr()) ; + message.append(mLdapDefinition.mServer) ; message.appendAscii(":") ; message.append(mLdapDefinition.mPort) ; throw ldap::LdapConnectionException(message.makeStringAndClear(), @@ -181,11 +181,11 @@ void LdapConnection::initConnection() OSL_ASSERT(data != 0); if (!isValid()) { connectSimple(); } - rtl::OString aUserDn =findUserDn( rtl::OUStringToOString(aUser, RTL_TEXTENCODING_ASCII_US)); + rtl::OUString aUserDn =findUserDn( aUser ); LdapMessageHolder result; LdapErrCode retCode = ldap_search_s(mConnection, - CONST_PCHAR_CAST aUserDn.getStr(), + CONST_PCHAR_CAST rtl::OUStringToOString( aUserDn, RTL_TEXTENCODING_UTF8 ).getStr(), LDAP_SCOPE_BASE, "(objectclass=*)", 0, @@ -209,7 +209,7 @@ void LdapConnection::initConnection() } } //------------------------------------------------------------------------------ - rtl::OString LdapConnection::findUserDn(const rtl::OString& aUser) + rtl::OUString LdapConnection::findUserDn(const rtl::OUString& aUser) throw (lang::IllegalArgumentException, ldap::LdapConnectionException, ldap::LdapGenericException) { @@ -225,7 +225,7 @@ void LdapConnection::initConnection() - rtl::OStringBuffer filter( "(&(objectclass=" ); + rtl::OUStringBuffer filter( "(&(objectclass=" ); filter.append( mLdapDefinition.mUserObjectClass ).append(")(") ; filter.append( mLdapDefinition.mUserUniqueAttr ).append("=").append(aUser).append("))") ; @@ -235,19 +235,19 @@ void LdapConnection::initConnection() attributes[0]= const_cast<sal_Char *>(LDAP_NO_ATTRS); attributes[1]= NULL; LdapErrCode retCode = ldap_search_s(mConnection, - CONST_PCHAR_CAST mLdapDefinition.mBaseDN.getStr(), + CONST_PCHAR_CAST rtl::OUStringToOString( mLdapDefinition.mBaseDN, RTL_TEXTENCODING_UTF8 ).getStr(), LDAP_SCOPE_SUBTREE, - CONST_PCHAR_CAST filter.makeStringAndClear().getStr(), attributes, 0, &result.msg) ; + CONST_PCHAR_CAST rtl::OUStringToOString( filter.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ).getStr(), attributes, 0, &result.msg) ; checkLdapReturnCode("FindUserDn", retCode,mConnection) ; - rtl::OString userDn ; + rtl::OUString userDn ; LDAPMessage *entry = ldap_first_entry(mConnection, result.msg) ; if (entry != NULL) { sal_Char *charsDn = ldap_get_dn(mConnection, entry) ; - userDn = charsDn ; + userDn = rtl::OStringToOUString( charsDn, RTL_TEXTENCODING_UTF8 ); ldap_memfree(charsDn) ; } else diff --git a/extensions/source/config/ldap/ldapaccess.hxx b/extensions/source/config/ldap/ldapaccess.hxx index 3cf290738b00..4886dc3cb15a 100644 --- a/extensions/source/config/ldap/ldapaccess.hxx +++ b/extensions/source/config/ldap/ldapaccess.hxx @@ -45,19 +45,19 @@ struct LdapUserProfile; struct LdapDefinition { /** LDAP server name */ - rtl::OString mServer ; + rtl::OUString mServer ; /** LDAP server port number */ sal_Int32 mPort ; /** Repository base DN */ - rtl::OString mBaseDN ; + rtl::OUString mBaseDN ; /** DN to use for "anonymous" connection */ - rtl::OString mAnonUser ; + rtl::OUString mAnonUser ; /** Credentials to use for "anonymous" connection */ - rtl::OString mAnonCredentials ; + rtl::OUString mAnonCredentials ; /** User Entity Object Class */ - rtl::OString mUserObjectClass; + rtl::OUString mUserObjectClass; /** User Entity Unique Attribute */ - rtl::OString mUserUniqueAttr; + rtl::OUString mUserUniqueAttr; } ; typedef std::map< rtl::OUString, rtl::OUString > LdapData; // key/value pairs @@ -94,7 +94,7 @@ public: /** finds DN of user @return DN of User */ - rtl::OString findUserDn(const rtl::OString& aUser) + rtl::OUString findUserDn(const rtl::OUString& aUser) throw (lang::IllegalArgumentException, ldap::LdapConnectionException, ldap::LdapGenericException); diff --git a/extensions/source/config/ldap/ldapuserprofilebe.cxx b/extensions/source/config/ldap/ldapuserprofilebe.cxx index 6b73e9eb2057..41de4b30dafe 100644 --- a/extensions/source/config/ldap/ldapuserprofilebe.cxx +++ b/extensions/source/config/ldap/ldapuserprofilebe.cxx @@ -171,11 +171,9 @@ bool LdapUserProfileBe::readLdapConfiguration( bool LdapUserProfileBe::getLdapStringParam( uno::Reference<container::XNameAccess>& xAccess, const rtl::OUString& aLdapSetting, - rtl::OString& aServerParameter) + rtl::OUString& aServerParameter) { - rtl::OUString sParam; - xAccess->getByName(aLdapSetting) >>= sParam; - aServerParameter = rtl::OUStringToOString(sParam, RTL_TEXTENCODING_ASCII_US); + xAccess->getByName(aLdapSetting) >>= aServerParameter; return !aServerParameter.isEmpty(); } diff --git a/extensions/source/config/ldap/ldapuserprofilebe.hxx b/extensions/source/config/ldap/ldapuserprofilebe.hxx index ccd9af8f42bd..196435979d32 100644 --- a/extensions/source/config/ldap/ldapuserprofilebe.hxx +++ b/extensions/source/config/ldap/ldapuserprofilebe.hxx @@ -151,7 +151,7 @@ class LdapUserProfileBe : private LdapProfileMutexHolder, public BackendBase bool getLdapStringParam(uno::Reference<container::XNameAccess>& xAccess, const rtl::OUString& aLdapSetting, - rtl::OString& aServerParameter); + rtl::OUString& aServerParameter); LdapData data_; } ; |