|
Hi, basically i was wondering is there is any way i can incorporate that fact that a user has already logged on to the computer into restricting access to some forms. All the computers that operators use are controlled with standard username and password. Management computers have their own unique log on and they would have full functionality of the app. So if they log on with standard username and password and try click event from mdi form they would be restricted from opening some forms. Private Sub WORKSCHEDULEToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WORKSCHEDULEToolStripMenuItem.Click Dim NewMDIChild As New WORKSCHEDULEENTRY NewMDIChild.MdiParent = Me NewMDIChild.WindowState = FormWindowState.Maximized NewMDIChild.Show() 'some where in here if user is such and such show message no access granted' End Sub Thanks Intozz |
| intozz Tuesday, June 09, 2009 12:57 AM |
You could probably make WindowsIdentity.Groups work to check if the user belongs to the "right" kind of group of users. Work with your domain controller administrator to sort this out. Hans Passant.- Marked As Answer bynobugzMVP, ModeratorWednesday, June 10, 2009 7:36 AM
-
|
| nobugz Tuesday, June 09, 2009 1:06 AM |
You could probably make WindowsIdentity.Groups work to check if the user belongs to the "right" kind of group of users. Work with your domain controller administrator to sort this out. Hans Passant.- Marked As Answer bynobugzMVP, ModeratorWednesday, June 10, 2009 7:36 AM
-
|
| nobugz Tuesday, June 09, 2009 1:06 AM |
Then something like this or this totally out to lunch Private Sub WORKSCHEDULEToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WORKSCHEDULEToolStripMenuItem.Click Dim NewMDIChild As New WORKSCHEDULEENTRY NewMDIChild.MdiParent = Me NewMDIChild.WindowState = FormWindowState.Maximized NewMDIChild.Show() 'some where in here if user is such and such show message no access granted' Dim MyIdentity As WindowsIdentity = WindowsIdentity.GetCurrent() if myidentity = "usernamehere" then newmdichild.show = false End Sub
|
| intozz Tuesday, June 09, 2009 2:10 AM |
Hmya, going by specific user names is pretty high maintenance.
Hans Passant. |
| nobugz Tuesday, June 09, 2009 2:28 AM |
ok missing my point everybody who will have restricted access uses the same generic username and password for all the computers . they already only have a limited access to specific programs they use to run the machines. but its the code i need to get down to make it work
|
| intozz Tuesday, June 09, 2009 3:33 AM |
Okay, well, you should have no trouble making WindowsIdentity work for you.
Hans Passant. |
| nobugz Tuesday, June 09, 2009 3:43 AM |
In case if you are using the above code, i would recommend to soft code the "username" instead of hard coding. |
| ChronusDOTNet Tuesday, June 09, 2009 4:13 AM |
so im not sure what you mean there softcode vs hardcode? and in reply to nobugz i do have trouble making it work ive been learning on the fly im now about 6 months into writing and learning this vb app. while i do have the core of my program for all the things i need working with database etc. im trying to tidy up all these loose ends
|
| intozz Tuesday, June 09, 2009 4:18 AM |
I have no idea what "trouble making it work" means. Perhaps you ought to code it like this: Dim MyIdentity As WindowsIdentity = WindowsIdentity.GetCurrent() If MyIdentity.Name = "MyDC\DaBoss" Then Dim NewMDIChild As New WORKSCHEDULEENTRY NewMDIChild.MdiParent = Me NewMDIChild.WindowState = FormWindowState.Maximized NewMDIChild.Show() End If
Hans Passant. |
| nobugz Tuesday, June 09, 2009 4:41 AM |
like i say i play around alot with code hash things together trying to get things to work, im like a bride i guess! something borrowed something blue something new. the slash in "mydc\daboss" is that "username\password" ? and thanks for your responses i do appreciate it. ive learned alot in 6 months but probably only amounts to 5% of what there is to learn and then some
|
| intozz Tuesday, June 09, 2009 5:14 AM |
No, it's domain\username. Use the debugger.
Hans Passant. |
| nobugz Tuesday, June 09, 2009 5:36 AM |
So i tried it out. I used this to get my current username:- AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal) Dim myID As WindowsIdentity = WindowsIdentity.GetCurrent() Msgbox("The Current User is : " & myID.Name) which worked. i got the domain\username but i tried out the code and nothing happens. it seems that it returns myidentity as nothing MyIdentity Nothing System.Security.Principal.WindowsIdentity any other help anybody?
|
| intozz Wednesday, June 10, 2009 1:02 AM |
ok got it its case sensitive, thanks for the help
- Unmarked As Answer bynobugzMVP, ModeratorWednesday, June 10, 2009 7:35 AM
- Marked As Answer byintozz Wednesday, June 10, 2009 1:57 AM
-
|
| intozz Wednesday, June 10, 2009 1:40 AM |