|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Runtime Security PermissionsI've got a program running on a Network share. It works without any problems when I add the \\server\* with Full Trust in the .Net Configuration MMC. I also export this security set as an MSI to be installed for users who wish to run the program. The question is, is that sometimes a user will simply go to the share and try running the program sometimes (start -> run -> \\server\share\Program.Net.Exe). This will cause the application to fail, and an unfriendly message to be displayed. I would like to do a test to make sure the program has the correct permissions to run, but it doesn't even reach the On_Load event. How would I go about testing to make sure the program is able to run so if they don't have the security permissions to run a program from the share, I'd like to give them a nice friendly "Don't Panic!" message :) Any examples in VB/C# work for me, thanks in advance! -Jesse Albert Hi Jesse, here's something in VB that works just fine.
HTH, Marius. <snip> Imports System.Security Public Class MainApp Public Shared Sub Main() If Panic() Then MessageBox.Show("Don't Panic") Else Application.Run(New MainForm) End If End Sub Private Shared Function Panic() As Boolean Try Dim trust As New PermissionSet(Permissions.PermissionState.Unrestricted) trust.Demand() Return False Catch ex As SecurityException MessageBox.Show("Panic! No permissions to run app") Return True Catch ex As Exception MessageBox.Show("Panic! Trouble running app") Return True End Try End Function End Class </snip> <Jess.Alb***@gmail.com> wrote in message Show quote news:1149254968.935756.206040@y43g2000cwc.googlegroups.com... > Hey All, > I've got a program running on a Network share. It works without any > problems when I add the \\server\* with Full Trust in the .Net > Configuration MMC. I also export this security set as an MSI to be > installed for users who wish to run the program. > > The question is, is that sometimes a user will simply go to the share > and try running the program sometimes (start -> run -> > \\server\share\Program.Net.Exe). This will cause the application to > fail, and an unfriendly message to be displayed. > > I would like to do a test to make sure the program has the correct > permissions to run, but it doesn't even reach the On_Load event. How > would I go about testing to make sure the program is able to run so if > they don't have the security permissions to run a program from the > share, I'd like to give them a nice friendly "Don't Panic!" message :) > > Any examples in VB/C# work for me, thanks in advance! > > -Jesse Albert > Perfect, thanks a ton!!!
-Jesse Marius Groenendijk (Hotmail) wrote: Show quote > Hi Jesse, here's something in VB that works just fine. > HTH, > Marius. > > <snip> > Imports System.Security > > Public Class MainApp > > Public Shared Sub Main() > If Panic() Then > MessageBox.Show("Don't Panic") > Else > Application.Run(New MainForm) > End If > End Sub > > Private Shared Function Panic() As Boolean > Try > Dim trust As New > PermissionSet(Permissions.PermissionState.Unrestricted) > trust.Demand() > Return False > Catch ex As SecurityException > MessageBox.Show("Panic! No permissions to run app") > Return True > Catch ex As Exception > MessageBox.Show("Panic! Trouble running app") > Return True > End Try > End Function > End Class > </snip> > > <Jess.Alb***@gmail.com> wrote in message > news:1149254968.935756.206040@y43g2000cwc.googlegroups.com... > > Hey All, > > I've got a program running on a Network share. It works without any > > problems when I add the \\server\* with Full Trust in the .Net > > Configuration MMC. I also export this security set as an MSI to be > > installed for users who wish to run the program. > > > > The question is, is that sometimes a user will simply go to the share > > and try running the program sometimes (start -> run -> > > \\server\share\Program.Net.Exe). This will cause the application to > > fail, and an unfriendly message to be displayed. > > > > I would like to do a test to make sure the program has the correct > > permissions to run, but it doesn't even reach the On_Load event. How > > would I go about testing to make sure the program is able to run so if > > they don't have the security permissions to run a program from the > > share, I'd like to give them a nice friendly "Don't Panic!" message :) > > > > Any examples in VB/C# work for me, thanks in advance! > > > > -Jesse Albert > > |
|||||||||||||||||||||||