Getting the current Windows user name

N

Nick

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.GetCurrent().Name() - Is this the
right one to use?
 
D

Dale

Check your NTFS permissions (ACLs) to make sure the user trying to access
the folder and files have access.

Dale
 
G

Greg Burns

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
 
N

Nick

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
 
G

Greg Burns

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top