From 183cdd4398e0c31f72825cfe63ab606f075b92f1 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Thu, 18 Feb 2010 16:46:23 +0000 Subject: [PATCH] Example for TlsOptions usage --- contrib/ldapc++/examples/Makefile.am | 5 +- contrib/ldapc++/examples/Makefile.in | 122 ++++++++++++++++++-------- contrib/ldapc++/examples/startTls.cpp | 79 +++++++++++++++++ 3 files changed, 168 insertions(+), 38 deletions(-) create mode 100644 contrib/ldapc++/examples/startTls.cpp diff --git a/contrib/ldapc++/examples/Makefile.am b/contrib/ldapc++/examples/Makefile.am index 14a04e5919..5b6d1a3889 100644 --- a/contrib/ldapc++/examples/Makefile.am +++ b/contrib/ldapc++/examples/Makefile.am @@ -5,7 +5,7 @@ # COPYING RESTRICTIONS APPLY, see COPYRIGHT file ## AM_CPPFLAGS = -I$(top_srcdir)/src -noinst_PROGRAMS = main readSchema urlTest +noinst_PROGRAMS = main readSchema startTls urlTest main_SOURCES = main.cpp main_LDADD = ../src/libldapcpp.la @@ -13,5 +13,8 @@ main_LDADD = ../src/libldapcpp.la readSchema_SOURCES = readSchema.cpp readSchema_LDADD = ../src/libldapcpp.la +startTls_SOURCES = startTls.cpp +startTls_LDADD = ../src/libldapcpp.la + urlTest_SOURCES = urlTest.cpp urlTest_LDADD = ../src/libldapcpp.la diff --git a/contrib/ldapc++/examples/Makefile.in b/contrib/ldapc++/examples/Makefile.in index 5b7568f74c..fe7e9793c0 100644 --- a/contrib/ldapc++/examples/Makefile.in +++ b/contrib/ldapc++/examples/Makefile.in @@ -1,8 +1,9 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -18,8 +19,9 @@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c @@ -34,7 +36,8 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -noinst_PROGRAMS = main$(EXEEXT) readSchema$(EXEEXT) urlTest$(EXEEXT) +noinst_PROGRAMS = main$(EXEEXT) readSchema$(EXEEXT) startTls$(EXEEXT) \ + urlTest$(EXEEXT) subdir = examples DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -44,6 +47,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/src/config.h CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) am_main_OBJECTS = main.$(OBJEXT) main_OBJECTS = $(am_main_OBJECTS) @@ -51,12 +55,16 @@ main_DEPENDENCIES = ../src/libldapcpp.la am_readSchema_OBJECTS = readSchema.$(OBJEXT) readSchema_OBJECTS = $(am_readSchema_OBJECTS) readSchema_DEPENDENCIES = ../src/libldapcpp.la +am_startTls_OBJECTS = startTls.$(OBJEXT) +startTls_OBJECTS = $(am_startTls_OBJECTS) +startTls_DEPENDENCIES = ../src/libldapcpp.la am_urlTest_OBJECTS = urlTest.$(OBJEXT) urlTest_OBJECTS = $(am_urlTest_OBJECTS) urlTest_DEPENDENCIES = ../src/libldapcpp.la DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles +am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ @@ -66,9 +74,10 @@ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ -SOURCES = $(main_SOURCES) $(readSchema_SOURCES) $(urlTest_SOURCES) -DIST_SOURCES = $(main_SOURCES) $(readSchema_SOURCES) \ +SOURCES = $(main_SOURCES) $(readSchema_SOURCES) $(startTls_SOURCES) \ $(urlTest_SOURCES) +DIST_SOURCES = $(main_SOURCES) $(readSchema_SOURCES) \ + $(startTls_SOURCES) $(urlTest_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -92,31 +101,36 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ -ECHO = @ECHO@ +DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ +FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ +NM = @NM@ NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENLDAP_CPP_API_VERSION = @OPENLDAP_CPP_API_VERSION@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ @@ -136,7 +150,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ @@ -167,6 +181,7 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -179,6 +194,7 @@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @@ -189,6 +205,8 @@ main_SOURCES = main.cpp main_LDADD = ../src/libldapcpp.la readSchema_SOURCES = readSchema.cpp readSchema_LDADD = ../src/libldapcpp.la +startTls_SOURCES = startTls.cpp +startTls_LDADD = ../src/libldapcpp.la urlTest_SOURCES = urlTest.cpp urlTest_LDADD = ../src/libldapcpp.la all: all-am @@ -199,14 +217,14 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign examples/Makefile + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign examples/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ @@ -224,19 +242,25 @@ $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; for p in $$list; do \ - f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f $$p $$f"; \ - rm -f $$p $$f ; \ - done + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list main$(EXEEXT): $(main_OBJECTS) $(main_DEPENDENCIES) @rm -f main$(EXEEXT) $(CXXLINK) $(main_OBJECTS) $(main_LDADD) $(LIBS) readSchema$(EXEEXT): $(readSchema_OBJECTS) $(readSchema_DEPENDENCIES) @rm -f readSchema$(EXEEXT) $(CXXLINK) $(readSchema_OBJECTS) $(readSchema_LDADD) $(LIBS) +startTls$(EXEEXT): $(startTls_OBJECTS) $(startTls_DEPENDENCIES) + @rm -f startTls$(EXEEXT) + $(CXXLINK) $(startTls_OBJECTS) $(startTls_LDADD) $(LIBS) urlTest$(EXEEXT): $(urlTest_OBJECTS) $(urlTest_DEPENDENCIES) @rm -f urlTest$(EXEEXT) $(CXXLINK) $(urlTest_OBJECTS) $(urlTest_LDADD) $(LIBS) @@ -249,25 +273,26 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readSchema.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/startTls.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/urlTest.Po@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< @@ -283,14 +308,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) - tags=; \ + set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -298,29 +323,34 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) - tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ + test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique + $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags @@ -341,13 +371,17 @@ distdir: $(DISTFILES) if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @@ -375,6 +409,7 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -396,6 +431,8 @@ dvi-am: html: html-am +html-am: + info: info-am info-am: @@ -404,18 +441,28 @@ install-data-am: install-dvi: install-dvi-am +install-dvi-am: + install-exec-am: install-html: install-html-am +install-html-am: + install-info: install-info-am +install-info-am: + install-man: install-pdf: install-pdf-am +install-pdf-am: + install-ps: install-ps-am +install-ps-am: + installcheck-am: maintainer-clean: maintainer-clean-am @@ -453,6 +500,7 @@ uninstall-am: mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags uninstall uninstall-am + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/contrib/ldapc++/examples/startTls.cpp b/contrib/ldapc++/examples/startTls.cpp new file mode 100644 index 0000000000..3d9a471b12 --- /dev/null +++ b/contrib/ldapc++/examples/startTls.cpp @@ -0,0 +1,79 @@ +// $OpenLDAP$ +/* + * Copyright 2010, OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include +#include +#include "LDAPAsynConnection.h" +#include "TlsOptions.h" + +int main( int argc, char* argv[]){ + if ( argc != 4 ){ + std::cerr << "usage: " << argv[0] << " " << std::endl; + return(-1); + } + std::string uri(argv[1]); + std::string cacert(argv[2]); + std::string cadir(argv[3]); + TlsOptions tls; + std::cout << "Current global settings:" << std::endl; + std::cout << " CaCertfile: " << tls.getStringOption( TlsOptions::CACERTFILE) << std::endl; + std::cout << " CaCertDir: " << tls.getStringOption( TlsOptions::CACERTDIR ) << std::endl; + std::cout << " Require Cert: " << tls.getIntOption( TlsOptions::REQUIRE_CERT ) << std::endl; + std::cout << "Applying new settings:" << std::endl; + tls.setOption( TlsOptions::CACERTFILE, cacert ); + tls.setOption( TlsOptions::REQUIRE_CERT, TlsOptions::DEMAND ); + std::cout << " CaCertfile: " << tls.getStringOption( TlsOptions::CACERTFILE ) << std::endl; + std::cout << " Require Cert: " << tls.getIntOption( TlsOptions::REQUIRE_CERT ) << std::endl; + + try { + // 1. connect using global options + LDAPAsynConnection l(uri); + try { + l.start_tls(); + std::cout << "StartTLS successful." << std::endl; + l.unbind(); + } catch ( LDAPException e ) { + std::cerr << e << std::endl; + } + + // 2. connect using connection specific option + l = LDAPAsynConnection(uri); + tls=l.getTlsOptions(); + std::cout << "Current connection specific settings:" << std::endl; + std::cout << " CaCertfile: " << tls.getStringOption( TlsOptions::CACERTFILE) << std::endl; + std::cout << " CaCertDir: " << tls.getStringOption( TlsOptions::CACERTDIR ) << std::endl; + std::cout << " Require Cert: " << tls.getIntOption( TlsOptions::REQUIRE_CERT ) << std::endl; + std::cout << "Applying new settings:" << std::endl; + tls.setOption( TlsOptions::CACERTDIR, cadir ); + tls.setOption( TlsOptions::REQUIRE_CERT, TlsOptions::DEMAND ); + std::cout << " CaCertDir: " << tls.getStringOption( TlsOptions::CACERTDIR ) << std::endl; + std::cout << " Require Cert: " << tls.getIntOption( TlsOptions::REQUIRE_CERT ) << std::endl; + try { + l.start_tls(); + std::cout << "StartTLS successful." << std::endl; + l.unbind(); + } catch ( LDAPException e ) { + std::cerr << e << std::endl; + } + + // 3. and once again using the globals + try { + LDAPAsynConnection l2(uri); + TlsOptions tls2; + std::cout << "Current global settings:" << std::endl; + std::cout << " CaCertfile: " << tls2.getStringOption( TlsOptions::CACERTFILE) << std::endl; + std::cout << " CaCertDir: " << tls2.getStringOption( TlsOptions::CACERTDIR ) << std::endl; + std::cout << " Require Cert: " << tls2.getIntOption( TlsOptions::REQUIRE_CERT ) << std::endl; + l2.start_tls(); + std::cout << "StartTLS successful." << std::endl; + l2.unbind(); + } catch ( LDAPException e ) { + std::cerr << e << std::endl; + } + } catch ( LDAPException e ) { + std::cerr << e << std::endl; + } +} -- 2.39.5