1// OpenLDAP: pkg/ldap/contrib/ldapc++/examples/urlTest.cpp,v 1.1.2.3 2008/04/14 23:18:59 quanah Exp
2/*
3 * Copyright 2008, OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5 */
6
7#include <LDAPUrl.h>
8#include <LDAPException.h>
9#include <cstdlib>
10#include <iostream>
11
12int main(int argc, char *argv[]) {
13    if ( argc != 2 ) {
14        std::cout << argc << std::endl;
15        std::cout << "urlTest <ldap-URI>" << std::endl;
16        exit(1);
17    }
18    std::string uristr = argv[1];
19    try {
20        LDAPUrl url(uristr);
21        std::cout << "Host: " << url.getHost() << std::endl;
22        std::cout << "Port: " << url.getPort() << std::endl;
23        std::cout << "BaseDN: " << url.getDN() << std::endl;
24        std::cout << "Scope: " << url.getScope() << std::endl;
25        StringList attrs = url.getAttrs();
26        std::cout << "Attrs: " << std::endl;
27        StringList::const_iterator i = attrs.begin();
28        for( ; i != attrs.end(); i++ ) {
29            std::cout << "    " << *i << std::endl;
30        }
31        std::cout << "Filter: " << url.getFilter() << std::endl;
32        std::cout << "Setting new BaseDN" << std::endl;
33        url.setDN("o=Beispiel, c=DE");
34        std::cout << "Url: " << url.getURLString() << std::endl;
35    } catch (LDAPUrlException e) {
36        std::cout << e.getCode() << std::endl;
37        std::cout << e.getErrorMessage() << std::endl;
38        std::cout << e.getAdditionalInfo() << std::endl;
39    }
40
41}
42