diff options
Diffstat (limited to 'eurephiadm')
-rw-r--r-- | eurephiadm/commands/users.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/eurephiadm/commands/users.c b/eurephiadm/commands/users.c index a8e9d93..3b84a5d 100644 --- a/eurephiadm/commands/users.c +++ b/eurephiadm/commands/users.c @@ -56,13 +56,6 @@ #include "../xsltparser.h" -// TO BE REMOVED WHEN ALL FUNCTIONS ARE PORTED TO NEW eDBadminUserAccount() API -// These functions are here only to make eurephiadm compile. -static int eDBadminDeleteUser(eurephiaCTX *ctx, int uid, xmlDoc *update_xml) { - return 0; -} - - /** * Forward declaration of a function already found in certificates.c */ @@ -672,12 +665,27 @@ int account_activation(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES * case 'D': // Delete user account xmlFreeDoc(update_xml); // We need another XML doc to delete users - eurephiaXML_CreateDoc(ctx, 1, "delete_user", &update_xml, &update_n); + eurephiaXML_CreateDoc(ctx, 1, "UserAccount", &update_xml, &update_n); assert( (update_xml != NULL) && (update_n != NULL) ); + xmlNewProp(update_n, (xmlChar *) "mode", (xmlChar *) "delete"); xmlNewProp(update_n, (xmlChar *) "uid", (xmlChar *) uid_str); + update_n = xmlNewChild(update_n, NULL, (xmlChar *) "fieldMapping", NULL); + xmlNewProp(update_n, (xmlChar *) "table", (xmlChar *) "users"); - rc = eDBadminDeleteUser(ctx, atoi_nullsafe(uid_str), update_xml); + res_xml = eDBadminUserAccount(ctx, update_xml); + // Check if this update failed and abort further operations if it did + if( eurephiaXML_IsResultMsg(ctx, res_xml) ) { + res = eurephiaXML_ParseResultMsg(ctx, res_xml); + if( (res == NULL) || (res->resultType == exmlERROR) ) { + free_nullsafe(ctx, res); + break; + } + free_nullsafe(ctx, res); + } else { + // No ResultMsg document was returned, which is also wrong. + break; + } // Delete links between certificates associated to this user account xmlFreeDoc(update_xml); eurephiaXML_CreateDoc(ctx, 1, "usercerts", &update_xml, &update_n); @@ -689,27 +697,22 @@ int account_activation(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES * xmlNewChild(update_n, NULL, (xmlChar *) "uid", (xmlChar *) uid_str); tmp_xml = eDBadminUserCertsLink(ctx, update_xml); - if( tmp_xml == NULL ) { - fprintf(stderr, "%s: Failed to remove the user-certs link\n", MODULE); - } - res = eurephiaXML_ParseResultMsg(ctx, tmp_xml); if( res == NULL ) { fprintf(stderr, "%s: Failed to remove user <-> certificate link. " "No results received\n", MODULE); rc = 0; + } else if( res->resultType == exmlERROR ) { + fprintf(stderr, "%s: %s\n", MODULE, res->message); } else { - if( res->resultType == exmlERROR ) { - fprintf(stderr, "%s: %s\n", MODULE, res->message); - }; + fprintf(stdout, "%s: %s\n", MODULE, res->message); rc = 1; - free_nullsafe(ctx, res); } + free_nullsafe(ctx, res); xmlFreeDoc(tmp_xml); break; } - if( eurephiaXML_IsResultMsg(ctx, res_xml) ) { eurephiaRESULT *res = eurephiaXML_ParseResultMsg(ctx, res_xml); if( res->resultType == exmlERROR ) { |