473,403 Members | 2,293 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,403 software developers and data experts.

ASP.NET/VB Get Windows Login (not ASPNET user)

I have been trying to figure out how to get the user login name of the
user using an asp.net page. This is for an intranet. I got as far as
doing something like this:

Dim wpMain as WindowsPrincipal
wpMain = new WindowsPrincipal(WindowsIdentity.GetCurrent())
Label1.Text = wpMain.Identity.Name

However, that will display <COMPUTERNAME>\ASPNET. I don't need the
ASPNET user, I need the user who is logged into the computer.
Any ideas?

Nov 19 '05 #1
6 8628
Hi Kevin,

Make sure you have Anonymous access switched off in IIS Manager and
Integrated switched on.

Ken

"SirPoonga" <ke*********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I have been trying to figure out how to get the user login name of the
user using an asp.net page. This is for an intranet. I got as far as
doing something like this:

Dim wpMain as WindowsPrincipal
wpMain = new WindowsPrincipal(WindowsIdentity.GetCurrent())
Label1.Text = wpMain.Identity.Name

However, that will display <COMPUTERNAME>\ASPNET. I don't need the
ASPNET user, I need the user who is logged into the computer.
Any ideas?


Nov 19 '05 #2
I've been working on similar things I found that I needed to disable
anonymous access and turn on integrated windows authentication. This however
will mean that users will need to sign in.

You also want to change the authenication mode in your web config file.

<authentication mode="Windows" />

If you find out a way to get the ID without the user having to login then
please post it here.


"SirPoonga" wrote:
I have been trying to figure out how to get the user login name of the
user using an asp.net page. This is for an intranet. I got as far as
doing something like this:

Dim wpMain as WindowsPrincipal
wpMain = new WindowsPrincipal(WindowsIdentity.GetCurrent())
Label1.Text = wpMain.Identity.Name

However, that will display <COMPUTERNAME>\ASPNET. I don't need the
ASPNET user, I need the user who is logged into the computer.
Any ideas?

Nov 19 '05 #3
"Unrecognized configuration section 'authentication'"
Hmmmm. I looked at msdn.micosoft.com on how to do the authentication
mode.

I will have to talk to the IT people. I don't have control over the
IIS server. I might not be able to do what I want.

Nov 19 '05 #4
Hi SirPoonga,

Try out the following code:

Imports System.Security
.........
.........

Dim authUserName As String
Dim aspUserName As String
authUserName = User.Identity.Name
aspUserName = Principal.WindowsIdentity.GetCurrent.Name
Label1.Text = "You are: " & authUserName
Label2.Text = "This page runs as: " & aspUserName
and ,

1) Start IIS
2) Expand your server and its default Web site, right-click the "your
project" site, and then click Properties.
3) On the Directory Security tab in the WindowsSite Properties dialog box,
click the Edit button in the "Anonymous access and authentication control"
section.
4) Click to clear the Anonymous access check box, verify that the Integrated
Windows authentication check box is selected, and then click OK.
5) Click OK to close the "your project" Properties dialog box.
6) Switch back to Visual Studio, and then run the project. Confirm that the
page is displayed with the following message:
You are: "Your Windows user name"
This page runs as: DomainOrServer\ASPNET
For more clarification feel free to touch with me...

Enjoy Programming....

Kombaraj .A

"SirPoonga" wrote:
I have been trying to figure out how to get the user login name of the
user using an asp.net page. This is for an intranet. I got as far as
doing something like this:

Dim wpMain as WindowsPrincipal
wpMain = new WindowsPrincipal(WindowsIdentity.GetCurrent())
Label1.Text = wpMain.Identity.Name

However, that will display <COMPUTERNAME>\ASPNET. I don't need the
ASPNET user, I need the user who is logged into the computer.
Any ideas?

Nov 19 '05 #5
That's awesome. Can I just get the user name, no domain? Or am I just
going to have to parse that. Nothing a simple split() can't solve.

Nov 19 '05 #6
Ok, I just tried this and it works on my machine running IIS for
development.
However, when I had an coworker try and open the page authentication
was required.
I guess I don't understand what is going on. How does someone else
view the page then? Do they have to login to something? Do I have to
setup User permissions somewhere?

Nov 19 '05 #7

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

Similar topics

2
by: Vaap | last post by:
I did lot of googling to see if I can solve the SQL server not found problem while trying to run ASP.Net community starter kit from an XP machine to Windows 2003 server hosting SQL server 2000...
4
by: Kristof Despiere | last post by:
Suppose you have one domain, filled with a couple of users. What needs to be done now is I need to start a windows application from a webform by pressing a button on the webform (for example). ...
6
by: SusieQ | last post by:
Is it possible to have asp.net on a windows 2000 server and still retain compatibility with clients who don't want to use it? I installed Aspnet on my Windows 2000 server and it killed all my...
3
by: Kim | last post by:
After installing MSDE2000 on my WIN XP machine, I created the database from Access using the upsizing wizard. Although the tables can be seen from the server explorer, I keep on encountering...
8
by: Keith H | last post by:
I'm looking for a way to force the user to re-authenticate with their Windows username/password/domain after clicking the submit button on an ASP.NET page. This is for an internal application. ...
9
by: Justin Engelman | last post by:
Hi, I have a website that uses an ISAPI filter that will redirect anyone going to any page on the site to an SSL login page (on a different website with the same root domain) if they do not have...
3
by: Joe Fawcett | last post by:
Dear All We have an application where users login, their name/password details are stored in a table, and now we want to add a third party bulletin board that lives in its own virtual directory....
6
by: Not Me | last post by:
Hey, We have an sql server 2000 machine and IIS 6 machine running seperately but on the same domain. I can connect fine to the database without using impersonation, but when it's enabled I get...
11
by: Anil Gupte | last post by:
I am getting the following error: ********* Login failed for user 'AUM\ASPNET'. Description: An unhandled exception occurred during the execution of the current web request. Please review the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.