1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / How to use asp.net login control

How to use asp.net login control

4 posts, 0 answered
  1. Doug
    Doug avatar
    34 posts
    Registered:
    20 Sep 2010
    18 Jan 2011
    Link to this post
    Hey all,

    I was able to successfully programmatically create a user by using the 'CreateUserWizard' and was able to assign the new user to a specific role. I am now trying to figure out how to use a asp.net login control with Sitefinity 4.

    <asp:Login ID="Login" OnLoginError="Login_LoginError" OnLoggingIn="Login_LoggingIn" OnAuthenticate="Login_Authenticate" DestinationPageUrl="/" runat="server">
                            <LayoutTemplate>
                                <table style="margin-top:0px;">
                                    <tr>
                                        <td align="right" style="padding-right:10px;">User Name:</td>
                                        <td>
                                            <asp:TextBox ID="UserName" MaxLength="256" Width="185" runat="server" />
                                            <asp:RequiredFieldValidator ID="UserNameRequiredFieldValidator" ControlToValidate="UserName" Display="Dynamic" Text="* Required" runat="server" />
                                        </td>
                                        <asp:RequiredFieldValidator ID="UserNameRequired" ControlToValidate="UserName" ValidationGroup="Login" runat="server" />
                                    </tr>
                                    <tr>
                                        <td align="right" style="padding-right:10px;">Password:</td>
                                        <td>
                                            <asp:TextBox ID="Password" MaxLength="128" Width="185" TextMode="Password" runat="server" />
                                            <asp:RequiredFieldValidator ID="PasswordRequiredFieldValidator" ControlToValidate="Password" Display="Dynamic" Text="* Required" runat="server" />
                                        </td>
                                        <asp:RequiredFieldValidator ID="PasswordRequired" ControlToValidate="Password" ValidationGroup="Login" runat="server" />
                                    </tr>
                                    <tr>
                                        <td> </td>
                                        <td colspan="2">Not a member? <a href="/Register">Register here</a>.</td>
                                    </tr>
                                    <tr>
                                        <td> </td>
                                        <td>Forgot your password? <a href="/Password-Recovery">Click here</a>.</td>
                                    </tr>
                                </table>
                                <table class="loginPng">
                                    <tr>
                                        <td width="60"> </td>
                                        <td colspan="2" align="center"><asp:ImageButton ID="Submit" CommandName="Login" ImageUrl="/CustomTemplates/MyTemplate/App_Themes/Main/Images/Login_btn.png" runat="server" /></td>
                                    </tr>
                                </table>
                            </LayoutTemplate>
                        </asp:Login>

    I've provided the following delegates.

    protected void Login_LoginError(object sender, EventArgs e)
    {
    }
     
    protected void Login_LoggingIn(object sender, LoginCancelEventArgs e)
    {
    }
     
    protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
    {
    }

    1. Do I need to provide an OnLoggingIn and OnAuthenticate delegate methods like I have previously done?
           a. If I need to provide one or both of these methods, what are the steps needed to authenticate a user?
    2. Is the login control automatically communicate with sitefinity's data store to authenticate users or does one need to implement custom logic?
    3. Do I need to add anything to the web.config to get authentication with asp login control to work with Sitefinity?

    Thanks,
  2. Dido
    Dido avatar
    149 posts
    Registered:
    24 Sep 2012
    19 Jan 2011
    Link to this post
    Hi Doug,

    Basically, you needn't use it. Sitefinity defines a public LoginControl that you can drag and drop from the widget toolbar in page editor.

    To authenticate, you need something like

    User sfUser;
    var result = SecurityManager.AuthenticateUser(this.MembershipProvider, this.UserName, this.Password, this.RememberMeSet, out sfUser);
    bool authenticated = result == UserLoggingReason.Success;

    We sent several replies to the other request you had with the same topic, so you can check them for reference.

    All the best,
    Dido
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Doug
    Doug avatar
    34 posts
    Registered:
    20 Sep 2010
    19 Jan 2011
    Link to this post
    I was trying to do this in a custom master I created. What is the sitefinity login control I should use in the mark up of my master page?

    Is it something like this: <sf:Login ..... />? Basically, with my custom master page, I want to declare the control instead of dropping on to a page that inherits from my master page.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 Jan 2011
    Link to this post
    Hello Doug,

    You have to register a tag prefix for Telerik.Sitefinity.Web.UI.PublicControls namespace, Assembly- Telerik.Sitefinity

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
4 posts, 0 answered