CMS Admin Create User with Identity

Vote:
 

I am in the process of migrating several of our sites from Membership to MsIdentity. Thanks to the plethora of guides and walk-throughs, most of the work was relatively strait-forward. The site is set-up, existing test users and roles are migrated and I can log in. There are a couple snags, though. One of those is CMS Admin -> Create User.

I can enter the credentials for a new user and assign the roles. Clicking on the save button, I can see from Prefix profiling (see below) and a subsequent database verification that the new user is created using the Identity framework. However, at the end of the execution I get the following error and exception:


20.1.1 Unexpected Membership Provider Error. This may be caused by invalid combination of Role and Membership providers.:


System.NullReferenceException: Object reference not set to an instance of an object.
at EPiServer.UI.Edit.UserGuiSettings.SaveSettings at EPiServer.UI.Edit.UserMembership.SaveEPiServerProfileAndPlugins
at EPiServer.UI.Edit.UserMembership.SaveButton_Click


It seems that CreateUser is hardwired to Memebership, despite the Identity initialisation being in place. Is there some more configuration that needs to be in place for the Create User function to work properly?




    [ModuleDependency(typeof(EPiServer.Cms.UI.AspNetIdentity.ApplicationSecurityEntityInitialization))]
    [ModuleDependency(typeof(EPiServerUIInitialization))]
public class CustomInitialize : IConfigurableModule
{
...
private static void ConfigureContainer(ConfigurationExpression container)
        {
...
container.For().Use();
            container.For().Use();
}
}
  • 0
    945

    SqlConnection.OpenAsyncvar-t-app01 | DressmannTestIdentity

  • 9
    946

      SqlCommand.ExecuteReaderAsync SELECT AspNetUsers, Records: 1

  • 46
    956

    Untracked Application Code

  • 0
    1002

    SqlConnection.OpenAsyncvar-t-app01 | DressmannTestIdentity

  • 67
    1002

    Untracked Application Code

  • 1
    1068

      SqlCommand.ExecuteReaderAsync SELECT AspNetUserClaims, Records: 0

  • 24
    1070

    Untracked Application Code

  • 0
    1094

    SqlConnection.OpenAsyncvar-t-app01 | DressmannTestIdentity

  • 50
    1094

    Untracked Application Code

  • 1
    1145

      SqlCommand.ExecuteReaderAsync SELECT AspNetUserLogins, Records: 0

  • 0
    1163

    SqlConnection.OpenAsyncvar-t-app01 | DressmannTestIdentity

  • 43
    1163

    Untracked Application Code

  • 4
    1206

      SqlCommand.ExecuteReaderAsync SELECT AspNetUserRoles, Records: 0

  • 0
    1214

    SqlConnection.OpenAsyncvar-t-app01 | DressmannTestIdentity

  • 15
    1215

      SqlCommand.ExecuteReaderAsync SELECT AspNetUsers, Records: 1

  • 0
    1233

    SqlConnection.OpenAsyncvar-t-app01 | DressmannTestIdentity

  • 9
    1233

      SqlCommand.ExecuteReaderAsync SELECT AspNetUsers, Records: 1

  • 50
    1242

    Untracked Application Code

  • 0
    1292

    SqlConnection.OpenAsyncvar-t-app01 | DressmannTestIdentity

  • 125
    1292

    Untracked Application Code

  • 5
    1418

      SqlCommand.ExecuteReaderAsync SELECT AspNetUserRoles, AspNetRoles, Records: 0

  • 26
    1423

    Untracked Application Code

  • 0
    1448

    SqlConnection.OpenAsyncvar-t-app01 | DressmannTestIdentity

  • 39
    1449

    Untracked Application Code

  • 7
    1488

      SqlCommand.ExecuteReaderAsync SELECT AspNetRoles, Records: 1

  • 73
    1495

    Untracked Application Code

  • 0
    1568

    SqlConnection.OpenAsyncvar-t-app01 | DressmannTestIdentity

  • 9
    1568

      SqlCommand.ExecuteReaderAsync SELECT AspNetUsers, Records: 1

  • 0
    1595

    SqlConnection.OpenAsyncvar-t-app01 | DressmannTestIdentity

  • 1
    1595

    SqlInternalConnection.BeginSqlTransaction

  • 32
    1596

    Untracked Application Code

  • 1
    1627

      SqlCommand.ExecuteNonQueryAsync UPDATE AspNetUsers, Records: 1

  • 13
    1629

      SqlCommand.ExecuteNonQueryAsync INSERT AspNetUserRoles, Records: 1

  • 1
    1642

    SqlInternalTransaction.Commit

  • 0
    1662

    Caught System.NullReferenceException

  • System.NullReferenceException: Object reference not set to an instance of an object.
      at EPiServer.UI.Edit.UserGuiSettings.SaveSettings
      at EPiServer.UI.Edit.UserMembership.SaveEPiServerProfileAndPlugins
      at EPiServer.UI.Edit.UserMembership.SaveButton_Click
    
  • 0
    20.1.1 Unexpected Membership Provider Error. This may be caused by invalid combination of Role and Membership providers.:
#196552
Sep 04, 2018 9:50
Vote:
 

The same problem occurs when going to

EPPi server CMS -> My settings -> User Informaton

and press the Save button.

#196554
Edited, Sep 04, 2018 10:38
Vote:
 

I think I solved this mystery.

UserGuiSettings.SaveSettings() calls :

 ProfileData orCreateProfile = this._profileRepository.get_Service().GetOrCreateProfile(userName);

In web.config I specified



    <profile enabled="false">
      <properties>
        <clear />
      </properties>
      <providers>
        <clear />
      </providers>
    </profile>

along with disabling of membership and roleManager sections

Reenabling profile section to something along these lines fixed the crash:

<profile enabled="true" defaultProvider="SqlProfileProvider" automaticSaveEnabled="true">
      <properties>
        <add name="Address" type="System.String" />
        <add name="ZipCode" type="System.String" />
        <add name="Locality" type="System.String" />
        <add name="Email" type="System.String" allowAnonymous="true" />
        <add name="FirstName" type="System.String" allowAnonymous="true" />
        <add name="LastName" type="System.String" allowAnonymous="true" />
        <add name="FullName" type="System.String" allowAnonymous="true" />
        <add name="Language" type="System.String" />
        <add name="State" type="System.Int32" allowAnonymous="false" />
        <add name="Country" type="System.String" />
        <add name="Company" type="System.String" />
        <add name="Title" type="System.String" />
        <add name="PreferredBillingAddress" type="System.String" />
        <add name="PreferredShippingAddress" type="System.String" />
        <add name="LastVisited" type="System.DateTime" />
        <add name="SubscriptionInfo" type="EPiServer.Personalization.SubscriptionInfo, EPiServer" />
        <add name="CustomExplorerTreePanel" type="System.String" />
        <add name="FileManagerFavourites" type="System.Collections.Generic.List`1[System.String]" />
        <add name="EditTreeSettings" type="EPiServer.Personalization.GuiSettings, EPiServer" />
        <add name="ClientToolsActivationKey" type="System.String" />
        <add name="FrameworkName" type="System.String" />
      </properties>
      <providers>
        <clear />
        <add name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="EcfSqlConnection" applicationName="ProjectZAdmin" />
      </providers>
    </profile>

What puzzles me, is that Profile from the old membership framework still must be used along with the new AspNetIdentity, preserving the aspnet_Profile table in the Commerce database.

#196569
Sep 04, 2018 16:00
* 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.