locked
Custom code on user login RRS feed

  • Question

  • Hi,

    Is there any mechanism in SharePoint 2013 that I can utilize to launch a piece of custom code (an initialization logic in our database) when a user logs in to SharePoint?

    Thanks,

    Leszek


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com

    Thursday, May 7, 2015 2:48 PM

Answers

  • Hi,

    Its very much possible all you need is to configure the Form Based Authentication on your web application.

    Please check this link

    FBA & Windows mixed mode

    obtnLogin_Click method write your own logic.


    Murugesa Pandian| MCPD | MCTS |SharePoint 2010


    • Edited by Murugesa Pandian Thursday, May 7, 2015 5:30 PM
    • Marked as answer by ata6502 Friday, May 15, 2015 1:32 PM
    Thursday, May 7, 2015 5:29 PM

All replies

  • Hi,

    Its very much possible all you need is to configure the Form Based Authentication on your web application.

    Please check this link

    FBA & Windows mixed mode

    obtnLogin_Click method write your own logic.


    Murugesa Pandian| MCPD | MCTS |SharePoint 2010


    • Edited by Murugesa Pandian Thursday, May 7, 2015 5:30 PM
    • Marked as answer by ata6502 Friday, May 15, 2015 1:32 PM
    Thursday, May 7, 2015 5:29 PM
  • Hi Leszek,

    From your description, my understanding is that you want to trigger your custom logic when user login in.

    Besides Murugesa Pandian’s method to configure Form Based  Authentication, you could customize a login in page, and then trigger your custom logic.

    In addition, you could use httpmodule to monitor user login as code below:

    void context_PreRequestHandlerExecute(object sender, EventArgs e)
    
    {
    
                    HttpApplication app = sender as HttpApplication; 
    
                    if (app != null)
    
                    {
    
                                    Page page = app.Context.CurrentHandler as Page; 
    
                                    if (page != null)
    
                                    {
    
                                                    if (HttpContext.Current.Request.Url.AbsoluteUri.Contains("spcial a url"))
    
                                                    {
    
                                                                    // write your custom logic here
    
                                                    }
    
                                    }
    
                    }
    
    }
    

    You could refer to this article about how to use httpmodule in SharePoint:

    http://www.jeanpaulva.com/index.php/2014/10/30/sharepoint-http-module-example/

    Best Regards,

    Vincent Han


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Proposed as answer by Dennis Guo Thursday, May 14, 2015 9:34 AM
    Friday, May 8, 2015 9:37 AM
  • Thanks for your help. I think I will go for Form Based Authentication.

    Leszek


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com

    Friday, May 15, 2015 1:32 PM