Setting FullTrust with CasPol

Generally if you need to modify the Code Access Security Policy for the target machine of your app, you are doing something you shouldn't be with your code.  Most likely there is a different way to achieve the same ends without opening up your user's machine to possible security risks.  Our application is no exception.  However, until we can fully refactor the problem code, we will need to continue to run with FullTrust for the Local Intranet and Trusted Sites.  One thing that has bitten us in the past is the differences between Local Intranet and Trusted Sites.  The default security policies for Local Intranet and Trusted Sites for 1.1 are Medium Trust and Low Trust respectively.  Our app can be configured to run in "client/server" mode and this currently requires that the client enable FullTrust to their Local Intranet to access the server.  Fine, dandy, run CasPol on the client, be done.  However, if for whatever reason the client user has added the server to their list of Trusted Sites (via Internet Explorer Security settings) the Trusted Sites policy trounces the Local Intranet policy.  So, long story short, we need to the policy for both Local Intranet and Trusted Sites.

I did some googling to determine the way to make this happen but ultimately I could not find a consistent way to adjust the security policies using the command line CasPol.exe.  Some trial and error finally yielded the following syntax:

CasPol.exe -q -m -ag All_Code -zone Intranet FullTrust

CasPol.exe -q -m -ag All_Code -zone Trusted FullTrust

This will quietly (without confirmation prompts) set FullTrust at the machine level for both the Local Intranet and Trusted Sites zones.  Add these calls during the installation of your client application, and you should be in business.

posted @ Wednesday, August 15, 2007 8:08 AM


Print

Comments on this entry:

# re: Setting FullTrust with CasPol

Left by Jeff Brown at 8/15/2007 9:20 PM
Gravatar

Boy that's scary. Sure you can't constrain it any further to just your code, or specific trusted Uris?

# re: Setting FullTrust with CasPol

Left by TSalm at 3/25/2008 5:25 AM

There's of course a syntax to open only on a specific URI :
CasPol.exe -machine -addgroup 1 -url "file:\\Server\Folder" FullTrust -name ExprimFolder -pp on

# re: Setting FullTrust with CasPol

Left by TSalm at 3/25/2008 5:25 AM

There's of course a syntax to open only on a specific URI :
CasPol.exe -machine -addgroup 1 -url "file:\\Server\Folder" FullTrust -name ExprimFolder -pp on

# re: Setting FullTrust with CasPol

Left by nipun at 7/29/2008 4:40 AM
Gravatar

I have a problem, I have an exe built in .net 2.0 which would be downlaoded from an url, if i run my exe directly from the browser i.e run it using the run button in the dialog box provided i get an exception System.Security.SecurityException.

# re: Setting FullTrust with CasPol

Left by viljem at 10/7/2008 1:29 PM
Gravatar

I had same problem. This has solved it. Thanks!

Your comment:



 (will not be displayed)


 
 
 
Please add 7 and 5 and type the answer here:
 

Live Comment Preview:

 
«October»
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678