mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-25 00:59:45 -05:00
example code for the LDAPUrl Class
This commit is contained in:
parent
804ff1ed94
commit
2d2ad0e314
3 changed files with 51 additions and 4 deletions
|
|
@ -2,10 +2,13 @@
|
|||
# Copyright 2003, OpenLDAP Foundation, All Rights Reserved.
|
||||
# COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
||||
##
|
||||
noinst_PROGRAMS = main readSchema
|
||||
noinst_PROGRAMS = main readSchema urlTest
|
||||
|
||||
main_SOURCES = main.cpp
|
||||
main_LDADD = ../src/libldapcpp.la
|
||||
|
||||
readSchema_SOURCES = readSchema.cpp
|
||||
readSchema_LDADD = ../src/libldapcpp.la
|
||||
|
||||
urlTest_SOURCES = urlTest.cpp
|
||||
urlTest_LDADD = ../src/libldapcpp.la
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ PRE_UNINSTALL = :
|
|||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
noinst_PROGRAMS = main$(EXEEXT) readSchema$(EXEEXT)
|
||||
noinst_PROGRAMS = main$(EXEEXT) readSchema$(EXEEXT) urlTest$(EXEEXT)
|
||||
subdir = examples
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
|
|
@ -53,6 +53,9 @@ main_DEPENDENCIES = ../src/libldapcpp.la
|
|||
am_readSchema_OBJECTS = readSchema.$(OBJEXT)
|
||||
readSchema_OBJECTS = $(am_readSchema_OBJECTS)
|
||||
readSchema_DEPENDENCIES = ../src/libldapcpp.la
|
||||
am_urlTest_OBJECTS = urlTest.$(OBJEXT)
|
||||
urlTest_OBJECTS = $(am_urlTest_OBJECTS)
|
||||
urlTest_DEPENDENCIES = ../src/libldapcpp.la
|
||||
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/src
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
|
|
@ -64,8 +67,9 @@ LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \
|
|||
CXXLD = $(CXX)
|
||||
CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \
|
||||
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
SOURCES = $(main_SOURCES) $(readSchema_SOURCES)
|
||||
DIST_SOURCES = $(main_SOURCES) $(readSchema_SOURCES)
|
||||
SOURCES = $(main_SOURCES) $(readSchema_SOURCES) $(urlTest_SOURCES)
|
||||
DIST_SOURCES = $(main_SOURCES) $(readSchema_SOURCES) \
|
||||
$(urlTest_SOURCES)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
|
@ -169,6 +173,8 @@ main_SOURCES = main.cpp
|
|||
main_LDADD = ../src/libldapcpp.la
|
||||
readSchema_SOURCES = readSchema.cpp
|
||||
readSchema_LDADD = ../src/libldapcpp.la
|
||||
urlTest_SOURCES = urlTest.cpp
|
||||
urlTest_LDADD = ../src/libldapcpp.la
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
|
|
@ -215,6 +221,9 @@ main$(EXEEXT): $(main_OBJECTS) $(main_DEPENDENCIES)
|
|||
readSchema$(EXEEXT): $(readSchema_OBJECTS) $(readSchema_DEPENDENCIES)
|
||||
@rm -f readSchema$(EXEEXT)
|
||||
$(CXXLINK) $(readSchema_LDFLAGS) $(readSchema_OBJECTS) $(readSchema_LDADD) $(LIBS)
|
||||
urlTest$(EXEEXT): $(urlTest_OBJECTS) $(urlTest_DEPENDENCIES)
|
||||
@rm -f urlTest$(EXEEXT)
|
||||
$(CXXLINK) $(urlTest_LDFLAGS) $(urlTest_OBJECTS) $(urlTest_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
|
@ -224,6 +233,7 @@ 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)/urlTest.Po@am__quote@
|
||||
|
||||
.cpp.o:
|
||||
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
|
||||
|
|
|
|||
34
contrib/ldapc++/examples/urlTest.cpp
Normal file
34
contrib/ldapc++/examples/urlTest.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#include <LDAPUrl.h>
|
||||
#include <LDAPException.h>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if ( argc != 2 ) {
|
||||
std::cout << argc << std::endl;
|
||||
std::cout << "urlTest <ldap-URI>" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
std::string uristr = argv[1];
|
||||
try {
|
||||
LDAPUrl url(uristr);
|
||||
std::cout << "Host: " << url.getHost() << std::endl;
|
||||
std::cout << "Port: " << url.getPort() << std::endl;
|
||||
std::cout << "BaseDN: " << url.getDN() << std::endl;
|
||||
std::cout << "Scope: " << url.getScope() << std::endl;
|
||||
StringList attrs = url.getAttrs();
|
||||
std::cout << "Attrs: " << std::endl;
|
||||
StringList::const_iterator i = attrs.begin();
|
||||
for( ; i != attrs.end(); i++ ) {
|
||||
std::cout << " " << *i << std::endl;
|
||||
}
|
||||
std::cout << "Filter: " << url.getFilter() << std::endl;
|
||||
std::cout << "Setting new BaseDN" << std::endl;
|
||||
url.setDN("o=Beispiel, c=DE");
|
||||
std::cout << "Url: " << url.getURLString() << std::endl;
|
||||
} catch (LDAPUrlException e) {
|
||||
std::cout << e.getCode() << std::endl;
|
||||
std::cout << e.getErrorMessage() << std::endl;
|
||||
std::cout << e.getAdditionalInfo() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue