How to solve the problem orphan users in SQL Server databases?

First you need to know what is orphaned user?
SQL Server maintains user logins in the sysxlogins system table in the master database. Every time you add a user, or give a Windows account access, an entry is made in this table. Every user is assigned a security identifier (SID) in sysxusers. Each database has a table called sysusers that contains a list of users that have access to that database. Typically, the SID in the sysusers table matched the SID in sysxusers.
When a user¬†entry exists in sysusers that that does not have a matching SID in sysxusers, that user is “orphaned.

Read the rest of this entry »