locked
API Key - Authentication - Sessions - Dynamic database binding RRS feed

  • Question

  • Hi,

    I have the below mentioned scenario for buliding WCF Data Services using Entity Framework 4.1.

    1) Each our customers needs to be given a unique key to access the Data Service. Based on the Key that is passed as part of the Query String the Data Service has to connect to a different MySqlserver and a different database within that server.

    How can point 1) above be implemented?

    2) Each customer has to Login with their username and password and if successfull can perforn any number of service operations until he logs out (or until he closes the browser)

    How can point 2) above be implemented? Are there any samples available (in ASP .Net AJAX).

    3) Some operations do not require login and can be performed by any user.

    Any help with a comprehensive end-to-end walkthrough sample will be greatly appreciated.

    Thank you.

    Saturday, August 20, 2011 5:40 PM

Answers

  • #1 - in your DataService<T> derived class override the CreateDataSource method, look at the incomming request (assuming you're using ASP.NET you can access this through the static HttpContext) and return a new instance of the ObjectContext derived class which connects to the right database.

    #2 - You should be able to find some help in these blogs: http://blogs.msdn.com/b/astoriateam/archive/tags/authentication/

    #3 - In #2 you decide on per-request basis if it needs to be authenticated or not. So that shoult be pretty straightforward.

    Thanks,


    Vitek Karas [MSFT]
    • Marked as answer by Rosy Madhuri Friday, August 26, 2011 6:47 AM
    Sunday, August 21, 2011 2:42 PM
    Moderator
  • #1 - in your DataService<T> derived class override the CreateDataSource method, look at the incomming request (assuming you're using ASP.NET you can access this through the static HttpContext) and return a new instance of the ObjectContext derived class which connects to the right database.

    #2 - You should be able to find some help in these blogs: http://blogs.msdn.com/b/astoriateam/archive/tags/authentication/

    #3 - In #2 you decide on per-request basis if it needs to be authenticated or not. So that shoult be pretty straightforward.

    Thanks,


    Vitek Karas [MSFT]

    Thanks Vitek
    • Marked as answer by Rosy Madhuri Friday, August 26, 2011 8:32 AM
    Friday, August 26, 2011 6:48 AM

All replies

  • #1 - in your DataService<T> derived class override the CreateDataSource method, look at the incomming request (assuming you're using ASP.NET you can access this through the static HttpContext) and return a new instance of the ObjectContext derived class which connects to the right database.

    #2 - You should be able to find some help in these blogs: http://blogs.msdn.com/b/astoriateam/archive/tags/authentication/

    #3 - In #2 you decide on per-request basis if it needs to be authenticated or not. So that shoult be pretty straightforward.

    Thanks,


    Vitek Karas [MSFT]
    • Marked as answer by Rosy Madhuri Friday, August 26, 2011 6:47 AM
    Sunday, August 21, 2011 2:42 PM
    Moderator
  • #1 - in your DataService<T> derived class override the CreateDataSource method, look at the incomming request (assuming you're using ASP.NET you can access this through the static HttpContext) and return a new instance of the ObjectContext derived class which connects to the right database.

    #2 - You should be able to find some help in these blogs: http://blogs.msdn.com/b/astoriateam/archive/tags/authentication/

    #3 - In #2 you decide on per-request basis if it needs to be authenticated or not. So that shoult be pretty straightforward.

    Thanks,


    Vitek Karas [MSFT]

    Thanks Vitek
    • Marked as answer by Rosy Madhuri Friday, August 26, 2011 8:32 AM
    Friday, August 26, 2011 6:48 AM