*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
/*
rc = ldap_start_tls_s(ld, NULL, NULL);
if (rc != LDAP_SUCCESS) {
- fprintf(stderr, "LDAP Error(tls): ldap_simple_bind_s: %s\n",
+ g_printerr("LDAP Error(tls): ldap_simple_bind_s: %s\n",
ldap_err2string(rc));
return NULL;
}
if (* ctl->bindDN != '\0') {
rc = claws_ldap_simple_bind_s(ld, ctl->bindDN, ctl->bindPass);
if (rc != LDAP_SUCCESS) {
- fprintf(stderr, "bindDN: %s, bindPass: %s\n", ctl->bindDN, ctl->bindPass);
- fprintf(stderr, "LDAP Error(bind): ldap_simple_bind_s: %s\n",
+ g_printerr("bindDN: %s, bindPass: %s\n", ctl->bindDN, ctl->bindPass);
+ g_printerr("LDAP Error(bind): ldap_simple_bind_s: %s\n",
ldap_err2string(rc));
return NULL;
}
int i;
g_return_if_fail(mods != NULL);
- fprintf( stderr, "Type\n");
+ g_printerr( "Type\n");
for (i = 0; NULL != mods[i]; i++) {
LDAPMod *mod = (LDAPMod *) mods[i];
gchar **vals;
case LDAP_MOD_DELETE: mod_op = g_strdup("DELETE"); break;
default: mod_op = g_strdup("UNKNOWN");
}
- fprintf( stderr, "Operation: %s\tType:%s\nValues:\n", mod_op, mod->mod_type);
+ g_printerr( "Operation: %s\tType:%s\nValues:\n", mod_op, mod->mod_type);
vals = mod->mod_vals.modv_strvals;
while (*vals) {
- fprintf( stderr, "\t%s\n", *vals++);
+ g_printerr( "\t%s\n", *vals++);
}
}
}
if (!value || strcmp(value, "") == 0)
value = g_strdup("thisisonlyadummy");
rc = ldap_compare_s(ld, dn, mods[i]->mod_type, value);
- fprintf(stderr, "ldap_compare for (%s:%s)\" failed[0x%x]: %s\n",
+ g_printerr("ldap_compare for (%s:%s)\" failed[0x%x]: %s\n",
mods[i]->mod_type, value, rc, ldap_err2string(rc));
g_free(value);
}
if (ctl) {
rc = ldap_search_s(ld, ctl->baseDN, /*LDAP_SCOPE_SUBTREE*/LDAP_SCOPE_ONELEVEL, filter, NULL, 0, &res);
if (rc) {
- fprintf(stderr, "ldap_search for attr=%s\" failed[0x%x]: %s\n",attr, rc, ldap_err2string(rc));
+ g_printerr("ldap_search for attr=%s\" failed[0x%x]: %s\n",attr, rc, ldap_err2string(rc));
retVal = -2;
}
else {
*/
void ldapsvr_handle_other_attributes(LDAP *ld, LdapServer *server, char *dn, GHashTable *contact) {
GList *node;
- gboolean CHECKED_ATTRIBUTE[ATTRIBUTE_SIZE];
+ gboolean CHECKED_ATTRIBUTE[ATTRIBUTE_SIZE + 1];
LDAPMod *mods[ATTRIBUTE_SIZE + 1];
LDAPMod modarr[ATTRIBUTE_SIZE];
gint cnt = 0;
- char *attr[] = {NULL, NULL};
+ char *attr[ATTRIBUTE_SIZE + 1][2];
int mod_op, rc, i;
g_return_if_fail(server != NULL || dn != NULL || contact != NULL);
- for (i = 0; i < ATTRIBUTE_SIZE; i++)
+ for (i = 0; i <= ATTRIBUTE_SIZE; i++) {
CHECKED_ATTRIBUTE[i] = FALSE;
+ attr[i][0] = attr[i][1] = NULL;
+ }
node = g_hash_table_lookup(contact , "attribute");
while (node) {
AttrKeyValue *item = node->data;
*/
}
else {
- SETMOD(mods[cnt], modarr[cnt], mod_op, g_strdup(item->key), attr, g_strdup(item->value));
+ SETMOD(mods[cnt], modarr[cnt], mod_op, g_strdup(item->key), attr[cnt], g_strdup(item->value));
cnt++;
CHECKED_ATTRIBUTE[index] = TRUE;
}
}
node = g_list_next(node);
}
- char **attribs = ldapctl_attribute_array(server->control);
+ char **attribs = ldapctl_full_attribute_array(server->control);
for (i = 0; i < ATTRIBUTE_SIZE; i++) {
/* Attributes which holds no information are to be removed */
if (CHECKED_ATTRIBUTE[i] == FALSE) {
if (ldapsvr_check_search_attributes(attribs, (char *) ATTRIBUTE[i])) {
mod_op = ldapsvr_deside_operation(ld, server, dn, (char *) ATTRIBUTE[i], "");
if (mod_op == LDAP_MOD_DELETE) {
- SETMOD(mods[cnt], modarr[cnt], LDAP_MOD_DELETE, g_strdup((char *) ATTRIBUTE[i]), attr, NULL);
+ SETMOD(mods[cnt], modarr[cnt], LDAP_MOD_DELETE, g_strdup((char *) ATTRIBUTE[i]), attr[cnt], NULL);
cnt++;
}
}
server->retVal = LDAPRC_ALREADY_EXIST;
break;
default:
- fprintf(stderr, "ldap_modify for dn=%s\" failed[0x%x]: %s\n",dn, rc, ldap_err2string(rc));
+ g_printerr("ldap_modify for dn=%s\" failed[0x%x]: %s\n",dn, rc, ldap_err2string(rc));
if (rc == 0x8)
server->retVal = LDAPRC_STRONG_AUTH;
else
}
}
else {
- /* Only consider those attributes which is currently part of the search criteria.
- * If attributes are not part of the search criteria they would seem to hold
- * no information since their values will not be populated in the GUI
- */
- char **attribs = ldapctl_attribute_array(server->control);
+ char **attribs = ldapctl_full_attribute_array(server->control);
for (i = 0; i < ATTRIBUTE_SIZE; i++) {
if (ldapsvr_check_search_attributes(attribs, (char *) ATTRIBUTE[i])) {
if (CHECKED_ATTRIBUTE[i] == FALSE) {
server->retVal = LDAPRC_ALREADY_EXIST;
break;
default:
- fprintf(stderr, "ldap_modify for dn=%s\" failed[0x%x]: %s\n",base_dn, rc, ldap_err2string(rc));
+ g_printerr("ldap_modify for dn=%s\" failed[0x%x]: %s\n",base_dn, rc, ldap_err2string(rc));
if (rc == 0x8)
server->retVal = LDAPRC_STRONG_AUTH;
else
*/
}
else {
- fprintf(stderr, "Current dn: %s\n", dn);
- fprintf(stderr, "new dn: %s\n", newRdn);
- fprintf(stderr, "LDAP Error(ldap_modrdn2_s) failed[0x%x]: %s\n", rc, ldap_err2string(rc));
+ g_printerr("Current dn: %s\n", dn);
+ g_printerr("new dn: %s\n", newRdn);
+ g_printerr("LDAP Error(ldap_modrdn2_s) failed[0x%x]: %s\n", rc, ldap_err2string(rc));
g_free(newRdn);
clean_up(ld, server, contact);
return;
mods[cnt] = NULL;
rc = ldap_modify_ext_s(ld, dn, mods, NULL, NULL);
if (rc) {
- fprintf(stderr, "ldap_modify for dn=%s\" failed[0x%x]: %s\n",
+ g_printerr("ldap_modify for dn=%s\" failed[0x%x]: %s\n",
dn, rc, ldap_err2string(rc));
server->retVal = LDAPRC_NAMING_VIOLATION;
}
server->retVal = LDAPRC_SUCCESS;
rc = ldap_delete_ext_s(ld, dn, NULL, NULL);
if (rc) {
- fprintf(stderr, "ldap_modify for dn=%s\" failed[0x%x]: %s\n",
+ g_printerr("ldap_modify for dn=%s\" failed[0x%x]: %s\n",
dn, rc, ldap_err2string(rc));
server->retVal = LDAPRC_NODN;
}
}
}
else {
- fprintf(stderr, "\t\tpid : ???\n");
+ g_printerr("\t\tpid : ???\n");
}
node = g_list_next(node);
}