473,326 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Getting the current Windows user name

I'm developing an intranet app, and want to get the current user name for
logging purposes. I've turned off anonymous access, and turned on windows
authentication in the IIS config. The apps web.config file has
authentication mode set to windows, and 'identity impersonate' is set to
true.

When I try and get the default.aspx page, IE returns an error page with an
'Access is denied.' error. (Even if I try direct from the webserver, logged
on as the administrator.)

Where else do I have to set the permissions?

Thanks,

Nick

PS: I'm using this line in the code to get the user:
System.Security.Principal.WindowsIdentity.GetCurre nt().Name() - Is this the
right one to use?
Nov 18 '05 #1
4 5952
Check your NTFS permissions (ACLs) to make sure the user trying to access
the folder and files have access.

Dale

"Nick" <Ni**@NTWorks.no.spam.fsnet.co.uk> wrote in message
news:Ow**************@TK2MSFTNGP11.phx.gbl...
I'm developing an intranet app, and want to get the current user name for
logging purposes. I've turned off anonymous access, and turned on windows
authentication in the IIS config. The apps web.config file has
authentication mode set to windows, and 'identity impersonate' is set to
true.

When I try and get the default.aspx page, IE returns an error page with an
'Access is denied.' error. (Even if I try direct from the webserver, logged on as the administrator.)

Where else do I have to set the permissions?

Thanks,

Nick

PS: I'm using this line in the code to get the user:
System.Security.Principal.WindowsIdentity.GetCurre nt().Name() - Is this the right one to use?

Nov 18 '05 #2
From a webform inheriting from Page class:
Dim sCurrentuser As String = Me.User.Identity.Name

From a class not inheriting from Page:
Dim sCurrentuser As String = HttpContext.Current.User.Identity.Name

Do these:
Turn off anonymous access
turn on window authentication in IIS
web.config autentication mode set to windows

Not required to do this
Setting Identity Impersonate = True <-- this might be why getting Access
denied to Virtual directory on IIS

HTH,
Greg
"Nick" <Ni**@NTWorks.no.spam.fsnet.co.uk> wrote in message
news:Ow**************@TK2MSFTNGP11.phx.gbl...
I'm developing an intranet app, and want to get the current user name for
logging purposes. I've turned off anonymous access, and turned on windows
authentication in the IIS config. The apps web.config file has
authentication mode set to windows, and 'identity impersonate' is set to
true.

When I try and get the default.aspx page, IE returns an error page with an
'Access is denied.' error. (Even if I try direct from the webserver, logged on as the administrator.)

Where else do I have to set the permissions?

Thanks,

Nick

PS: I'm using this line in the code to get the user:
System.Security.Principal.WindowsIdentity.GetCurre nt().Name() - Is this the right one to use?

Nov 18 '05 #3
Thanks for the suggestions - that seems to have done the trick!

One difference though - on my XP Pro Dev PC I have to give the ASPNET user
the database permissions for the pages to work. On the Win2k Server I need
to give the IWAM_ user the db permissions. Is this right?

Nick

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
From a webform inheriting from Page class:
Dim sCurrentuser As String = Me.User.Identity.Name

From a class not inheriting from Page:
Dim sCurrentuser As String = HttpContext.Current.User.Identity.Name

Do these:
Turn off anonymous access
turn on window authentication in IIS
web.config autentication mode set to windows

Not required to do this
Setting Identity Impersonate = True <-- this might be why getting Access
denied to Virtual directory on IIS

HTH,
Greg
"Nick" <Ni**@NTWorks.no.spam.fsnet.co.uk> wrote in message
news:Ow**************@TK2MSFTNGP11.phx.gbl...
I'm developing an intranet app, and want to get the current user name for logging purposes. I've turned off anonymous access, and turned on windows authentication in the IIS config. The apps web.config file has
authentication mode set to windows, and 'identity impersonate' is set to
true.

When I try and get the default.aspx page, IE returns an error page with an 'Access is denied.' error. (Even if I try direct from the webserver,

logged
on as the administrator.)

Where else do I have to set the permissions?

Thanks,

Nick

PS: I'm using this line in the code to get the user:
System.Security.Principal.WindowsIdentity.GetCurre nt().Name() - Is this

the
right one to use?


Nov 18 '05 #4
I have the same setup (Win XP Pro for development & Win 2K Server for
deployment) and I only have to give ASPNET user modify permissions to
database folder.

Download Filemon from here:
http://www.sysinternals.com/

Run it on your server, and see what is happening.

Good luck,
Greg

"Nick" <Ni**@NTWorks.no.spam.fsnet.co.uk> wrote in message
news:uT**************@TK2MSFTNGP09.phx.gbl...
Thanks for the suggestions - that seems to have done the trick!

One difference though - on my XP Pro Dev PC I have to give the ASPNET user
the database permissions for the pages to work. On the Win2k Server I need
to give the IWAM_ user the db permissions. Is this right?

Nick

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
From a webform inheriting from Page class:
Dim sCurrentuser As String = Me.User.Identity.Name

From a class not inheriting from Page:
Dim sCurrentuser As String = HttpContext.Current.User.Identity.Name

Do these:
Turn off anonymous access
turn on window authentication in IIS
web.config autentication mode set to windows

Not required to do this
Setting Identity Impersonate = True <-- this might be why getting Access
denied to Virtual directory on IIS

HTH,
Greg
"Nick" <Ni**@NTWorks.no.spam.fsnet.co.uk> wrote in message
news:Ow**************@TK2MSFTNGP11.phx.gbl...
I'm developing an intranet app, and want to get the current user name for logging purposes. I've turned off anonymous access, and turned on windows authentication in the IIS config. The apps web.config file has
authentication mode set to windows, and 'identity impersonate' is set to true.

When I try and get the default.aspx page, IE returns an error page
with
an 'Access is denied.' error. (Even if I try direct from the webserver,

logged
on as the administrator.)

Where else do I have to set the permissions?

Thanks,

Nick

PS: I'm using this line in the code to get the user:
System.Security.Principal.WindowsIdentity.GetCurre nt().Name() - Is
this the
right one to use?



Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brian Henry | last post by:
im wokring on an intranet site, and i need the username of the current user logged in so it displays their information, how do i find out the user name thats logged into the system so i can use it...
4
by: Mark | last post by:
hey, i'm trying to get the current windows user and the groups they are in. Intergrated windows auth on and annoymous access turned off on IIS. However when trying to compile the following code...
4
by: Vik | last post by:
An ASP.NET page uses Windows authentication method for the user log in. How can get the username by code in this page? Thanks.
8
by: Mark White | last post by:
Hey everyone I'm having a great deal of problems finding this information through google and yahoo, so I turn to you on this. I have a Windows app running on XP. I am able to caputre the...
13
by: Steve Enzer | last post by:
How can I get the login name of the user currently logged into Windows as a string? Thanks, Steve Enzer
3
by: Atul | last post by:
Hi, I am running .NET Framework 2.0 on windows XP SP2. I am stuck in a situation where I need to find out a list of all active sessions running in IIS for a web application. I know that .NET...
1
by: iwdu15 | last post by:
hi, how can i get the icon associated with a certain file type? thanks -- -iwdu15
9
by: Alex | last post by:
Get the Name and Phone Number of the Current Windows User in a .NET Application I am writing a simple .NET (C#) application. It needs to "automatic" get the Name (last, first) and phone number...
3
by: tshad | last post by:
I have a file that I converted from VB.Net to C# that works fine in VB.Net when I compile but not in C# using the same libraries. The error I am getting is: PageInit.cs(9,7): error CS0138: A...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.