locked
Custom Webpart for login RRS feed

  • Question

  • Hi,

    I need a create a webpart for login in aspx. I don't need existing login webparts. I need to deploy this to my site. Please let me know the steps to acheive the same.
    • Edited by Mike Walsh FIN Wednesday, December 16, 2009 2:54 PM sig removed. Do not ask people to mark your post as an answer.
    Wednesday, November 25, 2009 12:00 PM

Answers

  • From your question, i can infer that you are using forms authentication for your portal and you need a custom log-in form, instead of an out-of-box.  I'd recommend you not to impact the existing login.aspx present in the _LAYOUTS directory.  I'd recommend you to create an application page (aspx) with custom log-in controls. Deploy this app page to the _LAYOUTS directory and mention the url of this application page as the LOGINURL of the forms authentication settings in web.config file.
    This should take care of redirecting the user to the custom log-in page.

    Then, whenever the user clicks the log-in button, call the Membership.ValidateUser method (which would take care of invoking membership and role provider) for authentication and authorization purpose. Once the user is authenticated and authorized you can re-direct the user to the original page.

    if (Membership.ValidateUser(UserTxt.Text, PwdTxt.Text))
    {
      // Do Secure ID thing here.
      // Redirect the user to the requested page.
      FormsAuthentication.RedirectFromLoginPage(UserTxt.Text,
        SaveChk.Checked);
    }


    Refer the following article.
    http://msdn.microsoft.com/en-us/library/bb975135.aspx#MOSSFBAPart2_CustomLogonPage

    You can also develop the log-in widget as the web part, add it to the sharepoint page (instead of application page), then mention this sharepoint page as the log-in url in web.config. This way you can achieve the same functionality with web part.

    The concept is the same, whichever way you go. Basically you need to programmatically authenticate and authorize the user
    Sundar Narasiman
    • Marked as answer by BiztalkGhost Thursday, November 26, 2009 10:26 AM
    Thursday, November 26, 2009 4:50 AM
  • The Forms Based Authentication solution of the Community Kit for SharePoint has such a webpart. I suggest that you refer to its components for help.

    http://cks.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=17901
    • Proposed as answer by shridha Thursday, November 26, 2009 6:58 AM
    • Marked as answer by Mike Walsh FIN Wednesday, December 16, 2009 2:54 PM
    Thursday, November 26, 2009 6:16 AM

All replies

  • From your question, i can infer that you are using forms authentication for your portal and you need a custom log-in form, instead of an out-of-box.  I'd recommend you not to impact the existing login.aspx present in the _LAYOUTS directory.  I'd recommend you to create an application page (aspx) with custom log-in controls. Deploy this app page to the _LAYOUTS directory and mention the url of this application page as the LOGINURL of the forms authentication settings in web.config file.
    This should take care of redirecting the user to the custom log-in page.

    Then, whenever the user clicks the log-in button, call the Membership.ValidateUser method (which would take care of invoking membership and role provider) for authentication and authorization purpose. Once the user is authenticated and authorized you can re-direct the user to the original page.

    if (Membership.ValidateUser(UserTxt.Text, PwdTxt.Text))
    {
      // Do Secure ID thing here.
      // Redirect the user to the requested page.
      FormsAuthentication.RedirectFromLoginPage(UserTxt.Text,
        SaveChk.Checked);
    }


    Refer the following article.
    http://msdn.microsoft.com/en-us/library/bb975135.aspx#MOSSFBAPart2_CustomLogonPage

    You can also develop the log-in widget as the web part, add it to the sharepoint page (instead of application page), then mention this sharepoint page as the log-in url in web.config. This way you can achieve the same functionality with web part.

    The concept is the same, whichever way you go. Basically you need to programmatically authenticate and authorize the user
    Sundar Narasiman
    • Marked as answer by BiztalkGhost Thursday, November 26, 2009 10:26 AM
    Thursday, November 26, 2009 4:50 AM
  • Thanks for your reply.

    Since I'm new to MOSS. Kindly guide me through the steps.

    1. I will create a login.aspx in ASP.Net WebApplication
    2. Use SQLHelper class to connect to aspnetdb[membershipdb]
    3. In my .cs file on login_clicked i will have code as you have mentioned.
    4. I should copy the .aspx and dll and config file to my sites _layout folder

    Correct me on the above steps.

    One more q's

    1. How this way of creating is different from creating login webpart through aspx pages and deploying as .wsp file ?

    Thanks in advance
    • Edited by Mike Walsh FIN Wednesday, December 16, 2009 2:54 PM sig removed. Do not ask people to mark your post as an answer.
    Thursday, November 26, 2009 5:45 AM
  • The Forms Based Authentication solution of the Community Kit for SharePoint has such a webpart. I suggest that you refer to its components for help.

    http://cks.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=17901
    • Proposed as answer by shridha Thursday, November 26, 2009 6:58 AM
    • Marked as answer by Mike Walsh FIN Wednesday, December 16, 2009 2:54 PM
    Thursday, November 26, 2009 6:16 AM