Security in code problem

martin_vista

Active member
Joined
Mar 26, 2007
Messages
29
Programming Experience
3-5
The class clsCipher contains a method that reads an encrypted password from an ini files and decrypts it. The encryption and decryption work fine and have nothing to do with this question.

The problem is reading the .ini file. When I try this local, it is not a problem, but when I run the application from a share, it gives a security error. (my errors are in dutch, they are about System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral)
I know I should be able to solve this by setting policies, but the application I am building has to run in several different environments, I will not be allowed to change policies everywhere, so I'll need to find a solution in the code.

This is the code:

Dim myCipher As New rCipher.clsCipher 'the class is working fine
Dim filePerm As FileIOPermission
filePerm = New FileIOPermission(FileIOPermissionAccess.Read, Application.ExecutablePath)
txtPlain.Text = myCipher.GetPasswordFromIni(txtKey.Text, Application.ExecutablePath)


First I thought the Application.ExecutablePath was the problem, but when I point directly to the .ini file I get the same problem. I also found out that the following code gives exactly the same error:

Dim filePerm As FileIOPermission
filePerm = New FileIOPermission(FileIOPermissionAccess.Read, Application.ExecutablePath)
msgbox(Application,ExecutablePath)


All ntfs permissions are set correctly.

Does anyone know how to solve this?
 
The problem is running the .Net app from a network drive, .Net Framework does not allow it unless you configure the security setting from Framework Configuration utility of Control Panel or CasPol.exe command-line utility.
 
But...

But what should I do if I do not have access to the control panel?
The application will run in three different countries, on "normal" networks and on Citrix. The company that hosts the Citrix Server won't let me!
I am sure there must be a way?
 
The company that hosts the Citrix Server won't let me!
Then you're not allowed to run from their network shares. .Net Framework default security allow to run from local drive but not from network drive, which by definition is not a trusted environment.
 
Hmmm....

Thanks, it's new for me, I have always developed in .NET 1.0, I've never encountered the issue before.

But I still don't get it.
So if you build a .NET 2 application, you always have to alter the environment?
Is there an automated tool for this? Can I do (or ask the administrator) this using a group policies? Does anyone know which one?
 
Mentioned CasPol.exe command-line utility does this.
 
Back
Top