0

I am using IIS 7.5, and .net 4.5 trying to use Windows login for an intranet site. Works fine on my dev machine, but when I push to the web server, the windows login is using a different username (websitename) instead of the logged in user (domain\me). Anyone have any ideas on where I should look?

Edit added code

The Web.config

<compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Windows">

</authentication>

The page Imports

Imports Microsoft.Exchange.WebServices.Data
Imports System.Web.Security
Imports System.Web
Imports System.Web.UI
Imports System.Linq
Imports Microsoft.AspNet.Identity
Imports Microsoft.AspNet.Identity.EntityFramework
Imports Microsoft.AspNet.Identity.Owin
Imports Owin
Imports System.Data.SqlClient

The vb code

Dim DomainUser As String = HttpContext.Current.User.Identity.Name.Replace("\", "/")
 Dim loginName As New LoginName
 Dim sideName As New LoginName
 loginName = HeadLoginView

 hfEmail.Value = System.Security.Principal.WindowsIdentity.GetCurrent.Name.Split("\")(1) + My.Settings.EmailDomain
Daryl
  • 28
  • 8
  • 1
    You will need to describe your IIS authentication settings, and describe what code you're using to get the current username. – mason Jun 30 '17 at 01:21
  • The edits have been made. – Daryl Jul 06 '17 at 16:39
  • 1
    You're not using the correct technique for getting the logged in user in ASP.NET. – mason Jul 06 '17 at 16:40
  • See [this answer](https://stackoverflow.com/a/5417176/1139830). – mason Jul 06 '17 at 17:01
  • Mason, that is absolutely correct. I had figured it out, I need to use Environment.Username instead of System.Security.Principal.WindowsIdentity.GetCurrent.Name. Sometimes it is all about asking the right question. Thank you – Daryl Jul 06 '17 at 17:51
  • As the answer I linked to states, you should use `System.Web.HttpContext.Current.User` in ASP.NET. – mason Jul 06 '17 at 17:53

0 Answers0