Copied to clipboard

Flag this post as spam?

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


  • David Bailey 3 posts 72 karma points
    Apr 25, 2018 @ 21:30
    David Bailey
    0

    Sites using custom membership providers won't authenticate when using Courier

    Using Umbraco 7.10.0

    I get this error when I try to publish to my staging site from my development machine.

    Server was unable to process request. ---> User: courier.admin could not be authenticated
    

    I am using the following packages:

    UmbBackofficeMembershipProvider 4.1.1

    Courier Express 3.1.6

    The license was created today and exists on both machines. The username is in the database for both machines. I've tried the useLegacyEncoding attribute in the web.config with no success. I've also installed Courier at both locations. Nothing stands out in the logs.

    2018-04-25 17:22:48,771 [9] DEBUG Umbraco.Courier.Persistence.V6.NHibernate.NHibernateSessionManager - [Thread 9] Loading factory
    2018-04-25 17:22:50,808 [9] DEBUG Umbraco.Courier.Persistence.V6.NHibernate.NHibernateSessionManager - [Thread 9] Complete (took 2045ms)
    

    FWIW: It is working with the same custom auth provider in our 7.9 install without this issue.

  • David Bailey 3 posts 72 karma points
    Jun 03, 2018 @ 01:57
    David Bailey
    0

    I created a solution that allows legacy calls to use Active Directory to not error out. This class is compatible with the ActiveDirectoryBackOfficeUserPasswordChecker class. It allows implementers to use Active Directory in Courier and elsewhere the legacy MembershipProvider is used. The user still needs to be created in the UI or database.

    using System;
    using System.Configuration;
    using System.DirectoryServices.AccountManagement;
    using System.Web.Security;
    using Umbraco.Web.Security.Providers;
    
    namespace Umbraco.Backoffice.ActiveDirectoryMembership
    {
        public class UmbracoActiveDirectoryMembershipProvider : UsersMembershipProvider
        {
            public override bool AllowManuallyChangingPassword => false;
    
            public override bool ValidateUser(string username, string password)
            {
    
                bool flag = false;
    
                using (PrincipalContext context = new PrincipalContext(ContextType.Domain, ConfigurationManager.AppSettings["ActiveDirectoryDomain"]))
                {
                    flag = context.ValidateCredentials(username, password);
                }
    
                return flag;
            }
    
    
            protected override bool PerformChangePassword(string username, string oldPassword, string newPassword)
            {
                throw new NotSupportedException("The password must be changed in Active Directory");
            }
    
            protected override bool PerformChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer)
            {
                throw new NotSupportedException("Password Question/Answer is not supported by AD");
            }
    
            protected override MembershipUser PerformCreateUser(string memberTypeAlias, string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
            {
                return base.PerformCreateUser(memberTypeAlias, username, password, email, passwordQuestion, passwordAnswer, isApproved, providerUserKey, out status);
            }
    
            protected override string PerformGetPassword(string username, string answer)
            {
                throw new NotSupportedException("The Active Directory Provider does not support getting the password");
            }
    
            protected override string PerformResetPassword(string username, string answer, string generatedPassword)
            {
                throw new NotSupportedException("The password must be reset in Active Directory");
            }
    
        }
    
    
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft