capture window username

G

Guest

Hi

How do I the the username that was used when you logged into Windows from asp .net or c#? Thanks

Cheers,
James
 
G

Guest

I need the window username and password information so that I can imporsonate to access a remote file server using the UNC path. How can I do that not using asp server object but asp .net or c# code.

----- Steve C. Orr [MVP, MCSD] wrote: -----

Try Request.ServerVariables("LOGON_USER").

Note that it may not work consistently if you allow anonymous users in IIS.
Here's more info:
http://www.4guysfromrolla.com/webtech/092298-3.shtml

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
 
S

Steve C. Orr [MVP, MCSD]

It's the same syntax for ASP and ASP.NET and C# and VB.NET:
Request.ServerVariables("LOGON_USER")

For impersonation details you can look here:
http://msdn.microsoft.com/library/d...-us/cpguide/html/cpconaspnetimpersonation.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net



Z0gS said:
I need the window username and password information so that I can
imporsonate to access a remote file server using the UNC path. How can I do
that not using asp server object but asp .net or c# code.
----- Steve C. Orr [MVP, MCSD] wrote: -----

Try Request.ServerVariables("LOGON_USER").

Note that it may not work consistently if you allow anonymous users in IIS.
Here's more info:
http://www.4guysfromrolla.com/webtech/092298-3.shtml

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net




Z0gS said:
Windows from
asp .net or c#? Thanks
 
G

Guest

Can I do in the following way and setting <identity impersonate="false"/>

WindowsImpersonationContext context = WindowsIdentity.Impersonate(System.Security.Principal.WindowsIdentity.GetCurrent().Token);

//perform action here

context.Undo();


----- Steve C. Orr [MVP, MCSD] wrote: -----

It's the same syntax for ASP and ASP.NET and C# and VB.NET:
Request.ServerVariables("LOGON_USER")

For impersonation details you can look here:
http://msdn.microsoft.com/library/d...-us/cpguide/html/cpconaspnetimpersonation.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net



Z0gS said:
I need the window username and password information so that I can
imporsonate to access a remote file server using the UNC path. How can I do
that not using asp server object but asp .net or c# code.
----- Steve C. Orr [MVP, MCSD] wrote: -----
Try Request.ServerVariables("LOGON_USER").
Note that it may not work consistently if you allow anonymous users
in IIS.
Here's more info:
http://www.4guysfromrolla.com/webtech/092298-3.shtml
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
 

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
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top