I am building an application with a user login and various functions.
I want to use a flexible structure to load the current Users privileges into.
eg the Functions could be:
Product Maintenance
Customer Maintenance
Supplier Maintenance
Accts Receivable, etc

For each Function the User can be assigned privileges:
Read Access
List Access
Update
Add
Delete
Print

When the user logs in, I currently retrieving his functions and privileges from the database
and I would like to iterate each row and load them in a structure that can be used while navigating the application.

Does anyone have any thoughts on this? I first thought an array but I would need to iterate it to find the row with the name of the function.
A structure would be better but I would need to declare each function at startup before reading the database.

Any thoughts?

Why don't you create a User Class? something like this:

public class User

public property ForeName as string
public property LastName as string
public property AssignedFunctions as List(of string)

sub New()
AssignedFunctions = new List(of string)
end sub

end class

Then on getting the DB stuff you simply do

dim newUser as new User with {.ForeName="Susi", .LastName="Sorglos"}
newUser.AssignedFunctions.add("Read")
'or if u get the assigned functions from the DB separeted by comma
newUser.AssignedFunctions.addrange(dbValue)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.