asp.net 2.0 dev using VS 2005!

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
 
C

Chris Fulstow

Should be the currently logged-in Windows user, you can verify using:
Response.Write(User.Identity.Name);
 
J

John Timney \(MVP\)

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
 
J

Jens Jensen

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);

}
************
 
J

Jens Jensen

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?
 
J

John Timney \(MVP\)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top