简体   繁体   中英

Issue getting ASP.Net and Windows Authentication working on IIS

I have a simple ASP.Net page with VB code running on WIN7 Enterprise VM with IIS 7.5 on which I need to get the visitors domain username on load and store it in a string variable. The page is hosted internally on our domain and IIS is setup to authenticate anonymously.

I am getting the username with the following code: Environment.Username but of course it always says that the logged on user is IUSR

I installed the Windows Authentication component for IIS but don't know how to get it to work properly. I only started with ASP and IIS last month so I am very new to this. I only want this to apply to a specific folder so I selected it and enabled Windows Authentication, set it NTLM, and disabled Anonymous + ASP Impersenation. That didnt work. I think I tried every combination possible and all I am getting is either error 500, 404 because it tries to redirect to some login page which doesnt exist and sometimes I would get a username/password prompt but even then it wont accept anything

I dont want to prompt users, I just want to pass their existing logon info and open the page. Can someone please tell me how to set this up. I spent all day looking at hundreds of forums and sites and could not get it to work.

I also added the following to the web.config file:

<Identify impersonate="true" />

Thanks

Make sure you specify authorized users in web.config:

 <authentication mode="Windows" />
    <authorization>
      <allow roles="mydomain\someADgroup"/>
      <allow users="mydomain\somuser"/>
      <allow users="*" /> <!-- if you want it open to anybody, as long as they are authenticated-- on the domain!>

    </authorization>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM