473,407 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

.NET CGI script has inadequate permissions to receive form data ???

I'm trying to write a CGI script in C#; it receives data from an HTML
form via the POST method, and tries to read the form data using
System.Environment.GetEnvironmentVariable(). Which is where I have a
problem. When I use a 32-bit build of the CGI script, everything works
swimmingly. But when I use a 64-bit build of the CGI script,
GetEnvironmentVariable() throws a System.Security.SecurityException
saying it doesn't have permission to read the environment variable.
(I'm running Windows XP Professional x64 and .NET 2.0 SP1 64 bit, and
my web server is IIS 6.)

There must be something I'm missing, because if not, then it would be
impossible to write 64-bit CGI scripts in C# that use the POST method.
But: does anyone have any theories?

I've tried getting Visual Studio to sign the executable, to no avail.
And oddly, I can set the 32-bit build of the executable to be fully
trusted (using "caspol -af CgiScript.exe) but if I try to do the same
thing with the 64-bit build I get an "ERROR: Unable to load assembly".

My HTML form, CGI source code, and the 64-bit output (including the
exception) are below.

Cheers!

//////////////////////////////////////////////////////////////////////////

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>This will load CgiScript.exe</title>
</head>
<body>

<form action="CgiScript.exe", method="POST" id="MyForm">
<input type="checkbox" value="chkbox1" />Text1
<input type="checkbox" value="chkbox2" />Text2
<input type="submit" name="submit1" value="Submit1" />
<input type="submit" name="submit2" value="Submit2" />
</form>
</body>
</html>

//////////////////////////////////////////////////////////////////////////

namespace CgiScript
{
class Program
{
private static string GetProcessEnvironmentVariable(string
variable)
{
System.Console.WriteLine("About to get env var");
string value00 =
System.Environment.GetEnvironmentVariable(
variable, System.EnvironmentVariableTarget.Process
);
System.Console.WriteLine("Got env var");

if (null == value00) {
ReturnError("Missing value: " + variable);
}

return value00;
}

private static void ReturnError(string err)
{
System.Console.WriteLine();
System.Console.WriteLine();
System.Console.WriteLine(err);
}

public static void Main(string[] args)
{
try {
System.Console.WriteLine("Content-Type: text/plain");
System.Console.WriteLine();
System.Console.WriteLine();

string request_method =
GetProcessEnvironmentVariable("REQUEST_METHOD");
if (null == request_method) {
ReturnError("Missing value REQUEST_METHOD");
return;
}

} catch (System.Exception exc) {
ReturnError(exc.ToString());
}
}
}
}

//////////////////////////////////////////////////////////////////////////

About to get env var
System.Security.SecurityException: Request for the permission of type
'System.Security.Permissions.EnvironmentPermission , mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed.
at System.Security.CodeAccessSecurityEngine.Check(Obj ect demand,
StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Environment.GetEnvironmentVariable(String variable)
at System.Environment.GetEnvironmentVariable(String variable,
EnvironmentVariableTarget target)
at CgiScript.Program.GetProcessEnvironmentVariable(St ring variable)
at CgiScript.Program.Main(String[] args)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.Permissions.EnvironmentPermission
The Zone of the assembly that failed was:
Internet
Jul 24 '08 #1
0 1169

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wayne Deleersnyder | last post by:
Hi, I'm a newbie at Perl and CGI and hoping someone can point me in the right direction. Recently I've been going through an older book I have on CGI programming to get a start. Most of it...
1
by: Brad H McCollum | last post by:
I'm writing an application using VB 6.0 as the front-end GUI, and the MSDE version of SQL Server as the back-end (it's a program for a really small # of users --- less then 3-4). I'm trying to...
1
by: Brad H McCollum | last post by:
I've looked through many suggestions and partial examples all over this newsgroup and still am not coming up with anything that does specifically what I'm wanting to accomplish. I'm writing a VB...
1
by: malborg | last post by:
I have simple form in PHP with two input types as text to input login name and password.PS: They use POST method. (index.php) The other script(logowanie.php) checks if login and password is...
16
by: Lyle Fairfield | last post by:
There is an MS-SQL table named Bugs_Comments_and_Suggestions. There is a form named Bugs_Comments_and_Suggestions. To allow John Doe to use this form, we GRANT him LOGIN and ACCESS permissions...
9
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
2
by: Jay | last post by:
I have a web app running on the windows CE device. In one of the asp.net pages - it has javascript code. That seems to have a memory leak. When I run the web app - in about one hour, the app hangs....
2
chunk1978
by: chunk1978 | last post by:
i wrote a custom PHP script last year and everything worked perfectly... recently my webserver upgraded to PHP 5 and now my script doesn't work properly. what the script does is: users fill out...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.