Try this, I use this pattern for on-the-fly authentications.
1. Authenticate the user
2. Check the result of the user authentication
3. Sign-in the user against the current CMS context
For example:
UserInfo ui = AuthenticationHelper.AuthenticateUser(txtUsername.Text.Trim(), txtPsswd1.Text, CMSContext.CurrentSiteName, false);
if (ui == null)
{
//display error, login failed
return false;
} else {
CMSContext.AuthenticateUser(ui.UserName, false);
return true;
}
The one is an authentication of credentials, the other is a sign-in; from what I can tell, use both.