Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Govi 14 posts 35 karma points
    Sep 17, 2015 @ 20:26
    Govi
    0

    Active Directory authentication to backoffice is throwing InvalidCastException

    I am using Umbraco 7.3 and trying to configure Active Directory authentication exactly as mentioned in this post: https://our.umbraco.org/wiki/how-tos/membership-providers/active-directory-membership-provider

    When I try to hit backoffice after the build, I am getting this error: Unable to cast object of type 'System.Web.Security.ActiveDirectoryMembershipProvider' to type 'Umbraco.Core.Security.UmbracoMembershipProviderBase'. enter image description here

    Has anybody has this issue and resolved?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Sep 18, 2015 @ 09:02
    Alex Skrypnyk
    0

    Hi Govi,

    Can you provide code of login method ? What method make this crash ?

    Thanks, Alex

  • Govi 14 posts 35 karma points
    Sep 18, 2015 @ 17:21
    Govi
    0

    Hello Alex - I get this error for all pages (including backoffice /umbraco login page) and hence there's no way for me to try to login. The app is crashing at app_start itself. This is a plain vanilla Umbraco setup without any customization.

    Thanks, Govi

  • Gleb Kaplan 49 posts 125 karma points
    Oct 01, 2015 @ 10:20
    Gleb Kaplan
    0

    I have the same issue after unstalling Umbraco 7.3

    We have been using AD membership provider for backoffice user authentication, with the following setup (as specified in https://our.umbraco.org/wiki/how-tos/membership-providers/active-directory-membership-provider):

    In umbracoSettings.config

      <providers>
    <users>
      <DefaultBackofficeProvider>ADUsersMembershipProvider</DefaultBackofficeProvider>
    </users>
    

    In web.config:

        <membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15">
      <providers>
        <clear />
        <add name="UmbracoMembershipProvider" type="Umbraco.Web.Security.Providers.MembersMembershipProvider, Umbraco" minRequiredNonalphanumericCharacters="0" minRequiredPasswordLength="4" useLegacyEncoding="true" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="Member" passwordFormat="Hashed" />
        <add name="UsersMembershipProvider" type="Umbraco.Web.Security.Providers.UsersMembershipProvider, Umbraco" minRequiredNonalphanumericCharacters="0" minRequiredPasswordLength="4" useLegacyEncoding="true" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" passwordFormat="Hashed" />
        <add name="ADUsersMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0,               Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADMembership" attributeMapUsername="sAMAccountName" />
      </providers>
    </membership>
    

    Now I am getting the same error "Unable to cast object of type 'System.Web.Security.ActiveDirectoryMembershipProvider' to type 'Umbraco.Core.Security.UmbracoMembershipProviderBase'.".

    Please advise how to implement AD membership provider for backoffice in 7.3?

  • Gleb Kaplan 49 posts 125 karma points
    Oct 01, 2015 @ 15:21
    Gleb Kaplan
    0

    PS. I was trying to register my own provider inherited from UmbracoMembershipProviderBase. However Umbraco does not seem to use it during the backoffice login process. When running in the debugger I can see the breakpoint hit on fields declaration, but it never hits a breakpoint in ValidateUser().

  • Govi 14 posts 35 karma points
    Oct 01, 2015 @ 17:17
    Govi
    0

    Hello Gleb -
    Initially I thought I was getting this exception in the new versions of Umbraco (7.2, 7.3) but, I could replicate the same casting exception error in older versions as well. I was wondering how it was working at all for you earlier, as Umbraco.Core membershipprovider is not inherting from System.Web membershipprovider.

  • Terence Jee 16 posts 87 karma points
    Oct 05, 2015 @ 17:34
    Terence Jee
    0

    I am having the same issue as well. We're using AD authentication and I recieved this error as soon as I upgrade from 7.2 to 7.3.

    Unable to cast object of type 'System.Web.Security.ActiveDirectoryMembershipProvider' to type 'Umbraco.Core.Security.UmbracoMembershipProviderBase'.

    Anyone have any ideas? Thanks.

    Terence

  • Meni 247 posts 483 karma points
    Oct 08, 2015 @ 07:05
    Meni
    2

    Had same issue when upgraded from 7.28 to 7.3 (actually had lot ... - it's all the web.config - I guess because the move to MVC 5) Anyway, I replaced these lines at the web.config (copied these lines from the new web.config that comes with 7.3 to my current web.config - only these lines) and now it works:

    <!-- Membership Provider -->
    <membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15">
      <providers>
        <clear />
        <add name="UmbracoMembershipProvider" type="Umbraco.Web.Security.Providers.MembersMembershipProvider, Umbraco" minRequiredNonalphanumericCharacters="0" minRequiredPasswordLength="8" useLegacyEncoding="true" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="Member" passwordFormat="Hashed" />
        <add name="UsersMembershipProvider" type="Umbraco.Web.Security.Providers.UsersMembershipProvider, Umbraco" minRequiredNonalphanumericCharacters="0" minRequiredPasswordLength="8" useLegacyEncoding="true" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" passwordFormat="Hashed" />
      </providers>
    </membership>
    <!-- Role Provider -->
    <roleManager enabled="true" defaultProvider="UmbracoRoleProvider">
      <providers>
        <clear />
        <add name="UmbracoRoleProvider" type="Umbraco.Web.Security.Providers.MembersRoleProvider" />
      </providers>
    </roleManager>
    

    In general - just follow the error messages and replaced the "problematic" lined at the web.config (or add the new which added if need). Honestly it's really annoying all this problems every time that I upgrade. In wordpress it's much more smooth ... In a mature cms these problems not support to happened ... - anyway, I still love Umbraco ...

  • Amir 75 posts 224 karma points
    Oct 16, 2015 @ 15:14
    Amir
    0

    @Mani, How's that fixing the problem? You restored the default membership provide settings. The problem here is for custom membership provider for Active Directory connection.

  • Amir 75 posts 224 karma points
    Oct 16, 2015 @ 15:15
    Amir
    0

    Any updates for this?

  • Terence Jee 16 posts 87 karma points
    Dec 02, 2015 @ 21:33
    Terence Jee
    0

    This just came out: https://our.umbraco.org/projects/backoffice-extensions/umbraco-back-office-active-directory-aspnet-provider/

    I tried this and I'm still getting this error (Umbraco 7.3.3): Unable to cast object of type 'AdAspNetProvider.ActiveDirectoryMembershipProvider' to type 'Umbraco.Core.Security.UmbracoMembershipProviderBase'.

    Has anyone successfully setup AD backoffice authentication with Umbraco 7?

  • Govi 14 posts 35 karma points
    Dec 03, 2015 @ 19:06
    Govi
    1

    We have this problem in 7.3 version but, NOT in the earlier versions. Hence, we are using 7.2.8 with Active Directory settings in web.config and it's working fine.

  • Eric Schrepel 161 posts 226 karma points
    Feb 08, 2016 @ 22:42
    Eric Schrepel
    0

    Having the same issue after updating from 7.2.8 to 7.3.7, as we use Active Directory for users to login to the backoffice UI. Any updates to the issue are very welcome, otherwise we'll have to stick with 7.2.8 awhile yet.

  • Brian Powell 44 posts 199 karma points c-trib
    Feb 09, 2016 @ 07:09
    Brian Powell
    0

    See https://github.com/Bitmapped/UmbBackofficeMembershipProvider for code and instructions on how to fix this issue.

  • Jay 413 posts 639 karma points
    Apr 26, 2016 @ 10:21
    Jay
    0

    Any update to this issue? having the same issue now.

    I've checked out https://github.com/Bitmapped/UmbBackofficeMembershipProvider

    But the error is still occuring

    Thanks

  • Brian Powell 44 posts 199 karma points c-trib
    May 01, 2016 @ 05:02
    Brian Powell
    1

    If you upgraded from before 7.3.0, you need to change UsersMembershipProvider to use the default Umbraco provider.

    It should look like:

    <add name="UsersMembershipProvider" type="Umbraco.Web.Security.Providers.UsersMembershipProvider, Umbraco" minRequiredNonalphanumericCharacters="0" minRequiredPasswordLength="8" useLegacyEncoding="true" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" passwordFormat="Hashed" />
    

    You can still authenticate via AD, but that's done with a separate provider other than UsersMembershipProvider. My code at https://github.com/Bitmapped/UmbBackofficeMembershipProvider can be used for that purpose.

  • Jay 413 posts 639 karma points
    May 03, 2016 @ 10:59
    Jay
    0

    Hi Brian,

    Did you manage to test it on Umbraco V7.4.3?

    I've tried your UmbBackofficeMembershipProvider out but are having some casting issues at the moment like what Terence mentioned above. Any idea?

    Thanks

  • Tejashri Kadam 11 posts 81 karma points
    Jun 09, 2016 @ 06:32
    Tejashri Kadam
    0

    Hi Brian, I am currently working for implementing Windows authentication for Umbraco. I have an MVC site and Umbraco is installed in the same project. I have enabled Windows authentication for MVC site. When user visits the site, user is asked to enter its windows credentials and user is authenticated. When authenticated user tries to access Umbraco back office, user is redirected Umbraco's login Page. When I debugged, my user was still an authenticated user and HttpContext.User had user data but still login page appears. User's windows username and Umbraco's username is same. I installed your package and made changes as given but still user is redirected to login page. Is there anything I am missing?

    Thanks in advance.

  • Brian Powell 44 posts 199 karma points c-trib
    Jun 09, 2016 @ 12:58
    Brian Powell
    0

    The behavior you're seeing is by design with Umbraco. Logging in to the public side does not give you access to the backoffice and vice versa. From Umbraco's perspective, public logins are related to "members" and backoffice logins are related to "users." It may be possible to write code that allows access for one side if the user is logged in to the other side, but I've never looked at doing it.

  • Tejashri Kadam 11 posts 81 karma points
    Jun 15, 2016 @ 06:01
    Tejashri Kadam
    0

    Thank you Brian, for clearing my understanding.
    I created an empty MVC application with Umbraco version 7.4.3. I installed your package through nuget and made configuration changes as below:
    I updated membership tag as: <membership defaultProvider="BackofficeMembershipProvider"> <providers> <clear/> <add name="BackofficeMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADConnectionString" connectionUsername="domain\\admin" connectionPassword="password" attributeMapUsername="sAMAccountName"/> </providers> </membership>


    Also added <add key="owin:appStartup" value="BackofficeMembershipProviderCustomOwinStartup" />


    I have used proper connection string. I tested it in another application and it is working.
    I am getting below error:enter image description here


    I am not able to figure out what I am missing. Could you please help?

    Thanks.

  • Brian Powell 44 posts 199 karma points c-trib
    Jun 15, 2016 @ 10:38
    Brian Powell
    0

    @Tejashri Kadam:

    The error your getting says that it can't establish a connection to the server, so either there is a network issue or there is something wrong with your configuration. I would start by looking at your username and using a single backslash as shown in the documentation rather than a double backslash.

  • Tejashri Kadam 11 posts 81 karma points
    Jun 15, 2016 @ 11:43
    Tejashri Kadam
    0

    @Brian:
    Below is my membership tag in web.config:
    <membership defaultProvider="BackofficeMembershipProvider"> <providers> <add name="BackofficeMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" connectionUsername="domain\admin" connectionPassword="password"/> <add name="UsersMembershipProvider" type="Umbraco.Web.Security.Providers.UsersMembershipProvider, Umbraco" minRequiredNonalphanumericCharacters="0" minRequiredPasswordLength="8" useLegacyEncoding="true" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" passwordFormat="Hashed" /> </providers> </membership>
    If I use single slash it gives type casting error as below:
    enter image description here

    And if I use double slash, it gives connection error as I had mentioned earlier.

  • Brian Powell 44 posts 199 karma points c-trib
    Jun 15, 2016 @ 14:43
    Brian Powell
    0

    @Tejashri Kadam:

    This is an improvement since now it's at least connecting to the server and getting an authentication object.

    Try changing to Version=4.0.0.0 for System.Web.Security.ActiveDirectoryMembershipProvider. I think the issue is that it's trying to use the .NET 2.0 version of the membership provider rather than the .NET 4.0 one.

  • Tejashri Kadam 11 posts 81 karma points
    Jun 16, 2016 @ 15:18
    Tejashri Kadam
    0

    @Brian,
    I changed the version to 4.0.0.0 , but it still throws the same error.

  • Ron G 41 posts 137 karma points
    Jun 21, 2016 @ 20:02
    Ron G
    0

    @Tejashri Kadam: Did you ever get this resolved? I'm having the same issue.

  • Brian Powell 44 posts 199 karma points c-trib
    Jun 22, 2016 @ 03:09
    Brian Powell
    0

    @Tejashri Kadam, @Ron G: I'm not immediately sure what's causing the problems here.

    For my own install, I use AdAspNetProvider instead of the standard .NET AD provider, but it's just a subclass of the standard one. I'm not sure why the original wouldn't work and I'm not immediately seeing anything wrong with your settings. Info on this provider is on my Github at https://github.com/Bitmapped/AdAspNetProvider .

    Do you have Umbraco working with local authentication?

  • Jay 413 posts 639 karma points
    May 03, 2016 @ 11:22
    Jay
    0

    Hi Brian,

    From your github, it didn't mention that i need to switch on the UmbracoSettings.config.

    Do i still need to add the below in? I've added the below in and I've got the casting error.

    <providers>
            <users>
                <!-- if you wish to use your own membershipprovider for authenticating to the Umbraco back office -->
                <!-- specify it here (remember to add it to the web.config as well) -->
                <!-- This is the default Umbraco Membership Provider (UsersMembershipProvider) -->              
                <DefaultBackofficeProvider>BackofficeMembershipProvider</DefaultBackofficeProvider>
            </users>
        </providers>
    

    Regard the parts that you mentioned below.

    In versions 7.3.0 and newer, an administrator must create an Umbraco user account (use the same username) first before an Active Directory user can login.

    So for Eg i've got an AD account with the name of Tester88, so I need to login using the UmbracoDefaultOwinStartup like below.

    <add key="owin:appStartup" value="UmbracoDefaultOwinStartup" />
    

    Then create an Umbraco Admin user with the username of Tester88 (should i leave the password untouch here?) and then switch it back to

    <add key="owin:appStartup" value="BackofficeMembershipProviderCustomOwinStartup" />
    

    And try to login using my AD user of Tester88 which i've created earlier?

    Thanks

  • Brian Powell 44 posts 199 karma points c-trib
    May 03, 2016 @ 12:52
    Brian Powell
    2

    @JLon:

    I have the code in production with v7.4.3 right now. Can you be specific about the exact error messages you are receiving?

    I did not have to make any changes to UmbracoSettings.config. I do not have any section like this one in my UmbracoSettings.config:

    <providers>
            <users>
                <!-- if you wish to use your own membershipprovider for authenticating to the Umbraco back office -->
                <!-- specify it here (remember to add it to the web.config as well) -->
                <!-- This is the default Umbraco Membership Provider (UsersMembershipProvider) -->              
                <DefaultBackofficeProvider>BackofficeMembershipProvider</DefaultBackofficeProvider>
            </users>
        </providers>
    

    You need a user account you can use to login to the backoffice. Create your user account in the backoffice with the same username as the Active Directory account you intend to use and then change the owin:appStartup value. It doesn't matter which password you set in Umbraco as it's going to ignore it and try checking against AD.

  • Satish 20 posts 90 karma points
    Mar 16, 2023 @ 00:28
    Satish
    0

    I know this is old post but I am facing issues with setting up Active Directory. I followed your instructions also added the AdAspNetProvider. I am on Umbraco 7.4.3. post these settings, my Backoffice login pages opens up but it doesn't accept my Active directory login nor local Umbraco authentication. Any suggestions?

    enter image description here

  • Brian Powell 44 posts 199 karma points c-trib
    Mar 16, 2023 @ 16:12
    Brian Powell
    0

    UmbBackofficeMembershipProvider had to be re-architected to support Umbraco 7.7.2 and newer. Umbraco 7.4.3 requires you use UmbBackofficeMembershipProvider 3.0.0, which is available on NuGet. Are you sure you have the correct version installed?

  • Satish 20 posts 90 karma points
    Mar 16, 2023 @ 16:25
    Satish
    0

    Hello Brian, I downloaded from Umbraco itself ( UmbBackofficeMembershipProvider_3.0.0.zip ) for v7.4.3 and installed from backOffice.

    https://our.umbraco.com/packages/backoffice-extensions/umbraco-back-office-active-directory-aspnet-provider/

    thanks Satish

  • Jay 413 posts 639 karma points
    May 03, 2016 @ 13:06
    Jay
    0

    Thanks Brian, Let me try it out

  • Jay 413 posts 639 karma points
    May 03, 2016 @ 13:32
    Jay
    0

    Good news. Working sweet like what you said Brian. Thanks for the help ;)

  • kapil 3 posts 73 karma points notactivated
    Jul 26, 2016 @ 15:35
    kapil
    0

    Hi @JLon, Could You please help me to setup AD in umbraco 7.4.3 . I tried with all steps but still not able to login with AD credential.

  • Satish 20 posts 90 karma points
    Mar 16, 2023 @ 00:44
    Satish
    0

    Hi Kapil, were you able to solve this ?

  • Dave S 13 posts 77 karma points
    Feb 20, 2018 @ 16:17
    Dave S
    0

    Just thought i'd share my experience here, hopefully it helps someone. I've used brian's sourcecode on github rather than using the nuget file as I wanted to step through the code and debug the error. It turned out I had an existing user with the same email address from another test i'd been doing.

    I changed the users email through sql server management studio and then it worked!

    Tip: Making your account an Umbraco Admin account:

    1. Login with your windows domain account, this allows the user manager to setup your account in the database.
    2. Open sql server management studio and add a mapping for your user to the admin account in the [umbracoUser2UserGroup] table (admin was group id 1 on my install).
    3. Logout and in again and you're good to go with your admin account too.
Please Sign in or register to post replies

Write your reply to:

Draft