Activity-based Authorization

A very good post: Don’t Do Role-Based Authorization Checks; Do Activity-Based Checks

Tables

User:UserID | Name
1 | Jamie
2 | Tom

Role:RoleID | Name
1 | Admin
2 | General
3 | Audit
4 | Manager

Activity:ActivityID | Name
1 | Read A
2 | Create A
3 | Delete A
4 | Update A
5 | Read User
6 | Delete User

UserToRole:UserID | RoleID
1 | 3
2 | 1

RoleToActivity: RoleID | ActivityID
1 | 1
1 | 2
1 | 3
1 | 4
1 | 5
1 | 6
2 | 1
4 | 1
4 | 5

Code

Check users activity rather than role. Create similar APIs like Ruby CanCanCan.

void Initial() // load activity list into a list
bool Can(Activity name) // verify if current user can do this activity
bool Cannot(Activity name) // !can

Application Verifier

Cool app…help me find a random crash in Thread Pool caused by invalid handle when calling

::UnregisterWait
::RegisterWaitForSingleObject
::WaitForSingleObject

<Microsoft Application Verifier is a runtime verification tool for unmanaged code. It assists developers in quickly finding subtle programming errors that can be extremely difficult to identify with normal application testing. Application Verifier makes it easier to create reliable applications by monitoring an application’s interaction with the Microsoft Windows operating system, profiling its use of kernel objects, the registry, the file system, and Microsoft Win32 APIs (heap, handles, locks, and more).>

VC++ Directories vs. Additional Include Directories

Project->Properties->Configuration Properties->VC++ Directories:
– the setting in Options is used for all VS.
– Also can be found in VS->Tools->Options->Projects and Solutions->VC++ Directories which is added by default to all projects.
– The Include Directories corresponds to the environment variable INCLUDE.

C/C++->General->Additional Include Directories:
– the setting in Properties is used only for this project

Property Manager & Property Pages in VS2010/2012

VS->Menu->View->Property Manager/Property Pages

property sheet at the bottom is applied first.

Property Pages->VC++ Directories
– “Executable directories” → PATH
– “Include directories” → INCLUDE
– “Reference directories” → LIBPATH (for #using)
– “Library directories” → LIB