Copied to clipboard

Flag this post as spam?

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


  • Pete 213 posts 285 karma points
    Nov 24, 2011 @ 19:21
    Pete
    0

    ASP:Login Redirect

    Hey All

    I've got a role-based protected folder called "intranet" and use a asp:login in the login template like so:

    <umbraco:Macro  Alias="Login" runat="server"></umbraco:Macro>


    Which points to login.ascx which looks like:

     

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Login.ascx.cs" Inherits="PTMAuth.Login" %>
    <form id="Form1" runat="server">
    <asp:Login ID="Login1" runat="server" onauthenticate="Login1_Authenticate"></asp:Login>
    </form>


    Then in the code behind I've got:

    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
    if (Membership.Provider.ValidateUser(Login1.UserName.ToString(), Login1.Password.ToString()))
    {
    e.Authenticated = true;
    bool m_useSession = false;
    Member m = Member.GetMemberFromLoginNameAndPassword(Login1.UserName.ToString(), Login1.Password.ToString());
    Member.AddMemberToCache(m, m_useSession, new TimeSpan(0, 15, 0));
    Response.Redirect("~/intranet/intranet.aspx",false);
    }
    else
    {
    e.Authenticated = false;
    Login1.FailureText = "Not Logged In";
    }
    }

    In the webconfig, i've got it accessing an AD store for the membership provider like so:

    <add name="CustomMembershipProvider"
    type="CustomMembershipProvider"
    connectionStringName="ADConnectionString"
    connectionUsername="CN=ADAMAdmin,OU=Users,O=TestDirectory"
    connectionPassword="password"
    connectionProtection="None"
    attributeMapUsername="userPrincipalname"
    enableSearchMethods="true"
    defaultMemberTypeAlias="User"/>

     

     

    <add name="ADConnectionString" connectionString="LDAP://localhost:389/OU=Users,O=TestDirectory" />


    When I attempt log in, it seems to authenticate OK as it does'nt throw an error, and also it makes the auth cookie, however it does not redirect to intranet.aspx, it just loops back to the login page.

    Thanks
    Peter

  • Pete 213 posts 285 karma points
    Nov 24, 2011 @ 20:11
    Pete
    0

    Ah just noticed on the stacktrace...

    " umbracoRequestHandler Page protected
    No member with loginname: peter Exists

    umbracoRequestHandler
    Not logged in - redirecting to login page..."

    So looks like it's not logging the user in, even though it's making the auth cookie? Is there something else I'm missing? is there another cookie it should be making also? UMB_MEMBER ?



  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies