From edf5473aa4f54a5698a0f1f2d80532444df27092 Mon Sep 17 00:00:00 2001 From: Roman Rakus Date: Thu, 20 Sep 2012 12:26:23 +0200 Subject: account: delete instance on LMI_Account Signed-off-by: Roman Rakus --- src/account/LMI_AccountProvider.c | 41 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/account/LMI_AccountProvider.c b/src/account/LMI_AccountProvider.c index 0b10c44..79f138b 100644 --- a/src/account/LMI_AccountProvider.c +++ b/src/account/LMI_AccountProvider.c @@ -173,7 +173,46 @@ static CMPIStatus LMI_AccountDeleteInstance( const CMPIResult* cr, const CMPIObjectPath* cop) { - CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); + LMI_Account acc; + const char* username = NULL; + char errmsg[256]; + struct lu_context *luc = NULL; + struct lu_error *error = NULL; + struct lu_ent *lue = NULL; + + LMI_Account_InitFromObjectPath(&acc, _cb, cop); + username = acc.Name.chars; + + luc = lu_start(NULL, 0, NULL, NULL, lu_prompt_console_quiet, NULL, &error); + if (!luc) + { + fprintf(stderr, "Error initializing: %s\n", lu_strerror(error)); + exit(1); + } + + lue = lu_ent_new(); + + if (!lu_user_lookup_name(luc, username, lue, &error)) + { + snprintf(errmsg, 256, "Non existing user: %s\n", username); + lu_ent_free(lue); + lu_end(luc); + CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, errmsg); + } + + if (!lu_user_delete(luc, lue, &error)) + { + snprintf(errmsg, 256, "User %s could not be deleted: %s\n", username, + lu_strerror(error)); + lu_ent_free(lue); + lu_end(luc); + CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, errmsg); + } + + lu_ent_free(lue); + lu_end(luc); + + CMReturn(CMPI_RC_OK); } static CMPIStatus LMI_AccountExecQuery( -- cgit