File: urlTest.cpp

package info (click to toggle)
openldap 2.6.10%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 31,080 kB
  • sloc: ansic: 328,961; sh: 51,256; cpp: 6,011; makefile: 3,320; sql: 1,714; perl: 455; python: 184; tcl: 45
file content (41 lines) | stat: -rw-r--r-- 1,398 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// $OpenLDAP$
/*
 * Copyright 2008-2024 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;
    }

}