?
Solved

Get Windows login in ASP.NET website on IIS 7

Posted on 2011-10-06
7
Medium Priority
?
2,219 Views
Last Modified: 2013-11-05
In my asp.net 4.0 website I am using windows login  user name to login in my website without asking credential if that windows login user is  in DB if that user not in db then asking credential and authenticate against db .
To achieve above goal I implemented form and widows authentication in my website.
When I ran website through VS 2010(Dev. environment) I get actual windows login name but if I ran website on IIS 7 then I get “IUSER” as a windows login.
Following command I am trying  
      
"HttpContext.Current.Request.LogonUserIdentity.Name" get "IUSR" (NT AUTHORITY\IUSR) on IIS 7.
      
"HttpContext.Current.User.Identity.Name"  get  empty on IIS 7.
      
How can i get actual windows login on IIS 7 as well?
0
Comment
Question by:Barnum
  • 4
  • 2
7 Comments
 
LVL 18

Expert Comment

by:ivan_vagunin
ID: 36926417
Hi! You need to enable impersonation in web.config:
<configuration>
  <system.web>
    <identity impersonate="true"/>
  </system.web>
</configuration>

(http://msdn.microsoft.com/en-us/library/xh507fc5.aspx)
0
 

Author Comment

by:Barnum
ID: 36926589
i am already using this.
0
 
LVL 14

Accepted Solution

by:
Dustin Hopkins earned 1500 total points
ID: 36928662
Have you enabled windows authentication for the site in IIS 7? You do this by clicking the authentication icon for your website/application's container in IIS manager. and enabling "windows authentication" and probably disable anonymous authentication.

Hope this helps,
Dustin
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

Author Comment

by:Barnum
ID: 36932578
Yes, I already did this.
0
 
LVL 14

Assisted Solution

by:Dustin Hopkins
Dustin Hopkins earned 1500 total points
ID: 36932699
Ok to wrap this up, on the server you have:
Enabled Windows authentication
Disabled Anonymous Authentication
The server is on the same domain as the connecting computer

In your application:
Turn off Impersonation, unless you are actually using this.
And you have set the following in the web config:
<authentication mode="Windows" />
<authorization>
   <deny users="?"/>
</authorization>
The authorization section forces the client to authenticate.

After double checking this are you still getting a blank user instance?

Hope this helps,
Dustin

0
 

Author Comment

by:Barnum
ID: 36950784
I tried above solution.
Still not working for me.
0
 

Author Closing Comment

by:Barnum
ID: 37002421
We settled on a different method of authentication.  Thanks for all the the help, though!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

850 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