public static int DeleteSqlUser(int itemId) { // check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo); if (accountCheck < 0) { return(accountCheck); } // load original meta item SqlUser origItem = (SqlUser)PackageController.GetPackageItem(itemId); if (origItem == null) { return(BusinessErrorCodes.ERROR_MSSQL_USERS_PACKAGE_ITEM_NOT_FOUND); } // place log record TaskManager.StartTask("SQL_USER", "DELETE", origItem.Name); TaskManager.ItemId = itemId; try { // get service DatabaseServer sql = GetDatabaseServer(origItem.ServiceId); // delete service item sql.DeleteUser(origItem.Name, GetSqlDatabasesArray(origItem.PackageId, origItem.GroupName)); // delete meta item PackageController.DeletePackageItem(origItem.Id); return(0); } catch (Exception ex) { TaskManager.WriteError(ex); // Return a generic error instead of re-throwing an exception return(BusinessErrorCodes.FAILED_EXECUTE_SERVICE_OPERATION); } finally { TaskManager.CompleteTask(); } }