By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,830 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

Login Form w/ Schedule, creating a form that displays a dynamic name

P: 2
Hi all,

I have created a login form where both a manager and employee can login by entering their usernames and passwords. Once the employee logs in, I would like the next form (the schedule) to appear with the employees name at the top. I want the name at the top of the schedule form to be dynamic and change every time a new user logs in.

Thanks!
Nov 15 '17 #1
Share this Question
Share on Google+
4 Replies


Frinavale
Expert Mod 5K+
P: 9,731
Sounds nice,

Have you created a custom Principal for this purpose? (Here's a link to documentation for the Principal Class)

You should be able to access the name through the Principal and display it on the screen.
Nov 15 '17 #2

P: 2
Thanks for the reply. All I have is a login class that has usernames and passwords for various employees. I just want the name of the person who logs in to be input into the top of the schedule form that pops up once they login. How would I use a Principal class for this?
Nov 15 '17 #3

100+
P: 299
This may be a silly answer, but couldn't this be accomplished with a Form_Load event OR by passing the name from your original Form? I'm not sure if it's the Form's title(text) that you're wanting to change or if it's some sort of label on the second form, but this should be fairly simple. Please note that Environment.GetEnvironmentVariable() can be substituted with a value from a textbox or inputbox. For example:

Form Open Example:
Expand|Select|Wrap|Line Numbers
  1.  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Form2.Text = "Form2 - " & Environment.GetEnvironmentVariable("username")
  3.         Form2.ShowDialog()
  4.     End Sub
Form Load Event:
Expand|Select|Wrap|Line Numbers
  1.     Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         Me.Text = "Form2 - " & Environment.GetEnvironmentVariable("username")
  3.     End Sub
Nov 16 '17 #4

Frinavale
Expert Mod 5K+
P: 9,731
Luk3r's suggestion sounds like it might work for your very simple case.

I implement custom Identity and Principal classes (they implement the IIDentity and IPrincipal interfaces) and use them to authenticate the user (checking the user name and password on logging in) and to be able to enforce customized permissions based on the Roles defined in the Principal object.

It may be overly complicated for your situation though.

When I was in college, my first "login" project was simply to authenticate a user by checking user name and password against a database or flat text file (THIS WAS NOT SECURE). Once the user "logged in" I just stored their user name in Session (for web applications) and went from there.

Now I do things much more securely and the custom principals make it really easy to check if the user is in roles when accessing restricted areas of my applications (whether that be web applications or desktop applications).

While your needs may be satisfied by Luk3r's suggestion, it never hurts to be aware of Principals and Identities

-Frinny
Nov 16 '17 #5

Post your reply

Sign in to post your reply or Sign up for a free account.