- /* *DELETE* previous mappings if any.
- * This is done for both the SID and [U|G]ID passed in */
-
- /* NOTE: We should lock both the ksid and kid records here, before
- * making modifications. However, because tdb_chainlock() is a
- * blocking call we could create an unrecoverable deadlock, so for now
- * we only lock the ksid record. */
-
- /* Lock the record for this SID. */
- if (tdb_chainlock(ctx->tdb, ksid) != 0) {
- DEBUG(10,("Failed to lock record %s. Error %s\n",
- ksidstr, tdb_errorstr(ctx->tdb) ));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- data = tdb_fetch(ctx->tdb, ksid);
- if (data.dptr) {
- DEBUG(10, ("Deleting existing mapping %s <-> %s\n",
- (const char *)data.dptr, ksidstr ));
- tdb_delete(ctx->tdb, data);
- tdb_delete(ctx->tdb, ksid);
- SAFE_FREE(data.dptr);
+ if (ctx->db->transaction_start(ctx->db) != 0) {
+ DEBUG(0, ("Failed to start transaction for %s\n",
+ ksidstr));
+ ret = NT_STATUS_INTERNAL_DB_ERROR;
+ goto done;