37 const char *password,
Int_t version)
44 fLd = ldap_init(host, port);
46 Error(
"TLDAPServer",
"error in ldap_init function");
48 if (ldap_set_option(
fLd, LDAP_OPT_PROTOCOL_VERSION, &version) != LDAP_OPT_SUCCESS ) {
49 Error(
"Bind",
"Could not set protocol version!");
64 fPassword(lds.fPassword),
65 fIsConnected(lds.fIsConnected)
99 if (result != LDAP_SUCCESS) {
103 case LDAP_INVALID_CREDENTIALS:
104 Error(
"Bind",
"invalid password");
106 case LDAP_INAPPROPRIATE_AUTH:
107 Error(
"Bind",
"entry has no password to check");
110 Error(
"Bind",
"%s", ldap_err2string(result));
142 const char *namingcontexts = 0;
151 namingcontexts = attribute->
GetValue();
158 return namingcontexts;
171 const char *subschema = 0;
251 const char *filter,
TList *attrs,
261 LDAPMessage *searchresult;
262 char **attrslist = 0;
265 attrslist =
new char* [
n + 1];
266 for (
Int_t i = 0; i <
n; i++)
271 filter =
"(objectClass=*)";
273 errcode = ldap_search_s(
fLd, base, scope, filter, attrslist,
274 attrsonly, &searchresult);
278 if (errcode == LDAP_SUCCESS) {
281 ldap_msgfree(searchresult);
282 Error(
"Search",
"%s", ldap_err2string(errcode));
286 errcode = LDAP_SERVER_DOWN;
287 Error(
"Search",
"%s",
"server is not connected");
307 if (errcode != LDAP_SUCCESS)
308 Error(
"AddEntry",
"%s", ldap_err2string(errcode));
310 errcode = LDAP_SERVER_DOWN;
311 Error(
"AddEntry",
"server is not connected");
336 errcode = ldap_modify_s(
fLd, entry.
GetDn(),
ms);
338 if (errcode != LDAP_SUCCESS)
339 Error(
"ModifyEntry",
"%s", ldap_err2string(errcode));
341 errcode = LDAP_SERVER_DOWN;
342 Error(
"ModifyEntry",
"server is not connected");
358 errcode = ldap_delete_s(
fLd, dn);
359 if (errcode != LDAP_SUCCESS)
360 Error(
"DeleteEntry",
"%s", ldap_err2string(errcode));
362 errcode = LDAP_SERVER_DOWN;
363 Error(
"DeleteEntry",
"server is not connected");
385 errcode = ldap_modrdn2_s(
fLd, dn, newrdn, removeattr);
386 if (errcode != LDAP_SUCCESS)
387 Error(
"RenameEntry",
"%s", ldap_err2string(errcode));
389 errcode = LDAP_SERVER_DOWN;
390 Error(
"RenameEntry",
"server is not connected");
403 ldap_mods_free(mods, 1);
407 while ((mod = mods[i++]) != 0) {
408 if (mod->mod_op & LDAP_MOD_BVALUES) {
409 ber_bvecfree(mod->mod_bvalues);
413 while ((
c = mod->mod_values[j++]) != 0)
416 delete mod->mod_type;
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
const char * GetValue() const
Get next value of the attribute.
TLDAPAttribute * GetAttribute() const
Get next attribute of the entry.
LDAPMod ** GetMods(Int_t op)
Get array of "LDAPMod" structures for entry.
const char * GetDn() const
TLDAPEntry * GetNext()
Returns next entry from the search result.
virtual ~TLDAPServer()
If the object is connected to the server, it disconnects.
Int_t ModifyEntry(TLDAPEntry &entry, Int_t mode=LDAP_MOD_REPLACE)
Modifies specified entry.
TLDAPResult * GetAttributeTypes()
Calls GetSubschemaSubentry() and performs and LDAPSearch with the attribute "attributeTypes" to be re...
Bool_t IsConnected() const
TLDAPResult * GetObjectClasses()
Calls GetSubschemaSubentry() and performs and LDAPSearch with the attribute "objectClasses" to be ret...
const char * GetSubschemaSubentry()
Performs an LDAPSearch with the attribute "subschemaSubentry" to be returned with the result.
TLDAPServer(const TLDAPServer &)
Copy constructor.
void Unbind()
Unbinds from the server with specified binddn and password.
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.
static void DeleteMods(LDAPMod **mods)
Deletes the array of LDAPMod structures and frees its memory.
Int_t AddEntry(TLDAPEntry &entry)
Adds entry to the LDAP tree.
Int_t RenameEntry(const char *dn, const char *newrdn, Bool_t removeattr=kFALSE)
Renames the entry with specified DN, the entry must be leaf Be sure that you are bound with the write...
const char * GetNamingContexts()
Performs an LDAPSearch with the attribute "namingContexts" to be returned with the result.
TLDAPServer & operator=(const TLDAPServer &)
Equal operator.
Int_t DeleteEntry(const char *dn)
Deletes the entry with specified DN, the base entry must exist.
Int_t Bind()
Binds to the server with specified binddn and password.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
virtual void AddLast(TObject *obj)
Add object at the end of the list.
Collectable string class.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
TObject & operator=(const TObject &rhs)
TObject assignment operator.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
const char * Data() const
static constexpr double ms