LDAPExample.C

Go to the documentation of this file.
00001 void LDAPExample()
00002 {
00003    gSystem->Load("libRLDAP.so");
00004 
00005    TLDAPServer *server = new TLDAPServer("ldap.cern.ch");
00006 
00007    TLDAPResult *result = server.Search();
00008 
00009    if (result == 0) {
00010       printf("Search failed\n");
00011       exit(1);
00012    }
00013    result->Print();
00014    delete result;
00015 
00016    const char *namingcontexts = server.GetNamingContexts();
00017    result = server.Search(namingcontexts, LDAP_SCOPE_ONELEVEL, 0, 0, 1);
00018    TLDAPEntry *entry = result.GetNext();
00019    entry->Print();
00020 
00021    TString dn = entry->GetDn();
00022 
00023    delete result;
00024    delete entry;
00025 
00026    cout << "The DN of the entry is " << dn << endl;
00027 
00028    result = server.Search(dn, LDAP_SCOPE_SUBTREE, 0, 0, 0);
00029 
00030    if (result == 0) {
00031       printf("Search failed\n");
00032       exit(1);
00033    }
00034 
00035    result->Print();
00036    Int_t counter = result.GetCount();
00037    cout << "The result contains " << counter << " entries !!!" << endl;
00038 
00039    entry = result.GetNext();
00040 
00041    TLDAPAttribute *attribute = entry.GetAttribute("member");
00042 
00043    Int_t counter2 = attribute.GetCount();
00044    cout << "The attribute " << attribute.GetName() << " contains "
00045         << counter2 << " values !!!" << endl;
00046    const char *value = attribute.GetValue();
00047    cout << "The first value of the attribute is " << endl;
00048    cout << value << endl;
00049 
00050    delete result;
00051    delete entry;
00052 }

Generated on Tue Jul 5 15:44:52 2011 for ROOT_528-00b_version by  doxygen 1.5.1