From 1285ef838782a6399606fc5af96e288236edf8e2 Mon Sep 17 00:00:00 2001 From: Roman Rakus Date: Fri, 21 Sep 2012 13:06:24 +0200 Subject: account: DeleteInstance on LMI_Group Signed-off-by: Roman Rakus --- src/account/LMI_GroupProvider.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'src/account') diff --git a/src/account/LMI_GroupProvider.c b/src/account/LMI_GroupProvider.c index 5de5318..3ffec5a 100644 --- a/src/account/LMI_GroupProvider.c +++ b/src/account/LMI_GroupProvider.c @@ -122,7 +122,45 @@ static CMPIStatus LMI_GroupDeleteInstance( const CMPIResult* cr, const CMPIObjectPath* cop) { - CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); + LMI_Group lg; + const char *name = NULL; + struct lu_context *luc = NULL; + struct lu_error *error = NULL; + struct lu_ent *lue = NULL; + char errmsg[256]; + + LMI_Group_InitFromObjectPath(&lg, _cb, cop); + name = lg.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_group_lookup_name(luc, name, lue, &error)) + { /* Group not found */ + snprintf(errmsg, 256, "Non existing group: %s\n", name); + lu_ent_free(lue); + lu_end(luc); + CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, errmsg); + } + + if (!lu_group_delete(luc, lue, &error)) + { + snprintf(errmsg, 256, "Group %s could not be deleted: %s\n", name, + 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_GroupExecQuery( -- cgit