swh:1:snp:af87cd67498ef4fe47c76ed3e7caffe5b61facaf
Raw File
Tip revision: 59fe6578eda8d4c55e125a80e956ef4431ab5322 authored by Pere Mato on 04 March 2016, 14:47:28 UTC
Update ROOT version files to v6.07/04.
Tip revision: 59fe657
LDAPExample.C
void LDAPExample()
{
   gSystem->Load("libRLDAP.so");

   TLDAPServer *server = new TLDAPServer("ldap.cern.ch");
   if (!server->IsConnected()) {
      printf("Could not connect to ldap.cern.ch\n");
      delete server;
      return;
   }

   TLDAPResult *result = server.Search();

   if (result == 0) {
      printf("Search failed\n");
      return;
   }
   result->Print();
   delete result;

   const char *namingcontexts = server.GetNamingContexts();
   result = server.Search(namingcontexts, LDAP_SCOPE_ONELEVEL, 0, 0, 1);
   TLDAPEntry *entry = result.GetNext();
   entry->Print();

   TString dn = entry->GetDn();

   delete result;
   delete entry;

   cout << "The DN of the entry is " << dn << endl;

   result = server.Search(dn, LDAP_SCOPE_SUBTREE, 0, 0, 0);

   if (result == 0) {
      printf("Search failed\n");
      return;
   }

   result->Print();
   Int_t counter = result.GetCount();
   cout << "The result contains " << counter << " entries !!!" << endl;

   entry = result.GetNext();

   TLDAPAttribute *attribute = entry.GetAttribute("member");

   Int_t counter2 = attribute.GetCount();
   cout << "The attribute " << attribute.GetName() << " contains "
        << counter2 << " values !!!" << endl;
   const char *value = attribute.GetValue();
   cout << "The first value of the attribute is " << endl;
   cout << value << endl;

   delete result;
   delete entry;
}
back to top