Copied to clipboard

Flag this post as spam?

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


  • Mark Arndt Lønquist 20 posts 89 karma points
    Sep 28, 2016 @ 08:34
    Mark Arndt Lønquist
    0

    Active Directory login works, but menu not loading

    Hello there.

    I've managed to get backoffice logins working with Active Directory. However, upon initial login, the side-menu does not load, and I get some 417 Invalid token errors in the console. 417 Invalid token errors

    If I hit F5 to reload the page, the error goes away, and the side-menu is loaded just fine.

    This is the code:

    var result = Task.FromResult(BackOfficeUserPasswordCheckerResult.InvalidCredentials);
    
            try
            {
                var pc = new PrincipalContext(ContextType.Domain, WebConfigurationManager.AppSettings["ldapAddress"]);
    
                var isValid = pc.ValidateCredentials(user.UserName, password);
                if (isValid)
                {
                    result = Task.FromResult(BackOfficeUserPasswordCheckerResult.ValidCredentials);
                }
            }
            catch (Exception ex)
            {
                result = Task.FromResult(BackOfficeUserPasswordCheckerResult.InvalidCredentials);
                LogHelper.Error(typeof(ActiveDirectoryAuthenticator), "Error logging in using ActiveDirectory", ex);
            }
    
            return result;
    

    Note: Some code left out (does not affect the issue at hand)

    And this is where I setup the UmbracoCustomOwinStartup:

     public class UmbracoCustomOwinStartup
    {
        public void Configuration(IAppBuilder app)
        {
            var applicationContext = ApplicationContext.Current;
            app.ConfigureUserManagerForUmbracoBackOffice<BackOfficeUserManager, BackOfficeIdentityUser>(
                applicationContext,
                (options, context) =>
                {
                    var membershipProvider = MembershipProviderExtensions.GetUsersMembershipProvider().AsUmbracoMembershipProvider();
                    var userManager = BackOfficeUserManager.Create(options,
                        applicationContext.Services.UserService,
                        applicationContext.Services.ExternalLoginService,
                        membershipProvider);
    
                    userManager.BackOfficeUserPasswordChecker = new ActiveDirectoryAuthenticator();
                    return userManager;
                });
    
            app.UseUmbracoBackOfficeCookieAuthentication(ApplicationContext.Current)
               .UseUmbracoBackOfficeExternalCookieAuthentication(ApplicationContext.Current);
        }
    }
    

    It seems the cookie being set is not correct, as it changes after I press F5.

    Anyone have an idea?

  • David Peck 687 posts 1863 karma points c-trib
    Sep 28, 2016 @ 11:32
    David Peck
    0

    Hi Mark,

    I don't have an answer, sorry. However I just posted a request for some help on setting this up. Where did you find the info to progress as far as you have? Are you using Azure Active Directory or vanilla AD?

    I'll happily help you troubleshoot this, if I can catch up to where you've got with this.

  • David Peck 687 posts 1863 karma points c-trib
    Sep 28, 2016 @ 12:13
    David Peck
    0

    To answer my question, this is the post I've been looking for: http://skrift.io/articles/archive/authenticate-to-umbraco-73plus-using-active-directory/

  • Magic Mike 3 posts 73 karma points
    Nov 20, 2020 @ 12:59
  • David Peck 687 posts 1863 karma points c-trib
    Nov 20, 2020 @ 13:47
Please Sign in or register to post replies

Write your reply to:

Draft