Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.NET not detecting the current logged in user

Status
Not open for further replies.

NuJoizey

MIS
Joined
Aug 16, 2006
Messages
450
Location
US
what does it mean when my VB.NET returns:

Code:
Response.Write(System.Environment.UserDomainName)
returns "NT AUTHORITY"

and
Code:
Reponse.Write(System.Environment.UserName)
returns "NETWORK SERVICE"


instead of

Code:
Response.Write(System.Environment.UserDomainName)
returns "MY DOMAIN"

and
Code:
Reponse.Write(System.Environment.UserName)
returns "MY USER NAME"

My app seems to no longer recognize who is logged in, which is annoying me to no end right now.
 
in the web.config file set the authencation mode to Windows.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
hey jason - how's the ladyfinger business going? thanks for the reply.

it's already set to "windows". Any other idea what configurations should I be checking?
 
i think it's something to do with anonymous access - in IIS if I disable anonymous access, the app authenticates the current user, however I need it to be enabled because there are still certain things a non-logged user can do on my app.

It stopped working because I moved my app to a new server, and something in the configuration isn't right....but what is that something???
 
how's the ladyfinger business going?
jersey, you can't have your cake and eat it too!

Windows auth should have anonymous disabled. Using windows auth noone should be anonymous.

windows auth means you are on an intranet, if its for the outside world, then you need to go to forms auth.

web.config should be similar to
Code:
  <system.web>
    <customErrors mode="Off"></customErrors>
    <authentication mode="Windows" />
    <identity impersonate="true" />
    <authorization>
      <allow roles="DomainName\Domain Users"/>
      <deny users="*"/>
    </authorization>
  </system.web>
 
if i do <identity impersonate="true" />, all it does is tell me

"Login failed for user 'MYSERVER\IUSR_MYSERVER' "

but that's just it, that's wrong! I'm not IUSR! I'm logged in under my own valid domain account. It should see that and log me in appropriately.

I'm missing what this is supposed to do, as it didn't seem to have any affect at all, but i'm still fiddling with it:

<authorization>
<allow roles="DomainName\Domain Users"/>
<deny users="*"/>
</authorization>

Now if I just disable anonymous access, then it works, but the changes in the web.config seem to have no impact at all since it works the same even if I don't change web.config.

The problem with just leaving anon access disabled are:

1. during RDP sessions on the server, I can't seem to access the app without having it prompt me for login credentials (which by the way it won't take)

2. I just want it to work the same way it had been working before, is that so wrong? <grin> Seriously though, i should be able to replicate that behavior, but I can't seem to do it.
 
whats saying "Login failed for user 'MYSERVER\IUSR_MYSERVER' "?

ASP.Net or SQL? Is your database on the same box as the webserver?
 
This is the error message generated in my browser window (i assume by ASP.NET which presumably "bubbles up" from SQL, right?). The db and the webserver are on the same box.
 
no bubbles! but the framework will report sql errors.

since its a new server can you post the url format that you are accessing (since its internal shouldnt be a risk posting it, but obfuscate it if you want but leave all the http and colons and dots as it is.
 
keep anaon disabled, IWA enabled, thats all you should need to do in IIS. In your folders, your web.config should be like above. Maybe change the AllowRoles to all for now and take out the deny. (of course that would only then prompt the user for credentials)

Your database should have domain user permissions setup or change your connection string to use the sa username and password.
Thats about all there is to it.

You will have probs if the address has a subdomain, IWA doesnt like that much. (
Publish or add to a page the below stuff to see what your web server is seeing the user as. Its c# converted so hopefully it works right out the box.


Code:
<asp:Repeater ID="ServerVarsRepeater" runat="server">
    <ItemTemplate>
        <b>
            <%# Container.DataItem %>
        </b>:&nbsp;<%# Request.ServerVariables(Container.DataItem) %>
        <br />
    </ItemTemplate>
</asp:Repeater>

kick it off by putting this in page load
ServerVarsRepeater.DataSource = Request.ServerVariables
ServerVarsRepeater.DataBind()


btw - connection string using iwa to sql should be similar to....

server=(local);database=DBName;trusted_connection=True;Connection Lifetime=180
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top