uint8_t winsdb_delete(struct winsdb_handle *h, struct winsdb_record *rec)
{
	struct ldb_context *wins_db = h->ldb;
	TALLOC_CTX *tmp_ctx = talloc_new(wins_db);
	struct ldb_dn *dn;
	int trans;
	int ret;

	trans = ldb_transaction_start(wins_db);
	if (trans != LDB_SUCCESS) goto failed;

	dn = winsdb_dn(tmp_ctx, wins_db, rec->name);
	if (dn == NULL) goto failed;

	ret = ldb_delete(wins_db, dn);
	if (ret != LDB_SUCCESS) goto failed;

	trans = ldb_transaction_commit(wins_db);
	if (trans != LDB_SUCCESS) goto failed;

	wins_hook(h, rec, WINS_HOOK_DELETE, h->hook_script);

	talloc_free(tmp_ctx);
	return NBT_RCODE_OK;

failed:
	if (trans == LDB_SUCCESS) ldb_transaction_cancel(wins_db);
	talloc_free(tmp_ctx);
	return NBT_RCODE_SVR;
}
uint8_t winsdb_delete(struct winsdb_handle *h, struct winsdb_record *rec)
{
	struct ldb_context *wins_db = h->ldb;
	TALLOC_CTX *tmp_ctx = talloc_new(wins_db);
	struct ldb_dn *dn;
	int trans;
	int ret;

	trans = ldb_transaction_start(wins_db);
	if (trans != LDB_SUCCESS) goto failed;

	dn = winsdb_dn(tmp_ctx, wins_db, rec->name);
	if (dn == NULL) goto failed;

	ret = ldb_delete(wins_db, dn);
	if (ret != LDB_SUCCESS) goto failed;

	trans = ldb_transaction_commit(wins_db);
	if (trans != LDB_SUCCESS) goto failed;

	wins_hook(h, rec, WINS_HOOK_DELETE, h->hook_script);

	talloc_free(tmp_ctx);
	return NBT_RCODE_OK;

failed:
	if (trans == LDB_SUCCESS) ldb_transaction_cancel(wins_db);
	talloc_free(tmp_ctx);
	return NBT_RCODE_SVR;
}