summaryrefslogtreecommitdiffstats
path: root/contrib/ldapc++/examples/urlTest.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:35:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:35:32 +0000
commit5ea77a75dd2d2158401331879f3c8f47940a732c (patch)
treed89dc06e9f4850a900f161e25f84e922c4f86cc8 /contrib/ldapc++/examples/urlTest.cpp
parentInitial commit. (diff)
downloadopenldap-5ea77a75dd2d2158401331879f3c8f47940a732c.tar.xz
openldap-5ea77a75dd2d2158401331879f3c8f47940a732c.zip
Adding upstream version 2.5.13+dfsg.upstream/2.5.13+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'contrib/ldapc++/examples/urlTest.cpp')
-rw-r--r--contrib/ldapc++/examples/urlTest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/contrib/ldapc++/examples/urlTest.cpp b/contrib/ldapc++/examples/urlTest.cpp
new file mode 100644
index 0000000..6223630
--- /dev/null
+++ b/contrib/ldapc++/examples/urlTest.cpp
@@ -0,0 +1,41 @@
+// $OpenLDAP$
+/*
+ * Copyright 2008-2022 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include <LDAPUrl.h>
+#include <LDAPException.h>
+#include <cstdlib>
+#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;
+ }
+
+}