locked
LightSwitch Custom form authentication RRS feed

  • Question

  • Hi, i'm developing a solution using Lightswitch deployed as web application.

    All the users that can use the application are stored in a db table: I'd like to authenticate users on my custom table.  

    Is it possible?

    Thanks.

    Monday, September 12, 2011 4:54 PM

Answers

All replies

  • The standard aspnet security is used throughout all .NET platforms for the web.   I recommend that you create aspnet entries based on your current proprietary custom table. 

    We have extended information that integrates with the aspnet security tables - I would expect most LOB / ERP solutions would also do the same.

    My recommendation is that you integrate with the aspnet security.

    See Matt's blog:  How to reference security entities in LightSwitch

    Here's info on creating users from your current table provided by William: 

    Programatically creating users 

    Here's Richard Waddell blog on the topic:

    Creating a Relationship on current User through SecurityData.UserRegistrations Table

     


    Monday, September 12, 2011 6:28 PM
  • The method I use mostly is use forms security and keep forms/asp tables alone. Asp will handle auth as normal and you get an authenticated UserName on logon. Check anywhere with Application.User.Name.  You can then map that name into your Users table with any data you want.

    Tuesday, September 13, 2011 12:38 AM
  • Just a note that I also use Forms security and track audit trails based on the UserName rather than table PKs that may disappear.  UserNames are then matched to applicable tables - like an employee table.

    Yes, generally, I will have an Active boolean value in most tables (loosely) related to the aspnet User table.

    hmmm . . . the situation gets more complex with mulitple LS apps working together where each user has a separate aspnet user/profile, etc.  There are different application solutions that members of our community use to manage this. 

    Tuesday, September 13, 2011 7:27 PM
  • Actually, have any of you considered what will happen if a user's username changes? Like if they get married?

    You'll have orphan data that won't be able to be matched any more.

    The best way is to do a lookup, & store the integer ID. We explain this in more depth in our book: Pro Visual Studio LightSwitch 2011 Development.

    If you're worried about a user being "deleted", don't allow deletion of users, but simply "mark" them as deleted with a flag. IMO users should NEVER be deleted, as they can be linked to so much history.


    Yann

    (plus ça change, plus c'est la même chose!)

    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, remember to "Mark as Answer".

    This will help people find the answers that they're looking for more quickly.


    Wednesday, September 14, 2011 5:41 AM
    Moderator
  • Wednesday, March 28, 2012 11:03 AM