I have an application that needs to hit the ActiveDirectory to get user permission/roles on startup of the app, and persist throughout.
I don't want to hit AD on every form to recheck the user's permissions, so I'd like the user's role and possibly other data on the logged-in user to be globally available on any form within the application, so I can properly hide functionality, buttons, etc. where necessary.
Something like:
if (UserProperties.Role == Roles.Admin)
{
btnDelete.Visible = false;
}
What are the best practices for storing static user data in a windows app? Solutions such as a Singleton, or global variables may work, but I was trying to avoid these.
Is a User object that gets passed around to each form's contructor just as bad?