ROOT logo
void LDAPExample()
{
   gSystem->Load("libRLDAP.so");

   TLDAPServer *server = new TLDAPServer("ldap.cern.ch");

   TLDAPResult *result = server.Search();

   if (result == 0) {
      printf("Search failed\n");
      exit(1);
   }
   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");
      exit(1);
   }

   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;
}
 LDAPExample.C:1
 LDAPExample.C:2
 LDAPExample.C:3
 LDAPExample.C:4
 LDAPExample.C:5
 LDAPExample.C:6
 LDAPExample.C:7
 LDAPExample.C:8
 LDAPExample.C:9
 LDAPExample.C:10
 LDAPExample.C:11
 LDAPExample.C:12
 LDAPExample.C:13
 LDAPExample.C:14
 LDAPExample.C:15
 LDAPExample.C:16
 LDAPExample.C:17
 LDAPExample.C:18
 LDAPExample.C:19
 LDAPExample.C:20
 LDAPExample.C:21
 LDAPExample.C:22
 LDAPExample.C:23
 LDAPExample.C:24
 LDAPExample.C:25
 LDAPExample.C:26
 LDAPExample.C:27
 LDAPExample.C:28
 LDAPExample.C:29
 LDAPExample.C:30
 LDAPExample.C:31
 LDAPExample.C:32
 LDAPExample.C:33
 LDAPExample.C:34
 LDAPExample.C:35
 LDAPExample.C:36
 LDAPExample.C:37
 LDAPExample.C:38
 LDAPExample.C:39
 LDAPExample.C:40
 LDAPExample.C:41
 LDAPExample.C:42
 LDAPExample.C:43
 LDAPExample.C:44
 LDAPExample.C:45
 LDAPExample.C:46
 LDAPExample.C:47
 LDAPExample.C:48
 LDAPExample.C:49
 LDAPExample.C:50
 LDAPExample.C:51
 LDAPExample.C:52
 LDAPExample.C:53