Solved

File Permissions and CAS

Posted on 2009-05-19
4
200 Views
Last Modified: 2013-12-17
Hi,
I need to deploy an application (.exe) on the server, and be able to run it from other computers within the network.  I have built a simple app as a tester which creates a textwriter and saves a simple txt file.  I keep getting the error: "Request for the permission of type 'System.Security.Permissions.FileIOPermission....failed'.  This will occur if I change my code to access a different reference (other than IO), also.  I have done MANY things to try to rectify this, to no avail.  One thing being: I have modified the policy for my local intranet zone to FullTrust (using the .NET 2.0 configuration utility) And this STILL does not work!  I thought that  would be a no-brainer!  Maybe if you guys can help me with this task , I can figure out how to modify the permissions from there.  Maybe I am doing it all wrong?  Here is what I am doing:
Deploy setup file on server from msi
run program on server-works!
switch to networked desktop computer...
run configuration utility and change "machine" local intranet zone to FullTrust
(I also tried creating a new group, setting a URL, and setting it to fullTrust...didn't work)
Try running program from \\myservername\Program Files\myProgram\myProgram.exe
Get the above error!

I have sharing and security wide-open right now...full control from EVERYONE.
pertinent part of the code:
 
using System.IO;
 
private void mymethod()
{
    TextWriter tw = new StreamWriter(@"C:\Program Files\myProgram\logs\log.txt");
            tw.WriteLine(txtBxLog.Text.ToString());
            tw.Close();
}

Open in new window

0
Comment
Question by:accits
  • 2
  • 2
4 Comments
 
LVL 41

Expert Comment

by:graye
ID: 24441467
Yes, this is an example of the .Net Framework's own Code Access Security (CAS) settings on each of the client PCs.
Take a look at the following article that explains it all, and show how to deploy a CAS policy update:  http://www.emmet-gray.com/Articles/CodeAccessSecurity.htm
0
 

Author Comment

by:accits
ID: 24443020
I have looked over the document and am still stumped, as I have already increased my local intranet zone to FullTrust.  I will go over it in more detail and try to troubleshoot.

Is there anything I need to do on the server (windows 2003)?   I am developing the application, then deploying the application on the server, then going back to the development machine to try accessing the application.  It is on the developemt machine that I have configured FullTrust.  I have, for the time being, disabled the firewalls on both machines, and configured sharing and security permissions for the "EVERYONE" users group to "full control".
0
 
LVL 41

Accepted Solution

by:
graye earned 500 total points
ID: 24443283
No, there's nothing to do on the server...   just make sure you're modifying the CAS settings on each client (using one of the techniques described in the article).  
  • Make absolutely sure that you're using the version 2.0 control panel applet (and not the v1.1 one)
  • Use Windows Explorer to verify that the server is indeed in the LocalIntranet zone on the client PCs
0
 

Author Closing Comment

by:accits
ID: 31583313
thanks graye.  The document you sent helped me to troubleshoot.  It seems as if the server location was added as a "Trusted Site" at some time, and the "Trusted Site" policy was not full trust.  Therefore, even though I went through all of the steps for strong-naming and adding my application to other zones, it was still looking at the wrong policy.  A few corrections, and now it works!
Thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Many people tend to confuse the function of a virus with the one of adware, this misunderstanding of the basic of what each software is and how it operates causes users and organizations to take the wrong security measures that would protect them ag…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question