I came across an issue in which MOSS was present in the server and i was doing a re-configuration of Sharepoint farm connecting it to a new server farm. I came across the error "An exception of type system.security.principal.identitynotmappedexception was thrown". I had checked that I had cleaned up the config database and also the admin content Database of previously set farm. I had manually deleted the web sites present in IIS related to sharepoint. I was not sure as to why this error came up.
Doing a bit of research, I came to know there was issue with the Central Admin App pool as it was running in another service account. I had deleted the Central admin website but had missed out to delete the App Pools related to sharepoint which created this issue.
Once I deleted the App Pools related to Sharepoint and started the configuration again. Everything worked perfectly fine.
Hope this experience helps someone.