![]() |
User Currently Logged in....
Ok, yet another dumb question. I know i can pull what user is logged in by using a WMI pull. But how would I go about it with a System.Class.method? I've been searching the forums but can't find anything that helps.
I am trying to build an app that makes certian buttons active based on who's logged in. Any help is appreciated. TIA |
:
Module Module1Or even easier... :
Console.WriteLine("Current User: " + Environment.UserName) |
Well damn, that sounds good to me. I can always count on you IR. :D
|
Glad I could help...
|
Quote:
Thank you a thousand times over. |
Cool man, glad its working for you. Just a suggestion... have a list of acceptable users in a config file with the portions of the program they have access to... then enable/disable buttons based off of those entries... that way it would be more flexible. But, may not matter much as I'm not entirely sure what you are up to our how widespread its use will be.
|
Quote:
:
Bassically, we have alot of usernames that start w/ the same thing like. CONT_ or BUT_ ect..... and i am trying to make a catch all. I tried :
if usrName = "%but_%" And of course, no love. I am sure it's something simple and my lack of experience is to blame. Thank you in advance. |
Try substrings...
:
If usrName.Substring(0, 4).ToUpper = "BUT_" ThenSubstring(STARTING POSITION, NUM OF CHARS TO RETURN) All strings start at 0, so for the %CON_% instance, you will need to determine where in the string CON_ starts... For instance: USCON_MYID :
usrName.Substring(2, 4).ToUpper = "CON_"If the position of the keyword is not always constant in the username string, you could take the high road and use the .IndexOf string property to determine if the keyword is in that string... anywhere. Another thing is... are you sure you want to disable the view property or just disable the ability to click the button? button.Visible = False vs button.Enabled = False |
IR, i like the substring idea. I'll put that in. The 3 letter connotations apprear the same in all the names so it should work quite well. As for visibility, wer are doing this to cut down on technician time out in the area. The users are out in the area are used to doing MFG type line work, so they hardly know anything about computers, let alone what a start menue is. That's fine as long as they do the line work perfect most the time.
I am going to stack the buttons i have so it only appears as if there is one to any one user. Then i am going to control the visibility so that only the button they need for that area appears. Otherwise, they will either get confused or play around to much and muck up the configs for that area. Once I am done I'll post up pic's of the final form so it will make more sense. Right now I have alot of unneeded output feilds on the form to verify all the gears are turning in the direction. :D This is turning out to be alot of fun for me. Thank you again. |
Here's what the code ends up looking like when using the substring pull on the variable.
:
It works great. I do apreciate it. Now I am moving on to the copy / progress screen part of it. I can copy the files, but i've been tumbling through and a progress that's not completely foreign to build. |
| All times are GMT -5. The time now is 10:25 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC