Copied to clipboard

Flag this post as spam?

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


  • Ben McKean 272 posts 549 karma points
    Sep 16, 2015 @ 09:22
    Ben McKean
    0

    Can't log in to Umbraco when this is added

    Hi,

    I'm attempting to use this package. Eventually it'll be for both Members and Umbraco users but for now just trying to get Members set up.

    When I add the necessary items in web.config I can no longer log into Umbraco. I'm using 7.28

    My config looks as follows:

    Connection string:

      <connectionStrings>
        <remove name="umbracoDbDSN" />
        <add name="umbracoDbDSN" connectionString="Data Source=|DataDirectory|\Umbraco.sdf;Flush Interval=1;" providerName="System.Data.SqlServerCe.4.0" />
        <!-- Important: If you're upgrading Umbraco, do not clear the connection string / provider name during your web.config merge. -->
        <add name="MyMembershipConnectionString" connectionString="LDAP://[Domain],OU=Users,DC=[Domain],DC=co,DC=uk"  />
      </connectionStrings>
    

    Membership provider:

    <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="MyMembersMembershipProvider" type="RB.ActiveDirectoryProviders.ActiveDirectoryUmbracoMembersMembershipProvider, RB.ActiveDirectoryProviders" connectionStringName="MyMembershipConnectionString" connectionUsername="****" connectionPassword="*****" attributeMapUsername="sAMAccountName" defaultMemberType="Member" />     
      </providers>
    </membership>
    

    Role provider:

    <roleManager enabled="true" defaultProvider="MyMembersRoleProvider">
      <providers>
        <clear />
        <add name="UmbracoRoleProvider" type="Umbraco.Web.Security.Providers.MembersRoleProvider" />
        <add name="MyMembersRoleProvider" type="RB.ActiveDirectoryProviders.ActiveDirectoryRoleProvider, RB.ActiveDirectoryProviders" connectionStringName="MyMembershipConnectionString" connectionUsername="*****" connectionPassword="****" groupsToUse="Group,Brand" />
      </providers>
    </roleManager>
    

    When I attempt to log into Umbraco I get a JS console error: enter image description here

  • Dan Lister 416 posts 1974 karma points c-trib
    Sep 16, 2015 @ 11:51
    Dan Lister
    1

    Hi Ben,

    It looks like you have your default Role Provider setup correctly but not the default Membership Provider. For Umbraco Member's to use AD, change the default Membership Provider to be as follows:

    <membership defaultProvider="MyMembersMembershipProvider" userIsOnlineTimeWindow="15">
    

    I hope that helps.

    Thanks, Dan.

  • Ben McKean 272 posts 549 karma points
    Sep 16, 2015 @ 12:28
    Ben McKean
    0

    Thanks Dan. I've changed that and can now login :)

    Another questions. When viewing pages, I expected to be able to get the current user, should I be able to?

    HttpContext.Current.User.Identity.Name is null and System.Web.Security.Membership.GetUser() throws an error "Additional information: The parameter 'username' must not be empty".

    I'd expected to see my user or be able to get my user.

  • Dan Lister 416 posts 1974 karma points c-trib
    Sep 16, 2015 @ 13:12
    Dan Lister
    0

    Hey Ben,

    The following should allow you to get each type of authenticated member, both Forms and Windows:

    // Windows User
    HttpContext.Current.Request.LogonUserIdentity.Name
    
    // Forms User
    HttpContext.Current.User.Identity.Name
    

    Hope that helps.

    Thanks, Dan.

  • Ben McKean 272 posts 549 karma points
    Sep 17, 2015 @ 11:03
    Ben McKean
    0

    Here is what I've done so far: Installed your package and set up web.config accordingly Set public access for a page that is role based, this is set to go to a login page The login page redirects to winlogin.aspx I have the following for winlogin.aspx in web.config

    <location path="winlogin.aspx">
    <formsAuthenticationWrapper enabled="false" />
    <system.webServer>
    <security>
    <!--Enable IIS Windows authentication for the login page-->
    <authentication>
    <windowsAuthentication enabled="true">
    <providers>
    <clear/>
    <add value="NTLM"/>
    <add value="Negotiate"/>
    </providers>
    </windowsAuthentication>
    <anonymousAuthentication enabled="false" />
    </authentication>
    </security>
    </system.webServer>
    </location>
    

    When I try to access the page I get windows prompt to log in but when I enter my windows credentials I get a 401.2 error Is there anything else I need to do in IIS or anthing else? I've tried outputting the user to the screen and its IUSR which doesn't look right

    Also, I tried a normal login form that uses the UmbLoginController - should this automatically be able to log members in using their AD credentials? I'm getting invalid username or password from it at the moment.

    Thanks

  • Ben McKean 272 posts 549 karma points
    Sep 18, 2015 @ 11:02
    Ben McKean
    0

    I'm going to leave the auto login for the time being. Just trying to login using AD credentials

    should my login form below be correct? Just that its not hitting your ValidateUser method and is just coming back with invalid username or password

    @using (Html.BeginUmbracoForm<UmbLoginController>("HandleLogin", null, new { @class = "sign-in" }))
    {
        <h2>Sign in</h2>
            <fieldset>
    
                @if (!ViewData.ModelState.IsValid)
                {
    
                    foreach (ModelState modelState in ViewData.ModelState.Values)
                    {
                        var errors = modelState.Errors;
    
                        if (errors.Any())
                        {
                            <ul class="validation-summary-errors">
                                @foreach (ModelError error in errors)
                                {
                                    <li>
                                        <span class="fatal"></span>
                                        @error.ErrorMessage
                                    </li>
                                }
                            </ul>
                        }
                    }
                }
    
                @Html.TextBoxFor(m => loginModel.Username, new { required = "required", @placeholder = "Email address" })
                @Html.ValidationMessageFor(m => loginModel.Username)
    
                @Html.PasswordFor(m => loginModel.Password, new { required = "required", @placeholder = "Password" })
                @Html.ValidationMessageFor(m => loginModel.Password)
                <br />
                @Html.HiddenFor(m => loginModel.RedirectUrl)
                <button class="btn">Sign in</button>
            </fieldset>
    
    }
    
  • Kai Leske-Heed 8 posts 79 karma points
    Mar 18, 2016 @ 13:47
    Kai Leske-Heed
    0

    Did you ever manage to get this working. I am looking for an intranet solution to allow all our internal users to be able to log in automatically and set their permissions automatically.

    Now I was thinking of doing this in a wrapper around anything called from umbraco, but that I obviously a bit of a clunky solution.

  • Ben McKean 272 posts 549 karma points
    Mar 18, 2016 @ 13:58
    Ben McKean
    0

    Hi Kai,

    yes I did get it working. Which part of it are you stuck on?

  • Kai Leske-Heed 8 posts 79 karma points
    Mar 30, 2016 @ 14:53
    Kai Leske-Heed
    0

    I am stuck at the bit where you have started setting up a login page. Now my issue seems to be that 7.2 works differently. I have everything configured in web.config and it's on a clean install of 7.2

    I can set up a login page template and a winlogin.aspx but I was a bit confused as to what you were doing in the web.config file with your code there.

    What I want to do is have the automatic login for members and hide sections of umbraco based on role.

    I am not worried about having AD manage the back office at this point.

Please Sign in or register to post replies

Write your reply to:

Draft