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'.
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.
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?
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().
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.
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:
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 ...
@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.
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?
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.
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.
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?
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.
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:
I am not able to figure out what I am missing. Could you please help?
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.
@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:
And if I use double slash, it gives connection error as I had mentioned earlier.
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, @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?
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.
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.
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?
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?
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:
Login with your windows domain account, this allows the user manager to setup your account in the database.
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).
Logout and in again and you're good to go with your admin account too.
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'.
Has anybody has this issue and resolved?
Hi Govi,
Can you provide code of login method ? What method make this crash ?
Thanks, Alex
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
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
In web.config:
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?
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().
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.
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
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:
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 ...
@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.
Any updates for this?
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?
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.
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.
See https://github.com/Bitmapped/UmbBackofficeMembershipProvider for code and instructions on how to fix this issue.
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
If you upgraded from before 7.3.0, you need to change
UsersMembershipProvider
to use the default Umbraco provider.It should look like:
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.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
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.
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.
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:
I am not able to figure out what I am missing. Could you please help?
Thanks.
@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.
@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:
And if I use double slash, it gives connection error as I had mentioned earlier.
@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.
@Brian,
I changed the version to 4.0.0.0 , but it still throws the same error.
@Tejashri Kadam: Did you ever get this resolved? I'm having the same issue.
@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?
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.
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.
Then create an Umbraco Admin user with the username of Tester88 (should i leave the password untouch here?) and then switch it back to
And try to login using my AD user of Tester88 which i've created earlier?
Thanks
@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:
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.
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?
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?
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
Thanks Brian, Let me try it out
Good news. Working sweet like what you said Brian. Thanks for the help ;)
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.
Hi Kapil, were you able to solve this ?
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:
is working on a reply...