Back to index

openldap  2.4.31
urlTest.cpp
Go to the documentation of this file.
00001 // $OpenLDAP$
00002 /*
00003  * Copyright 2008-2012 The OpenLDAP Foundation, All Rights Reserved.
00004  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
00005  */
00006 
00007 #include <LDAPUrl.h>
00008 #include <LDAPException.h>
00009 #include <cstdlib>
00010 #include <iostream>
00011 
00012 int main(int argc, char *argv[]) {
00013     if ( argc != 2 ) {
00014         std::cout << argc << std::endl;
00015         std::cout << "urlTest <ldap-URI>" << std::endl;
00016         exit(1);
00017     }
00018     std::string uristr = argv[1];
00019     try {
00020         LDAPUrl url(uristr);
00021         std::cout << "Host: " << url.getHost() << std::endl;
00022         std::cout << "Port: " << url.getPort() << std::endl;
00023         std::cout << "BaseDN: " << url.getDN() << std::endl;
00024         std::cout << "Scope: " << url.getScope() << std::endl;
00025         StringList attrs = url.getAttrs();
00026         std::cout << "Attrs: " << std::endl;
00027         StringList::const_iterator i = attrs.begin();
00028         for( ; i != attrs.end(); i++ ) {
00029             std::cout << "    " << *i << std::endl;
00030         }
00031         std::cout << "Filter: " << url.getFilter() << std::endl;
00032         std::cout << "Setting new BaseDN" << std::endl;
00033         url.setDN("o=Beispiel, c=DE");
00034         std::cout << "Url: " << url.getURLString() << std::endl;
00035     } catch (LDAPUrlException e) {
00036         std::cout << e.getCode() << std::endl;
00037         std::cout << e.getErrorMessage() << std::endl;
00038         std::cout << e.getAdditionalInfo() << std::endl;
00039     }
00040 
00041 }