This code:
https://our.umbraco.com/documentation/Reference/Security/authenticate-with-AD works for 8.0. For 8.1, you need to add
Mapper, after membershipProvider,.
Then make sure you edit the web.config. Change it to:
<add key="owin:appStartup" value="ActiveDirectoryStartup" />
where ActiveDirectoryStartup is the name of your OWIN start.
I created a custom ActiveDirectoryPasswordChecker, which also creates the user if it doesn't exist, but that might be over the top.
namespace ActiveDirectoryLogin
{
public class ActiveDirectoryStartup : UmbracoDefaultOwinStartup
{
public override void Configuration(IAppBuilder app)
{
//ensure the default options are configured
base.Configuration(app);
// active directory authentication
ConfigureBackofficeActiveDirectoryPasswords(app);
}
private void ConfigureBackofficeActiveDirectoryPasswords(IAppBuilder app)
{
// https://our.umbraco.com/forum/extending-umbraco-and-using-the-api/96654-applicationcontextcurrent-in-umbraco-8#comment-308432
var applicationContext = Umbraco.Core.Composing.Current.Services;
IGlobalSettings GlobalSettings = Umbraco.Core.Composing.Current.Configs.Global();
IUmbracoSettingsSection UmbracoSettings = Umbraco.Core.Composing.Current.Configs.Settings();
app.ConfigureUserManagerForUmbracoBackOffice<BackOfficeUserManager, BackOfficeIdentityUser>(Umbraco.Web.Composing.Current.RuntimeState, GlobalSettings,
(options, context) =>
{
var membershipProvider = MembershipProviderExtensions.GetUsersMembershipProvider().AsUmbracoMembershipProvider();
var userManager = BackOfficeUserManager.Create(options,
applicationContext.UserService,
applicationContext.MemberTypeService,
applicationContext.EntityService,
applicationContext.ExternalLoginService,
membershipProvider,
Mapper,
UmbracoSettings.Content, GlobalSettings);
//Set your own custom IBackOfficeUserPasswordChecker
userManager.BackOfficeUserPasswordChecker = new ActiveDirectoryPasswordChecker();
return userManager;
});
}
}
}
(replace ActiveDirectoryPasswordChecker() with ActiveDirectoryBackOfficeUserPasswordChecker() for the default, or create the ActiveDirectoryPasswordChecker() to create your own)
AD for backend
Hi,
Is there a detail tutorial of how to get AD to work for backend login?
There is this URL;
https://our.umbraco.com/documentation/Reference/Security/#authenticating-with-active-directory-credentials
but i was hopeing someone would of done something a little more detailed for the noobs out there :)
Thanks
8.0 or 8.1?
This code: https://our.umbraco.com/documentation/Reference/Security/authenticate-with-AD works for 8.0. For 8.1, you need to add
Mapper,
aftermembershipProvider,
. Then make sure you edit the web.config. Change it to:<add key="owin:appStartup" value="ActiveDirectoryStartup" />
where ActiveDirectoryStartup is the name of your OWIN start.I created a custom ActiveDirectoryPasswordChecker, which also creates the user if it doesn't exist, but that might be over the top.
Full code for 8.1:
namespace ActiveDirectoryLogin { public class ActiveDirectoryStartup : UmbracoDefaultOwinStartup { public override void Configuration(IAppBuilder app) { //ensure the default options are configured base.Configuration(app);
}
(replace ActiveDirectoryPasswordChecker() with ActiveDirectoryBackOfficeUserPasswordChecker() for the default, or create the ActiveDirectoryPasswordChecker() to create your own)
is working on a reply...