From 75cace04fdcb672cc6c3c3ec8403206f2b222c50 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 1 May 2003 11:47:48 +0000 Subject: *id_to_*id call reshape to return NTSTATUS errors plus internal fixes 1st stage (This used to be commit 6d036761e565bc93964bb3c939d5b7d78d5778a3) --- source3/sam/idmap_tdb.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'source3/sam/idmap_tdb.c') diff --git a/source3/sam/idmap_tdb.c b/source3/sam/idmap_tdb.c index f85d2db086..ab86eaf4eb 100644 --- a/source3/sam/idmap_tdb.c +++ b/source3/sam/idmap_tdb.c @@ -213,7 +213,7 @@ idok: static NTSTATUS db_set_mapping(const DOM_SID *sid, unid_t id, int id_type) { - TDB_DATA ksid, kid; + TDB_DATA ksid, kid, data; fstring ksidstr; fstring kidstr; @@ -235,6 +235,20 @@ static NTSTATUS db_set_mapping(const DOM_SID *sid, unid_t id, int id_type) kid.dptr = kidstr; kid.dsize = strlen(kidstr) + 1; + /* *DELETE* prevoius mappings if any. + * This is done both SID and [U|G]ID passed in */ + + data = tdb_fetch(idmap_tdb, ksid); + if (data.dptr) { + tdb_delete(idmap_tdb, data); + tdb_delete(idmap_tdb, ksid); + } + data = tdb_fetch(idmap_tdb, kid); + if (data.dptr) { + tdb_delete(idmap_tdb, data); + tdb_delete(idmap_tdb, kid); + } + if (tdb_store(idmap_tdb, ksid, kid, TDB_INSERT) == -1) { DEBUG(0, ("idb_set_mapping: tdb_store 1 error: %s\n", tdb_errorstr(idmap_tdb))); return NT_STATUS_UNSUCCESSFUL; @@ -427,4 +441,3 @@ NTSTATUS idmap_reg_tdb(struct idmap_methods **meth) return NT_STATUS_OK; } - -- cgit