asp.net 2.0 dev using VS 2005!

  • Thread starter Thread starter Jens Jensen
  • Start date Start date
J

Jens Jensen

Hello,
when i runan app under VS 2005using the built in web server, which user is
my web application running under?



Many thanks
JJ
 
Should be the currently logged-in Windows user, you can verify using:
Response.Write(User.Identity.Name);
 
Its you, or better described as " the page runs in the context of your
current user account " whihc is whatever account yourt logged in with when
you run the app through the server.

read about it here:
http://msdn2.microsoft.com/en-us/library/58wxa9w5.aspx

If you want to check it, heres a bit of code that will tell you who you are:

one import

and 4 labels, stick this code in the page load event

lbl1.Text = "'" + User.Identity.Name + "'";

lbl2.Text = WindowsIdentity.GetCurrent().Name;

bool fred = ((WindowsIdentity)User.Identity).IsAnonymous;

lbl3.Text = fred.ToString();

lbl4.Text = Request.LogonUserIdentity.Name.ToString();



--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
 
Then then maybe you can help me solve the problem below:

**************************

I use the code below to zip files to a single .zip destination. I get the
expected result when i work on my developement machine (WinXP sp.2).

When i deploy the web application which host the code on win2k3 , it only
works for a single file.

I gave the modify right to "Noetwork Service" on the folder i'm writing to.
It does not help.

Can someone tell me what i'm doing wrong?
Code below:


protected void ZipWithExternalBatch(string input_file)

{

try

{

System.Diagnostics.Process job = new System.Diagnostics.Process();

job .StartInfo.FileName = "pkzip.exe";

job .StartInfo.Arguments = "-add " +
ConfigurationManager.AppSettings["TargetZipFile"].ToString()+ " " +
Server.MapPath(input_file);



job .StartInfo.UseShellExecute = false;

job .StartInfo.RedirectStandardOutput = true;

job .Start();

job .StandardOutput.ReadToEnd();

job.WaitForExit();

catch (Exception ex)

{

AppLog.Write(ex);

}
************
 
For some reason , the string

User.Identity.Name is empty on the server but returns the my user login name
on the developement server.

Hummmm?
 
Process.start is never easy to work with as its hard to gauge the impact of
calling any exe from the asp.net account. If I was you, I would look at
impersonation, and impersonate an actual user rather than relying on the
service account, that way like on your development machine the code will be
running as you.

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com


Jens Jensen said:
Then then maybe you can help me solve the problem below:

**************************

I use the code below to zip files to a single .zip destination. I get the
expected result when i work on my developement machine (WinXP sp.2).

When i deploy the web application which host the code on win2k3 , it only
works for a single file.

I gave the modify right to "Noetwork Service" on the folder i'm writing
to.
It does not help.

Can someone tell me what i'm doing wrong?
Code below:


protected void ZipWithExternalBatch(string input_file)

{

try

{

System.Diagnostics.Process job = new System.Diagnostics.Process();

job .StartInfo.FileName = "pkzip.exe";

job .StartInfo.Arguments = "-add " +
ConfigurationManager.AppSettings["TargetZipFile"].ToString()+ " " +
Server.MapPath(input_file);



job .StartInfo.UseShellExecute = false;

job .StartInfo.RedirectStandardOutput = true;

job .Start();

job .StandardOutput.ReadToEnd();

job.WaitForExit();

catch (Exception ex)

{

AppLog.Write(ex);

}
************

John Timney (MVP) said:
Its you, or better described as " the page runs in the context of your
current user account " whihc is whatever account yourt logged in with
when you run the app through the server.

read about it here:
http://msdn2.microsoft.com/en-us/library/58wxa9w5.aspx

If you want to check it, heres a bit of code that will tell you who you
are:

one import

and 4 labels, stick this code in the page load event

lbl1.Text = "'" + User.Identity.Name + "'";

lbl2.Text = WindowsIdentity.GetCurrent().Name;

bool fred = ((WindowsIdentity)User.Identity).IsAnonymous;

lbl3.Text = fred.ToString();

lbl4.Text = Request.LogonUserIdentity.Name.ToString();



--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
 
Back
Top