After changing the SID of any account, eg:
pdbedit -U S-1-5-21-2411803954-1159576741-3064619986-500 -u administrator -r
...the SID *is* changed successfully, but I get the following error:
| Unable to modify TDB passwd ! Error: Record does not exist
| occured while storing the RID index (RID_000001f4)
| Unable to modify entry!
From this point whenever I try to change the password using smbpasswd, I get a similar error to that above.
Using pdbedit -x to remove the account gives the error "Unable to delete user <user>", but pdbedit -L doesn't list the account any more.
Using tdbdump I find there is a remnant left over in passdb.tdb. Eg:
key(13) = "RID_00000bbc\00"
data(5) = "test\00"
key(13) = "INFO/version\00"
data(4) = "\02\00\00\00"
This problem only happens after changing the SID on an account.