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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Logged In User Name

Status
Not open for further replies.

emblewembl

Programmer
May 16, 2002
171
GB
I have written an asp.net system for an intranet which shows a different menu depending on the user logged into the particular workstation being used.

In order to determine which user is logged in I use:

HttpContext.Current.User.Identity.Name

This works fine on my network and used to work fine on my clients network, but since a whole bunch of new PCS were hooked up, and new users were set up it doesn't work. If I do:

Response.Write("Name:" & HttpContext.Current.User.Identity.Name)

.... I just get a blank! Does anyone know what could have caused this. Incidentaly all the new users were set up so they can log on without a password. Would this effect it?

Thanks!


i love chocolate
 
If your looking for the username they logon to windows with (which i think you are) you can also get this from
Code:
Request.ServerVariables["AUTH_USER"];

Don't know if that will help with your problem though, I use this on our network with no problems. I assume you have Windows Authentication set for the website in IIS and have Anonymous Access switched off? Don't know if the no password setup would cause a problem. Sorry can't be more definitive. Good Luck.

Rob

------------------------------------

Go placidly amidst the noise and haste,
find what peace there may be in silence.
-Anon

------------------------------------
 
I was trying to log in using windows integrated security and could not.

crazyboybert, could you please let me know step-by-step procedure to login with windows integrated security?

 
Here is a tek-tips faq which may help. It is for ASp but the theory is the same.

faq333-144#

Rob

Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
 
Still the same error!!!

[ApplicationException: Access is denied.
]
System.Security.Principal.WindowsIdentity._ResolveIdentity(IntPtr userToken) +0
System.Security.Principal.WindowsIdentity.get_Name() +71
System.Web.Configuration.AuthorizationConfigRule.IsUserAllowed(IPrincipal user, String verb) +100
System.Web.Configuration.AuthorizationConfig.IsUserAllowed(IPrincipal user, String verb) +81
System.Web.Security.UrlAuthorizationModule.OnEnter(Object source, EventArgs eventArgs) +156
System.Web.SyncEventExecutionStep.Execute() +59
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87

What am I doing wrong? The steps I took are...
1. Removed Anonimous Access from IIS
2. Edited Web.Config and added <identity Impersonate=True/>
3. In connectstring of the Connection, I added Trusted_Connection =Yes and I am not using any username or password. I tried only username after your post with
....user id=&quot; & NTUserName() & &quot;;.....

Please help!!! Thanks.
 
Is &quot;Integrated Windows authentication&quot; in IIS checked?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top