Is [Flags]Enumeration the propper solution

Last post 06-03-2009 8:21 PM by trondaron. 5 replies.

Sort Posts:

  • Is [Flags]Enumeration the propper solution

    05-19-2009, 2:10 PM
    • Member
      140 point Member
    • trondaron
    • Member since 05-19-2009, 12:56 PM
    • Costa Rica
    • Posts 39

    I am planning on have an unknown number of permissions. My intial estimate is roughly 20-30. These permissions will cover a variety of things related to whether a user can create/edit/view various items reports/limits/data etc.

     The questions is what is the best practice for this scenerio?

    My thoughts below feel free to ignore and just make suggestions:

    - A Permissions class that controls the whole mess and can be used in subsequent User Derivative classes. Then checked using something like User.Permissions.ReportsView

    - A single [Flag] type enumeration with all the permissions that can be stored in a hex field in a database

    - A system of [Flag] type enumerations; so that a user will be flagged for report permissions and then have those permissions defined using a second enumeration. These will be stored in set of database fields mirroring the same structure.

  • Re: Is [Flags]Enumeration the propper solution

    05-20-2009, 2:41 PM
    • Member
      140 point Member
    • trondaron
    • Member since 05-19-2009, 12:56 PM
    • Costa Rica
    • Posts 39

     Another option I've been considering:

    Database Tables: permissionLookup, users, userPermission

    The userPermission table holds the permissions using two foreign keys. This database structure allows for an unrestricted number of easily retrievable permissions.

     Code-wise;  To have a class that exposes permissions and will check them when supplied a user and permission (overloaded to take just IDs or full on user instances etc.).

     

    This method still feels heavy to me, it seems like this issue should have an existing design solution, but I'm having very little luck discovering it via research. Any help or thoughts are appreciated.

  • Re: Is [Flags]Enumeration the propper solution

    05-26-2009, 5:57 PM
    • Member
      140 point Member
    • trondaron
    • Member since 05-19-2009, 12:56 PM
    • Costa Rica
    • Posts 39

     I'm sure self bumping isn't the most respected act, but I really would like some one else's thoughts on this.

    Let me know if I haven't explained my situation clearly.

  • Re: Is [Flags]Enumeration the propper solution

    05-26-2009, 6:09 PM
    • Member
      202 point Member
    • mohit_dj
    • Member since 01-26-2009, 12:51 PM
    • Leeds, UK
    • Posts 46
    I just wonder whether permissions needs to be given to individual user or users could be grouped? If later is the situation then Roles Management might help? Or your second approach seems to be good... that way you can add any number of permissions for the users and with extra field called IsActive you can maintain the status of that permission (I mean whether that is still valid, it's better than deleting the record from the database).
    Cheers,
    Mohit J

    Mark as Answer if this helps you!
  • Re: Is [Flags]Enumeration the propper solution

    05-26-2009, 6:12 PM
    Answer
    • Member
      202 point Member
    • mohit_dj
    • Member since 01-26-2009, 12:51 PM
    • Leeds, UK
    • Posts 46
    Using typed datasets could ease your work of writing classes to represent tables in database and could also help you maintain separate DAL in your app...
    Cheers,
    Mohit J

    Mark as Answer if this helps you!
  • Re: Is [Flags]Enumeration the propper solution

    06-03-2009, 8:21 PM
    • Member
      140 point Member
    • trondaron
    • Member since 05-19-2009, 12:56 PM
    • Costa Rica
    • Posts 39

    I was not aware of Typed Datasets, they look promising for this purpose.

    I believe I've decided to create a class (perhaps a Typed Dataset) that will provide user permissions from the database. I'm on the fence as far as Role Management goes, the initial talk of who has what permissions doesn't reflect any specific permission sets being repeated.

     

    Thanks for the response Mohit!

Page 1 of 1 (6 items)