Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way to store the details of logged on user

Status
Not open for further replies.

sillysod

Technical User
Jan 6, 2004
300
GB
Hi there

I have added a logon form to my project

The user enters there username/ password and enters the system

Now against the username i store details of the access rights for that user in a series of yes/no fields in access

So when the user logs on i want all these yes/no fields globally availiable so that when certain forms are opened they can check to see whether or not the user is allowed to open them.

What would be the best way to store these fields ? Since VB.Net doesnt support global variables
 
hi,

you can decide to create a user class that receives all the "rights" and stores them in boolean fields on log on. Those fields will be shared so that you can access their values very easily.

the User class:

Code:
public class User

public shared AccesToForm1 as boolean
public shared AccesToForm2 as boolean

public shared sub loadRights()

'get the rights and store them in the boolean fields

end sub

end class



Then you can read this like this:

Code:
'where you need to decide if the loggedin user can access form1

if user.AccesToForm1 then

'code to open form1

end if

'where you need to decide if the loggedin user can access form2

if user.AccesToForm2 then

'code to open form2

end if


This works fine if you only have one user at a time.

Tell me if that was what you were looking for.
 
Yea thats exactly what i need,

i guess that i will need to pass a reference to the instantiated class around the forms.

Although if i instance the class in my Sub Main() will the variales just be globally availiable anyway?
 
if you use shared members, you don't need to instanciate the class and that makes the values globally availlable.

But this only works when you have only one simultaneous user.

Tell me if it'not the case.
 
I might be being a bit daft here, but how could i ever have more than one simultaneous user? surely if i ran a second instance of the app then everything within that app would also be a separate instance?

I will have a play with the solution offered tomorrow and will report back with the results

thanks for the help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top