Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I use openLDAP from a Qt-Application under Windows
Forum Updated to NodeBB v4.3 + New Features

How can I use openLDAP from a Qt-Application under Windows

Scheduled Pinned Locked Moved Solved General and Desktop
openldap cygwin
10 Posts 3 Posters 4.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    micky
    wrote on 7 Jul 2016, 20:18 last edited by A Former User 7 Sept 2016, 10:59
    #1

    Hello,
    I'm trying to access an openLDAP DB from Qt. Under Linux no problem at all. Under Windows I compiled openLDAP-2.4.44 under cygwin without errors but when I link the resulting libldap and liblber to my program I get:

    C:/Qt/Qt5.6.1/Tools/mingw492_32/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-atonexit.o):atonexit.c:(.text+0xc0): multiple definition of `atexit'
    C:/cygwin/lib/libcygwin.a(atexit.o):/usr/src/debug/cygwin-2.5.2-1/winsup/cygwin/lib/atexit.c:19: first defined here
    
    Can anybody help?
    
    TIA
    Michael
    
    PS: I link: -ldap -lber -ssl -crypto -cygwin
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 7 Jul 2016, 22:11 last edited by
      #2

      Hi,

      I haven't done it but AFAIK, you shouldn't mix Cygwin and MinGW. You'll have to build openLDAP directly with MinGW or build Qt for Cygwin.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • M Offline
        M Offline
        micky
        wrote on 9 Jul 2016, 08:27 last edited by micky 7 Oct 2016, 03:31
        #3

        Hi ,

        I finally found the solution. It's true, you can't mix Qt with cygwin. You have to compile openLDAP with MinGW which is a bit tricky. For those who are interested : Here is my batch (ugly hack ;-) ) to compile openLDAP:

        export PATH=/cygdrive/c/MinGW/bin:/cygdrive/c/cygwin/bin
        export MAKE=C:/MinGW/bin/mingw32-make.exe
        export CC=C:/MinGW/bin/mingw32-gcc.exe
        export SED=C:/cygwin/usr/bin/sed.exe
        
        export CPPFLAGS="-IC:/MinGW/include -IC:/cygwin/usr/local/include"
        export LDFLAGS="-LC:/Qt/Qt5.6.1/Tools/mingw492_32/opt/lib/ -lssl -lcrypto -LC:/cygwin/usr/local/lib -lregex -LC:/MinGW/lib -lws2_32"
        export LIBS="C:/Windows/System32/wsock32.dll"
        
        rm -rf openldap-2.4.44
        tar xvzf openldap-2.4.44.tgz  
        cd openldap-2.4.44
        
        ./configure --prefix=C:/openLDAP --disable-slapd --disable-debug --with-yielding_select=no --with-cyrus-sasl=no
        
        sed -E '/undef HAVE_WINSOCK_H/a#define HAVE_WINSOCK_H 1' include/portable.h > xx ; mv xx include/portable.h
        sed -E '/undef HAVE_WINSOCK\s/a#define HAVE_WINSOCK 1' include/portable.h > xx ; mv xx include/portable.h
        sed -E 's/\/cygdrive\/c/C:/' config.status > xx ; mv xx config.status
        /usr/bin/find . -name Makefile -exec sh -c "sed -E 's/^LN_S\\s*=.*/LN_S = cp/' {} > xx" \; -exec mv xx {} \;
        /usr/bin/find . -name Makefile -exec sh -c "sed -E 's/\/cygdrive\/c/C:/' {} > xx" \; -exec mv xx {} \;
        
        $MAKE depend
        cd libraries/liblber
        $MAKE
        cd ../libldap
        $MAKE libldap.la
        sed -E 's/\/cygdrive\/c/C:/' libldap.la > xx ; mv xx libldap.la
        cd ../libldap_r
        $MAKE libldap_r.la
        sed -E 's/\/cygdrive\/c/C:/' libldap_r.la > xx ; mv xx libldap_r.la
        cd ../..
        
        $MAKE
        $MAKE install
        
        S 1 Reply Last reply 27 Sept 2019, 06:19
        2
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 9 Jul 2016, 21:53 last edited by
          #4

          Out of curiosity, why do you have cygdrive in your PATH and MAKE ? the MinGW provided by Qt should contain what you need, doesn't it ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply 10 Jul 2016, 03:25
          1
          • S SGaist
            9 Jul 2016, 21:53

            Out of curiosity, why do you have cygdrive in your PATH and MAKE ? the MinGW provided by Qt should contain what you need, doesn't it ?

            M Offline
            M Offline
            micky
            wrote on 10 Jul 2016, 03:25 last edited by
            #5

            Because the sed provided with MinGW didn't work correctly. I don't know any more the exact details.
            As mentioned before: It's a hack that works for me. Perhaps I optimize it in the future (and integrate openLDAP into MXE)

            Regards
            Michael

            1 Reply Last reply
            1
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 10 Jul 2016, 22:03 last edited by
              #6

              Good to know, thanks for the details.

              Happy hacking !

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M micky
                9 Jul 2016, 08:27

                Hi ,

                I finally found the solution. It's true, you can't mix Qt with cygwin. You have to compile openLDAP with MinGW which is a bit tricky. For those who are interested : Here is my batch (ugly hack ;-) ) to compile openLDAP:

                export PATH=/cygdrive/c/MinGW/bin:/cygdrive/c/cygwin/bin
                export MAKE=C:/MinGW/bin/mingw32-make.exe
                export CC=C:/MinGW/bin/mingw32-gcc.exe
                export SED=C:/cygwin/usr/bin/sed.exe
                
                export CPPFLAGS="-IC:/MinGW/include -IC:/cygwin/usr/local/include"
                export LDFLAGS="-LC:/Qt/Qt5.6.1/Tools/mingw492_32/opt/lib/ -lssl -lcrypto -LC:/cygwin/usr/local/lib -lregex -LC:/MinGW/lib -lws2_32"
                export LIBS="C:/Windows/System32/wsock32.dll"
                
                rm -rf openldap-2.4.44
                tar xvzf openldap-2.4.44.tgz  
                cd openldap-2.4.44
                
                ./configure --prefix=C:/openLDAP --disable-slapd --disable-debug --with-yielding_select=no --with-cyrus-sasl=no
                
                sed -E '/undef HAVE_WINSOCK_H/a#define HAVE_WINSOCK_H 1' include/portable.h > xx ; mv xx include/portable.h
                sed -E '/undef HAVE_WINSOCK\s/a#define HAVE_WINSOCK 1' include/portable.h > xx ; mv xx include/portable.h
                sed -E 's/\/cygdrive\/c/C:/' config.status > xx ; mv xx config.status
                /usr/bin/find . -name Makefile -exec sh -c "sed -E 's/^LN_S\\s*=.*/LN_S = cp/' {} > xx" \; -exec mv xx {} \;
                /usr/bin/find . -name Makefile -exec sh -c "sed -E 's/\/cygdrive\/c/C:/' {} > xx" \; -exec mv xx {} \;
                
                $MAKE depend
                cd libraries/liblber
                $MAKE
                cd ../libldap
                $MAKE libldap.la
                sed -E 's/\/cygdrive\/c/C:/' libldap.la > xx ; mv xx libldap.la
                cd ../libldap_r
                $MAKE libldap_r.la
                sed -E 's/\/cygdrive\/c/C:/' libldap_r.la > xx ; mv xx libldap_r.la
                cd ../..
                
                $MAKE
                $MAKE install
                
                S Offline
                S Offline
                Surendar Dharani
                wrote on 27 Sept 2019, 06:19 last edited by
                #7

                @micky can you tell for ubuntu linux platform?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 27 Sept 2019, 18:24 last edited by
                  #8

                  Install the libldap2-dev package.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • S Offline
                    S Offline
                    Surendar Dharani
                    wrote on 3 Oct 2019, 12:06 last edited by Surendar Dharani 10 Mar 2019, 12:13
                    #9

                    I got connection with ldap / active directory. Now i want to check and retrieve the particular user's data.

                    lc->bind("cn=admin,dc=domain,dc=org", "pass",cons); bool result = lc->compare("cn=admin,dc=domain,dc=org", LDAPAttribute("cn","admin")); LDAPAttributeList* attrs=new LDAPAttributeList(); std::cout << "Attribute List ID: " << attrs << std::endl; LDAPSearchResults* entries = lc->search("DC=doamin,DC=org", LDAPConnection::SEARCH_ONE);

                    if (entries != 0){ LDAPEntry* entry = entries->getNext(); if(entry != 0){ std::cout << *(entry) << std::endl; } while(entry){ try{ entry = entries->getNext(); if(entry != 0){ std::cout << *(entry) << std::endl; } delete entry; }catch(LDAPReferralException e){ std::cout << "Caught Referral" << std::endl; } } }

                    Here it returns user groups and lots od cn, and dc, users list and etc.
                    But i want to check one particular user is exist or not in from this output and if exist i need that user's data.

                    Plz help. Thanks in advance.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 3 Oct 2019, 19:22 last edited by
                      #10

                      That's something you should ask the library developers.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved