My client has a database (TS) for a project I'm working on. This database has a Stored Procedure called Logon. Within that SPROC is a call to a second database (RRA), which is their custom authentication DB that is used across all of their projects. The result of this call is the Role(s) a user is assigned to (assuming authentication passes, of course).
I'm attempting to do this via WCF RIA Services. When I create my ADO.NET Entity Data Model, I'm not sure which Data connection I should use - the one that connects to TS, or the one that connects to RRA. I'm going on the assumption that its TS.
Beyond that assumption, I'm still stuck. I know I can add an Import Function to that Logon SPROC. Where do I go from here?
I agree that you should target the TS database.
Here's a walkthrough of using stored procs.
http://www.robbagby.com/entity-framework/entity-framework-modeling-select-stored-procedures/
And here's an answer to how you can create a custom authentication using RIA Services.
RIA Services: How can I create custom authentication?
Related
I am working on an application where I need to setup identity server 4. I have an api as resource. and a web forms application as client.I have few roles like teachers, students, parents in my database. How can I use this custom database and perform authentication and authorization without using identity?
Please suggest.
From your other question here I get a better idea of what you want.
I think one solution for what you want would be to setup identityserver4 in a seperate project with its own seperate database. I noticed the tag identityserver3, but I think it is quite safe to go for identityserver4. It shouldn't make a difference for the client/user since they are conceptually compatible.
1) Give your application a client/secret (which you configure in identityserver) in order to identify your application and grant access to the resource api. Here is some information: http://docs.identityserver.io/en/dev/quickstarts/1_client_credentials.html
You'll only need to configure one client to protect your resource from the outside. The only way to access the resource api is through your application, since your application is making the actual calls. This is also the drawback, you cannot expose the token to the outside world.
Since your client isn't the actual user, you'll need to identify the user. You can use any mechanism based on your current model as you like. A simple user/pass (with or without asp.net identity) could be enough to determine the roles. But please keep in mind that your application has full access to the resource api.
2) However, since identityserver is available, why not use it? Why don't you want to use the identitymodel? I think you should consider to seperate the identity information and your datamodel. Your datamodel shouldn't be aware of the security. And the security has nothing to do with your datamodel.
When you create a seperate database for identityserver you have one place to configure the identity users. All you need is a reference (sub) to the user in the datamodel. http://docs.identityserver.io/en/dev/quickstarts/2_resource_owner_passwords.html
Add claims or roles and everything is in place and you'll see there is no need to keep identity data in your custom database. The structure of your custom database stays intact, including the user table but without the identity data.
I think this is a safer solution and considering the good documentation and sample projects it may even turn out to be a quicker solution.
I have an azure mobile services and all the tables inherit from EntityData (to enable offline sync), which means they have system columns created automatically such as:
CreatedAt UpdatedAt Deleted
If I try to update or insert to this tables, can I still do it with just entity framework or plain SQL, or do I now have to do it all through the mobile service.
I'm somehow confused with the whole purpose of the EntityData and what it means. Cause I want an application that would be able to use offline sync, but still access data from a webpage.
The Azure Mobile Services SDK makes it very easy to perform CRUD operations on your tables but that doesn't mean you can't still access the tables using entity framework or just plain SQL.
Remember the Azure Mobile Services SDK supports both offline and online operations, but if you need to use the same Azure mobile services database with another client application, then you would have to get the SQL database connection string and connection information from the Azure Mobile services dashboard. With both information, your client app can use Entity framework or plain SQL queries to interact with the tables.
I'd like to create a Azure Mobile Service (.NET) that reads / writes from an existing database that is being used by an MVC 5 app. I've been trying, without luck, for the better part of a day to make this happen through the few examples that exist on the internet.
I've just now come across this SO post where Carlos Figueira says that a mobile service creates a new schema with the same name as the service name and all access is done via that schema and the user that has permission to that schema. If this is the case, how will I be able to have my mobile service connect to an existing table, if it always creates new tables in the new schema?
Also, I'm getting the impression that mobile services using .NET is much happier if I don't attempt to connect to an existing DB. Is this the case?
Azure Mobile Services will only work with tables in the new schema (with the service name). In order to work with an existing database, you need to transfer the tables to this schema, and then you will need to rename all your PK columns to "id" (lowercase). Once you have done that, the tables still don't show up in the Data tab in the management interface, but you can 'add' them and then it will connect and you can work with your existing data.
See this link for full walkthrough: http://www.strathweb.com/2012/12/using-existing-database-with-azure-mobile-services/
we have a live azure mobile service using dot net backend. The apps using it are out & people are using them.
If we add a few more nullable fields to one of the classes in azure service, will the existing client apps keep working, without an update?
Or do all users must require to update the app before continue using the services?
Existing clients will keep working. On the client side, when it receives objects with properties which it doesn't understand the serializer will just ignore those. On the server side, when it receives the data from old clients, any properties which you have added to the class will have its default value (e.g., if you have a new integer property, it will have the value 0, and for string properties the value null). As long as the logic in the service controller can handle those default values, then your application will be fine.
If you are using entity framework.Base on my test, it's OK.You don't have to change your client-side data model.
P.S. If you just change your entity class.It may clear your database.Be careful with that.
If you want Entity Framework to alter your database
automatically whenever you change your model schema, please use data migrations.
For more information refer to the documentation:
http://msdn.microsoft.com/en-us/data/jj591621.aspx
I'm looking into how to integrate [Authorize] within my MVC 2 application... I'm reading articles about it and I've run the aspnet_regsql tool. I see that my database now containes a bunch of new tables and a whole hell of a lot of SPROCs.
Why is all of this necessary? I thought that I would be able to check login credentials in a table that I've already created for Party ... can't I just call a SPROC that checks the login credentials and then logs the user in? Why all of these new tables and SPROCs?
Because it is the way how it is works. If you using ASP.NET Membership by default you need to have database aspnetdb with lots of tables and stored procs. If you want you may customize that. In order to do that you need to implement custom membership provider.
The simple example how to do that you may find here http://msdn.microsoft.com/en-us/library/aa479048.aspx and here http://www.asp.net/general/videos/how-do-i-create-a-custom-membership-provider also source code available.
It sounds like you want to create a custom membership provider. For logging in I think you really only need to override the ValidateUser method:
http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx
For roles you may be able to get by with overriding only the IsUserInRole method:
http://msdn.microsoft.com/en-us/library/8fw7xh74.aspx