Logo ROOT   6.16/01
Reference Guide
LDAPExample.C File Reference

Detailed Description

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;
}
int Int_t
Definition: RtypesCore.h:41
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
Int_t GetCount() const
const char * GetValue() const
Get next value of the attribute.
TLDAPAttribute * GetAttribute() const
Get next attribute of the entry.
Definition: TLDAPEntry.cxx:96
void Print(Option_t *="") const
Print entry in LDIF format.
Definition: TLDAPEntry.cxx:77
const char * GetDn() const
Definition: TLDAPEntry.h:41
TLDAPEntry * GetNext()
Returns next entry from the search result.
Definition: TLDAPResult.cxx:68
Int_t GetCount() const
Returns the number of entries in the search result.
void Print(Option_t *option="") const
Prints all entries.
Bool_t IsConnected() const
Definition: TLDAPServer.h:45
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.
const char * GetNamingContexts()
Performs an LDAPSearch with the attribute "namingContexts" to be returned with the result.
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Basic string class.
Definition: TString.h:131
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1843
Author

Definition in file LDAPExample.C.