[gq-commit] gq/src browse.c,1.59,1.60
Status: Beta
Brought to you by:
sur5r
From: <sta...@us...> - 2002-09-26 19:03:08
|
Update of /cvsroot/gqclient/gq/src In directory usw-pr-cvs1:/tmp/cvs-serv13767 Modified Files: browse.c Log Message: * Add information taken from the root DSE into the details for a server entry in the browse tree. This should finally close a TODO item introduced by Bert * Back out changes to search for user AND operational attributes, because + it is an openldap extension (?) [but works for other servers as well] + operational attributes should not be part of a selection anyway Index: browse.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/browse.c,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** browse.c 18 Sep 2002 07:29:10 -0000 1.59 --- browse.c 26 Sep 2002 19:03:01 -0000 1.60 *************** *** 708,711 **** --- 708,724 ---- int rc; /* void *optdata; */ + char *rootDSEattr[] = { + "vendorName", _("Vendor Name"), /* RFC 3045 */ + "vendorVersion", _("Vendor Version"), /* RFC 3045 */ + "altServer", _("Alternative Server(s)"), /* RFC 2251 */ + "supportedLDAPVersion", _("Supported LDAP Version"), /* RFC 2251 */ + "supportedSASLMechanisms", _("Supported SASL Mechanisms"), /* RFC 2251 */ + NULL + }; + LDAPMessage *res, *ee; + BerElement *berptr; + char *attr; + char **vals; + int i, msg; rc = ldap_get_option(ld, LDAP_OPT_PROTOCOL_VERSION, &intdata); *************** *** 735,738 **** --- 748,820 ---- row++; + /* read some Information from the root DSE */ + for (i = 0 ; rootDSEattr[i] && ld != NULL ; i += 2) { + char *attrs[2] = { rootDSEattr[i], NULL }; + + msg = ldap_search_s(ld, "", LDAP_SCOPE_BASE, "(objectclass=*)", + attrs, 0, &res); + if(msg != LDAP_SUCCESS) { + if (msg == LDAP_SERVER_DOWN) { + close_connection(entry->server, FALSE); + ld = open_connection(entry->server); + } + statusbar_msg(ldap_err2string(msg)); + } else { + if(res == NULL) continue; + ee = ldap_first_entry(ld, res); + + if (ee == NULL) { + ldap_msgfree(res); + continue; + } + attr = ldap_first_attribute(ld, res, &berptr); + + if (attr == NULL) { + ldap_msgfree(res); + #ifndef HAVE_OPENLDAP_12 + if(berptr) ber_free(berptr, 0); + #endif + continue; + } + vals = ldap_get_values(ld, res, attr); + if (vals) { + int j; + for (j = 0 ; vals[j] ; j++) ; + + label = gtk_label_new(rootDSEattr[i + 1]); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), + label, + 0, 1, row, row+j, + GTK_SHRINK, + GTK_EXPAND | GTK_SHRINK | GTK_FILL, + 0, 0); + + for (j = 0 ; vals[j] ; j++) { + snprintf(buf, sizeof(buf), "%s", vals[j]); + e = gtk_entry_new(); + gtk_entry_set_text(GTK_ENTRY(e), buf); + gtk_widget_set_sensitive(e, FALSE); + gtk_widget_show(e); + gtk_table_attach(GTK_TABLE(table), + e, + 1, 2, row, row+1, + GTK_EXPAND | GTK_SHRINK | GTK_FILL, + GTK_EXPAND | GTK_SHRINK | GTK_FILL, + 0, 0); + row++; + } + + + ldap_value_free(vals); + } + + ldap_memfree(attr); + #ifndef HAVE_OPENLDAP_12 + if(berptr) ber_free(berptr, 0); + #endif + ldap_msgfree(res); + } + } close_connection(entry->server, FALSE); } *************** *** 1471,1475 **** int written; char message[512]; - char *attrs[] = { "*", "+", NULL }; int ctx; --- 1553,1556 ---- *************** *** 1539,1543 **** msg = ldap_search_s(ld, (char *) I->data, LDAP_SCOPE_SUBTREE, ! "(objectclass=*)", attrs, 0, &res); if(msg == LDAP_SUCCESS) { for(e = ldap_first_entry(ld, res); e; e = ldap_next_entry(ld, e)) { --- 1620,1624 ---- msg = ldap_search_s(ld, (char *) I->data, LDAP_SCOPE_SUBTREE, ! "(objectclass=*)", NULL, 0, &res); if(msg == LDAP_SUCCESS) { for(e = ldap_first_entry(ld, res); e; e = ldap_next_entry(ld, e)) { |