Solved

web page thinks logged on user = "NETWORK SERVICE"

Posted on 2010-09-14
2
332 Views
Last Modified: 2012-05-10
I've created the method below to return the name of the user logged onto the PC.  ex:  john.doe

Works great when running from my own PC.  But when we put the code on our server and run it, the method returns a value of "NETWORK SERVICE" regardless of who runs the web page from their PC.

I need to know who is logged onto the site because that is used in the functionality of the site (ex:  record who made changes to data, etc.)

Thanks in advance for help,

Eric
public static string GetWindowsName()
  {
      string domainUser;
      string[] NameArray;

domainUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
      
NameArray = domainUser.Split('\\');

NameArray = User.Identity.Name.Split('\\');

return NameArray[1];
  }

Open in new window

0
Comment
Question by:Eric3141
2 Comments
 
LVL 30

Accepted Solution

by:
Brad Howe earned 500 total points
ID: 33672286

Hi,
The following code  "System.Security.Principal.WindowsIdentity.GetCurrent().Name" is used to what user the thread is executing as.

Please take a look at impersonation in this tech article. - http://support.microsoft.com/kb/306158

To correct this, you will need to configure the application to impersonate the Windows user who is accessing it by adding the following element after the authentication element in the Web.Config:

<identity impersonate="true"/>

If you do not set impersonate to true then the worker process runs as the Network Service or ASPNET account, depending on your version of IIS.

Cheers, Hades666
0
 
LVL 2

Author Comment

by:Eric3141
ID: 33708547
Worked great - thanks!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now