Solved

File Permissions and CAS

Posted on 2009-05-19
4
199 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

In today's information driven age, entrepreneurs have so many great tools and options at their disposal to help turn good ideas into a thriving business. With cloud-based online services, such as Amazon's Web Services (AWS) or Microsoft's Azure, bus…
Recently, I read that Microsoft has analysed statistics for their security intelligence report. It revealed: still, the clear majority of windows users do their daily work as administrator. An administrative account is a burden, security-wise. My ar…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 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