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");
304 LDAPMod **ms = entry.
GetMods(0);
305 errcode = ldap_add_s(
fLd, entry.
GetDn(), ms);
307 if (errcode != LDAP_SUCCESS)
308 Error(
"AddEntry",
"%s", ldap_err2string(errcode));
310 errcode = LDAP_SERVER_DOWN;
311 Error(
"AddEntry",
"server is not connected");
335 LDAPMod **ms = entry.
GetMods(mode);
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;
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.
TLDAPResult * GetAttributeTypes()
Calls GetSubschemaSubentry() and performs and LDAPSearch with the attribute "attributeTypes" to be re...
Collectable string class.
Bool_t IsConnected() const
const char * GetSubschemaSubentry()
Performs an LDAPSearch with the attribute "subschemaSubentry" to be returned with the result...
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
const char * GetNamingContexts()
Performs an LDAPSearch with the attribute "namingContexts" to be returned with the result...
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...
virtual void AddLast(TObject *obj)
Add object at the end of the list.
TLDAPResult * GetObjectClasses()
Calls GetSubschemaSubentry() and performs and LDAPSearch with the attribute "objectClasses" to be ret...
Int_t ModifyEntry(TLDAPEntry &entry, Int_t mode=LDAP_MOD_REPLACE)
Modifies specified entry.
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Int_t DeleteEntry(const char *dn)
Deletes the entry with specified DN, the base entry must exist.
void Error(const char *location, const char *msgfmt,...)
TLDAPAttribute * GetAttribute() const
Get next attribute of the entry.
virtual ~TLDAPServer()
If the object is connected to the server, it disconnects.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
LDAPMod ** GetMods(Int_t op)
Get array of "LDAPMod" structures for entry.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
TLDAPServer & operator=(const TLDAPServer &)
Equal operator.
TLDAPEntry * GetNext()
Returns next entry from the search result.
void Unbind()
Unbinds from the server with specified binddn and password.
static void DeleteMods(LDAPMod **mods)
Deletes the array of LDAPMod structures and frees its memory.
Mother of all ROOT objects.
Int_t Bind()
Binds to the server with specified binddn and password.
const char * GetDn() const
Int_t AddEntry(TLDAPEntry &entry)
Adds entry to the LDAP tree.
TLDAPServer(const TLDAPServer &)
Copy constructor.
virtual const char * GetName() const
Returns name of object.
virtual Int_t GetSize() const
const char * GetValue() const
Get next value of the attribute.
const char * Data() const