[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepimlibs/kldap
From:       Andre Heinecke <aheinecke () intevation ! de>
Date:       2010-12-01 9:07:26
Message-ID: 20101201090726.C7104AC8A3 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1202535 by aheinecke:

Make use of System LDAP functions on WINCE Systems if OpenLDAP is not
available.
Windows NT support is not complete yet.


 M  +24 -7     CMakeLists.txt  
 M  +8 -0      ber.cpp  
 M  +2 -0      kldap_config.h.cmake  
 M  +4 -0      ldapconnection.cpp  
 M  +26 -7     ldapoperation.cpp  


--- trunk/KDE/kdepimlibs/kldap/CMakeLists.txt #1202534:1202535
@@ -3,13 +3,15 @@
 include(CheckSymbolExists)
 
 add_definitions( -DKDE_DEFAULT_DEBUG_AREA=5322 )
-
 macro_optional_find_package(Ldap)
-macro_log_feature(LDAP_FOUND "OpenLDAP" "LDAP support" "http://www.openldap.org" \
                FALSE "" "STRONGLY RECOMMENDED: Without this, the KLDAP library will \
                be useless" )
-
+if (NOT WINCE) #FIXME enable for win32
+    macro_log_feature(LDAP_FOUND "OpenLDAP" "LDAP (Lightweight Directory Access \
Protocol) libraries" "http://www.openldap.org" FALSE "" "STRONGLY RECOMMENDED: Needed \
to provide LDAP functionality in KDE" ) +else (NOT WINCE)
+    macro_log_feature(LDAP_FOUND "OpenLDAP" "LDAP (Lightweight Directory Access \
Protocol) libraries" "http://www.openldap.org" FALSE "" "Used for additional LDAP \
Features on Windows Systems\nSystem LDAP used as fallback for KDE" ) +endif(NOT \
WINCE)  #look for Sasl2 in the top-level CMakeLists.txt file now
 #macro_optional_find_package(Sasl2)
-#macro_log_feature(SASL2_FOUND "cyrus-sasl" "Support for authentication over LDAP" \
"http://asg.web.cmu.edu/sasl/sasl-library.html" FALSE "" "" ) \
+#macro_log_feature(SASL2_FOUND "cyrus-sasl" "Cyrus SASL API" \
"http://asg.web.cmu.edu/sasl/sasl-library.html" FALSE "" "Needed to support \
authentication of logins" )  
 check_include_files(sys/time.h    HAVE_SYS_TIME_H)
 
@@ -19,7 +21,7 @@
 if (LDAP_FOUND)
    set(kldap_EXTRA_LIBS ${LDAP_LIBRARIES})
    set(kldap_EXTRA_INCLUDES ${LDAP_INCLUDE_DIR})
-
+   set(HAVE_LDAP_H)
    set(CMAKE_REQUIRED_INCLUDES lber.h ldap.h)
    set(CMAKE_REQUIRED_LIBRARIES ${LDAP_LIBRARIES})
    check_function_exists(ldap_start_tls_s HAVE_LDAP_START_TLS_S)
@@ -30,8 +32,23 @@
    check_function_exists(ldap_extended_operation_s HAVE_LDAP_EXTENDED_OPERATION_S)
    check_symbol_exists(ldap_extended_operation ldap.h \
HAVE_LDAP_EXTENDED_OPERATION_PROTOTYPE)  \
check_symbol_exists(ldap_extended_operation_s ldap.h \
                HAVE_LDAP_EXTENDED_OPERATION_S_PROTOTYPE)
-
-
+else (LDAP_FOUND)
+   if (WINCE)
+      set(LDAP_FOUND TRUE)
+      set(HAVE_WINLDAP_H TRUE)
+      set(CMAKE_REQUIRED_INCLUDES winldap.h w32-ldap-help.h)
+      set(CMAKE_REQUIRED_LIBRARIES wldap32)
+      set(kldap_EXTRA_LIBS ${kldap_EXTRA_LIBS} wldap32)
+      # Checks left in for compatibilty
+      check_function_exists(ldap_start_tls_s HAVE_LDAP_START_TLS_S)
+      check_function_exists(ldap_initialize HAVE_LDAP_INITIALIZE)
+      check_function_exists(ber_memfree HAVE_BER_MEMFREE)
+      check_function_exists(ldap_unbind_ext HAVE_LDAP_UNBIND_EXT)
+      check_function_exists(ldap_extended_operation HAVE_LDAP_EXTENDED_OPERATION)
+      check_function_exists(ldap_extended_operation_s \
HAVE_LDAP_EXTENDED_OPERATION_S) +      check_symbol_exists(ldap_extended_operation \
winldap.h HAVE_LDAP_EXTENDED_OPERATION_PROTOTYPE) +      \
check_symbol_exists(ldap_extended_operation_s winldap.h \
HAVE_LDAP_EXTENDED_OPERATION_S_PROTOTYPE) +   endif (WINCE)
 endif (LDAP_FOUND)
 
 if (SASL2_FOUND)
--- trunk/KDE/kdepimlibs/kldap/ber.cpp #1202534:1202535
@@ -34,16 +34,24 @@
 #define BC31 1
 #endif
 
+#ifndef HAVE_WINLDAP_H
 #include <lber.h>
 #include <ldap.h>
+#else
+#include <w32-ldap-help.h>
+#endif
 
 #ifndef LBER_USE_DER
 #define LBER_USE_DER 1
 #endif
 
 #ifndef HAVE_BER_MEMFREE
+# ifndef HAVE_WINLDAP_H
 #define ber_memfree(x) ldap_memfree(x)
+# else
+#  define ber_memfree(x) win_ldap_memfree(x)
 #endif
+#endif
 
 #endif
 
--- trunk/KDE/kdepimlibs/kldap/kldap_config.h.cmake #1202534:1202535
@@ -1,5 +1,7 @@
 #cmakedefine LDAP_FOUND
 #cmakedefine SASL2_FOUND
+#cmakedefine HAVE_WINLDAP_H
+#cmakedefine HAVE_LDAP_H
 #cmakedefine HAVE_SYS_TIME_H
 #cmakedefine HAVE_LDAP_START_TLS_S
 #cmakedefine HAVE_LDAP_INITIALIZE
--- trunk/KDE/kdepimlibs/kldap/ldapconnection.cpp #1202534:1202535
@@ -43,8 +43,12 @@
 #endif
 
 #ifdef LDAP_FOUND
+# ifndef HAVE_WINLDAP_H
 #include <lber.h>
 #include <ldap.h>
+#else
+# include <w32-ldap-help.h>
+#endif // HAVE_WINLDAP_H
 
 #ifndef LDAP_OPT_SUCCESS
 #define LDAP_OPT_SUCCESS 0
--- trunk/KDE/kdepimlibs/kldap/ldapoperation.cpp #1202534:1202535
@@ -35,9 +35,13 @@
 #endif
 
 #ifdef LDAP_FOUND
+# ifndef HAVE_WINLDAP_H
 #include <lber.h>
 #include <ldap.h>
-#endif
+# else
+#  include <w32-ldap-help.h>
+# endif // HAVE_WINLDAP_H
+#endif // LDAP_FOUND
 
 #include "ldapdefs.h"
 
@@ -245,7 +249,7 @@
   int ret;
 
   if ( server.auth() == LdapServer::SASL ) {
-#ifdef SASL2_FOUND
+#if defined( SASL2_FOUND ) && !defined( HAVE_WINLDAP_H )
     sasl_conn_t *saslconn = (sasl_conn_t *)mConnection->saslHandle();
     sasl_interact_t *client_interact = NULL;
     const char *out = NULL;
@@ -333,7 +337,7 @@
     } while ( !async && ret == KLDAP_SASL_BIND_IN_PROGRESS );
 #else
     kError() << "SASL authentication is not available "
-             << "(re-compile kldap with cyrus-sasl development).";
+             << "(re-compile kldap with cyrus-sasl and OpenLDAP development).";
     return KLDAP_SASL_ERROR;
 #endif
   } else { //simple auth
@@ -350,15 +354,21 @@
     if ( async ) {
       kDebug() << "ldap_sasl_bind (simple)";
       int msgid;
+#ifndef HAVE_WINLDAP_H
       ret = ldap_sasl_bind( ld, bindname.data(), 0, &ccred, 0, 0, &msgid );
-//    ret = ldap_simple_bind( ld, bindname.data(),pass.data() );
+#else
+      ret = ldap_simple_bind( ld, bindname.data(),pass.data() );
+#endif
       if ( ret == 0 ) {
         ret = msgid;
       }
     } else {
       kDebug() << "ldap_sasl_bind_s (simple)";
+#ifndef HAVE_WINLDAP_H
       ret = ldap_sasl_bind_s( ld, bindname.data(), 0, &ccred, 0, 0, 0 );
-//    ret = ldap_simple_bind_s( ld, bindname.data(), pass.data() );
+#else
+      ret = ldap_simple_bind_s( ld, bindname.data(), pass.data() );
+#endif
     }
   }
   return ret;
@@ -430,16 +440,25 @@
   }
   case RES_BIND:
   {
-    struct berval *servercred;
+    struct berval *servercred = 0;
+#ifndef HAVE_WINLDAP_H
+    // FIXME: Error handling Winldap does not have ldap_parse_sasl_bind_result
     retval = ldap_parse_sasl_bind_result( ld, msg, &servercred, 0 );
+#else
+    retval = KLDAP_SUCCESS;
+#endif
     if ( retval != KLDAP_SUCCESS && retval != KLDAP_SASL_BIND_IN_PROGRESS ) {
       kDebug() << "RES_BIND error: " << retval;
       ldap_msgfree( msg );
       return -1;
     }
     kDebug() << "RES_BIND rescode" << rescode << "retval:" << retval;
-    mServerCred = servercred ? QByteArray( servercred->bv_val, servercred->bv_len ) \
: QByteArray(); +    if ( servercred ) {
+      mServerCred = QByteArray( servercred->bv_val, servercred->bv_len );
     ber_bvfree( servercred );
+    } else {
+      mServerCred = QByteArray();
+    }
     break;
   }
   default:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic