Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Override EPiServer.Cms.UI.AspNetIdentity.ApplicationUserManager

Vote:
 

Hi,

I'm trying to migrate users from old sql membership provider to the new asp.net Identity so I can use the the new add-on that was released this summer, EPiServer.Cms.UI.AspNetIdentity. (http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Security/episerver-aspnetidentity/)

But as the passwords are changed  I need to override the PasswordHasher, described in blog post by http://sveinaandahl.blogspot.se/2016/03/how-to-validate-old-passwords-when.html

and how to migrate more generally http://www.asp.net/identity/overview/migrations/migrating-an-existing-website-from-sql-membership-to-aspnet-identity

So As I want to keep the episerver login and user management I'm trying to extend the EPiServer.Cms.UI.AspNetIdentity.ApplicationUserManager

by this small hack, but whatever trick I try to use the PasswordHasher is not changed. 

What am I missing? #seconddayaftervacation

   [EPiServer.Framework.InitializableModule]
    [EPiServer.Framework.ModuleDependency(typeof(EPiServer.Cms.UI.AspNetIdentity.ApplicationSecurityEntityInitialization))]
    [EPiServer.Framework.ModuleDependency(typeof(EPiServerUIInitialization))]
    public class EPiServerAspNetIdentityInitModule : EPiServer.ServiceLocation.IConfigurableModule
    {
        public void ConfigureContainer(EPiServer.ServiceLocation.ServiceConfigurationContext context)
        {
            context.Container.Configure(x=>x.For>().Use());
        }
        public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context) { }
        public void Uninitialize(EPiServer.Framework.Initialization.InitializationEngine context) { }
    }

    public class EPiUserManagerExtension : ApplicationUserManager
    {
        public EPiUserManagerExtension(UserStore store) : base(store)
        {
            this.PasswordHasher = new SqlPasswordHasher();
        }
    }

Stacktrace:

[FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. ]
   System.Convert.FromBase64_ComputeResultLength(Char* inputPtr, Int32 inputLength) +13946383
   System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength) +80
   System.Convert.FromBase64String(String s) +49
   Microsoft.AspNet.Identity.Crypto.VerifyHashedPassword(String hashedPassword, String password) +65
   Microsoft.AspNet.Identity.PasswordHasher.VerifyHashedPassword(String hashedPassword, String providedPassword) +15
   Microsoft.AspNet.Identity.d__3e.MoveNext() +373
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +13847892
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +61
   Microsoft.AspNet.Identity.d__17.MoveNext() +338
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +13847892
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +61
   Microsoft.AspNet.Identity.d__12.MoveNext() +601
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +13847892
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +61
   Microsoft.AspNet.Identity.AsyncHelper.RunSync(Func`1 func) +348
   EPiServer.Cms.UI.AspNetIdentity.ApplicationSignInManager`1.SignIn(String userName, String password, String returnUrl) +173
   EPiServer.Cms.UI.AspNetIdentity.ApplicationUISignInManager`1.SignIn(String providerName, String userName, String password) +58
   EPiServer.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +111
   System.Web.UI.WebControls.Login.AttemptLogin() +146
   System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +115
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6016
#152093
Aug 16, 2016 12:36
Vote:
 

Did you solve this? I am having the same issue.

#155516
Sep 20, 2016 8:56
Vote:
 

Hi,

Sorry unfortunately had no more time to work on this. 

#157790
Sep 22, 2016 9:32
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.