Please find the relevant steps in users and login mapping process:
1) When we restore a database, the users associated with the database gets restored.
2) using sp_help_revlogin, we generate the script for Logins and run this script on the new instance.
3) Now we have the users and logins both on the new instance but they are not mapped.
4) To check for orphan users, run this script:
sp_change_users_login @action='report'
This needs to be run within the desired database context.For example if want to check orphan users for Pubs database then run within it.
5) Now to map these orphan users with their respective logins, we need to run this command:
USE PUBS
GO
sp_change_users_login @Action='update_one',
@UserNamePattern='TestUser',
@LoginName='Testlogin'
GO
6) The above steps will fix the issue. Run the script for checking the orphan users again and validate that no more users are orphan.