I currently have an MVC website that uses forms authentication using the default SqlMembershipProvider.
In this website I can automatically log a user in by simply having a GUID that corresponds to their UserId in the aspnet_Membership table. All I do is query the table, then using their username I simply have forms authentication set the auth cookie.
I currently use:
FormsAuthentication.RedirectFromLoginPage(username, false)
But can optionally also use:
FormsAuthentication.SetAuthCookie(username, false, "/")
Now, I need to do something similar to this, but on SharePoint. SP does have access to my membership tables.
However, it seems that SP uses SecurityTokens for the validation:
SecurityToken token = SPSecurityContext.SecurityTokenForFormsAuthentication(new Uri(SPContext.Current.Web.Url), formsClaimsAuthenticationProvider.MembershipProvider, formsClaimsAuthenticationProvider.RoleProvider, strUsername, strPassword);
if (null != token)
{
EstablishSessionWithToken(token);
Response.Redirect(strSource);
}
Questions:
- Is there a way to get this token by simply providing the username, without the password?
- Or, can I manually create the
SecurityTokento provide toSetPrincipalAndWriteSessionToken()? - Or, can I manually set the authentication cookies myself?