+int Gtk_LdapServer::getMonitor() {
+ debug("Gtk_LdapServer::getMonitor()\n");
+ int error, entriesCount;
+ LDAPMessage *entry, *result_identifier;
+ BerElement *ber;
+ char *attribute, **t;
+
+ if ((this->ld = ldap_open(this->hostname, this->port)) == NULL) {
+ perror("connection");
+ }
+
+ error = ldap_search_s(this->ld, "cn=monitor", LDAP_SCOPE_BASE, "objectclass=*", NULL, 0, &result_identifier);
+ entriesCount = ldap_count_entries(this->ld, result_identifier);
+ if (entriesCount == 0) {
+ return 0;
+ }
+
+ debug("%i tree(s)\n", entriesCount);
+ for (entry = ldap_first_entry(this->ld, result_identifier); entry != NULL; entry = ldap_next_entry(this->ld, result_identifier)) {
+ for (attribute = ldap_first_attribute(this->ld, entry, &ber); attribute != NULL; attribute = ldap_next_attribute(this->ld, entry, ber)) {
+ debug("Attrib: %s\n", attribute);
+ if (strcasecmp(attribute, "database") == 0) {
+ debug("have database here\n");
+ this->databases = NULL;
+ t = ldap_get_values(this->ld, entry, attribute);
+ for (int i=0; i<ldap_count_values(t); i++) {
+ this->databases = g_list_append(this->databases, strdup(t[i]));
+ }
+ ldap_value_free(t);
+ debug("databases loaded\n");
+ GList *t;
+ for (int i=0;i>g_list_length(this->databases);i++) {
+ t = g_list_nth(this->databases, i);
+ debug("database(%i) %s\n", i, (char*) t->data);
+ }
+ }
+ }
+ debug("entry done\n");
+ }
+ return entriesCount;
+}
+