]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/examples/urlTest.cpp
need to copy the Entry to safely manipulate it
[openldap] / contrib / ldapc++ / examples / urlTest.cpp
1 #include <LDAPUrl.h>
2 #include <LDAPException.h>
3 #include <iostream>
4
5 int main(int argc, char *argv[]) {
6     if ( argc != 2 ) {
7         std::cout << argc << std::endl;
8         std::cout << "urlTest <ldap-URI>" << std::endl;
9         exit(1);
10     }
11     std::string uristr = argv[1];
12     try {
13         LDAPUrl url(uristr);
14         std::cout << "Host: " << url.getHost() << std::endl;
15         std::cout << "Port: " << url.getPort() << std::endl;
16         std::cout << "BaseDN: " << url.getDN() << std::endl;
17         std::cout << "Scope: " << url.getScope() << std::endl;
18         StringList attrs = url.getAttrs();
19         std::cout << "Attrs: " << std::endl;
20         StringList::const_iterator i = attrs.begin();
21         for( ; i != attrs.end(); i++ ) {
22             std::cout << "    " << *i << std::endl;
23         }
24         std::cout << "Filter: " << url.getFilter() << std::endl;
25         std::cout << "Setting new BaseDN" << std::endl;
26         url.setDN("o=Beispiel, c=DE");
27         std::cout << "Url: " << url.getURLString() << std::endl;
28     } catch (LDAPUrlException e) {
29         std::cout << e.getCode() << std::endl;
30         std::cout << e.getErrorMessage() << std::endl;
31         std::cout << e.getAdditionalInfo() << std::endl;
32     }
33
34 }