0

Waht would be a good way, using either EntityFramework methods or else, to validate that the credentials given have enough rights to do CRUD actions on the database?

Etienne Noël
  • 5,988
  • 6
  • 48
  • 75

2 Answers2

0

Haven't tried it myself but you could try adding DBA_TAB_PRIVS (Oracle) to your context and query against it to see if the user (GRANTEE) has related privilege(s).

For SQL Server privileges, you might refer to this post and work on the idea.

Community
  • 1
  • 1
uTeisT
  • 2,256
  • 14
  • 26
-3

You could use the System.Web.Mvc.AuthorizeAttribute attribute which is used to restrict access by callers to an action method.

Here it is an example that shows you how to create a custom AuthorizeAttribute: https://stackoverflow.com/a/11494091/5914627

https://msdn.microsoft.com/en-us/library/system.web.mvc.authorizeattribute(v=vs.108).aspx

Community
  • 1
  • 1
Felipe Cruz
  • 1,119
  • 10
  • 18
  • 2
    No way related to what OP is asking! – Developer Jan 31 '17 at 14:52
  • 1
    The question asks about an checking that application using Entity Framework has permissions on a database. This answer is about restricting users of an ASP.NET web application. The two scenarios are completely unrelated. – anaximander Jan 31 '17 at 15:29