How to use asp.net login control

Posted by Community Admin on 03-Aug-2018 21:39

How to use asp.net login control

All Replies

Posted by Community Admin on 18-Jan-2011 00:00

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,

Posted by Community Admin on 19-Jan-2011 00:00

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

Posted by Community Admin on 19-Jan-2011 00:00

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.

Posted by Community Admin on 19-Jan-2011 00:00

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

This thread is closed