ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LDAPExample.C
Go to the documentation of this file.
1 void LDAPExample()
2 {
3  gSystem->Load("libRLDAP.so");
4 
5  TLDAPServer *server = new TLDAPServer("ldap.cern.ch");
6  if (!server->IsConnected()) {
7  printf("Could not connect to ldap.cern.ch\n");
8  delete server;
9  return;
10  }
11 
12  TLDAPResult *result = server.Search();
13 
14  if (result == 0) {
15  printf("Search failed\n");
16  return;
17  }
18  result->Print();
19  delete result;
20 
21  const char *namingcontexts = server.GetNamingContexts();
22  result = server.Search(namingcontexts, LDAP_SCOPE_ONELEVEL, 0, 0, 1);
23  TLDAPEntry *entry = result.GetNext();
24  entry->Print();
25 
26  TString dn = entry->GetDn();
27 
28  delete result;
29  delete entry;
30 
31  cout << "The DN of the entry is " << dn << endl;
32 
33  result = server.Search(dn, LDAP_SCOPE_SUBTREE, 0, 0, 0);
34 
35  if (result == 0) {
36  printf("Search failed\n");
37  return;
38  }
39 
40  result->Print();
41  Int_t counter = result.GetCount();
42  cout << "The result contains " << counter << " entries !!!" << endl;
43 
44  entry = result.GetNext();
45 
46  TLDAPAttribute *attribute = entry.GetAttribute("member");
47 
48  Int_t counter2 = attribute.GetCount();
49  cout << "The attribute " << attribute.GetName() << " contains "
50  << counter2 << " values !!!" << endl;
51  const char *value = attribute.GetValue();
52  cout << "The first value of the attribute is " << endl;
53  cout << value << endl;
54 
55  delete result;
56  delete entry;
57 }
TLDAPResult * Search(const char *base="", Int_t scope=LDAP_SCOPE_BASE, const char *filter=0, TList *attrs=0, Bool_t attrsonly=0)
Performs searching at the LDAP directory.
Int_t GetCount() const
Returns the number of entries in the search result.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1766
Basic string class.
Definition: TString.h:137
const char * GetNamingContexts()
Performs an LDAPSearch with the attribute "namingContexts" to be returned with the result...
int Int_t
Definition: RtypesCore.h:41
Int_t GetCount() const
const char * GetValue() const
Get next value of the attribute.
const char * GetDn() const
Definition: TLDAPEntry.h:49
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
Bool_t IsConnected() const
Definition: TLDAPServer.h:51
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
TLDAPAttribute * GetAttribute() const
Get next attribute of the entry.
Definition: TLDAPEntry.cxx:96
Long64_t entry
TLDAPEntry * GetNext()
Returns next entry from the search result.
Definition: TLDAPResult.cxx:68
void LDAPExample()
Definition: LDAPExample.C:1
void Print(Option_t *option="") const
Prints all entries.
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
double result[121]
float value
Definition: math.cpp:443
void Print(Option_t *="") const
Print entry in LDIF format.
Definition: TLDAPEntry.cxx:77