473,652 Members | 3,045 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 WindowsPrincipa l
wpMain = new WindowsPrincipa l(WindowsIdenti ty.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 8640
Hi Kevin,

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

Ken

"SirPoonga" <ke*********@gm ail.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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 WindowsPrincipa l
wpMain = new WindowsPrincipa l(WindowsIdenti ty.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.

<authenticati on 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 WindowsPrincipa l
wpMain = new WindowsPrincipa l(WindowsIdenti ty.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
"Unrecogniz ed configuration section 'authentication '"
Hmmmm. I looked at msdn.micosoft.c om 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.N ame
aspUserName = Principal.Windo wsIdentity.GetC urrent.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 WindowsPrincipa l
wpMain = new WindowsPrincipa l(WindowsIdenti ty.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
3201
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 database. Tried all possible combinations but it still fails. I have Windows 2003 server having SQL Server 2000 installed with SP2. The installation went Ok on a XP professional machine and I was able to create database and user logins etc on...
4
2412
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). The problem is that the user who "owns" the service is always the ASPNET account. That's not good since you don't see the actual application (because it's owned by ASPNET). I've tried changed the processmodel section in the machine.config file to...
6
1388
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 ODBC (MSAccess) connections. As soon as I uninstalled it I was able to connect again. Is there something I need to do in order to use Aspnet on W2K and not clobber the connections?
3
2405
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 problem in building my web application. The error message is "Login failed for user\ASPNET". I've tried to supply/not supply a username and password at the SQL server login but both methods could not work. I did not create a username and password...
8
16507
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. Does anyone know if/how this can be done?
9
1947
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 the appropriate session cookie already. After logging in on that page successfully they are given the cookie and redirected back to the page they initially tried to go to. I would like to create a Windows application that gets data from that...
3
2051
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. Both applications are running on the same IIS. How do we authenticate users so that they don't have to sign in again without passing their name and password in the querystring or request header? The login details are the same for both...
6
12766
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 the error: "Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection." When I check System.Security.Principal.WindowsIdentity.GetCurrent().Name I get the valid domain user that I would expect, why isn't this...
11
1799
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 stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'AUM\ASPNET'.
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8703
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8467
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8589
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5619
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2703
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.