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

Any way to determine, via code, the user's Windows Login Name and domain?

Greetings,

I have a web application that will be hosted on our intranet. I would like
to determine, via code the user's windows login name and domain in the
following format: DOMAIN\loginname

Is this possible? Thanks,

-Dave
Nov 19 '05 #1
4 1594
Yes, this is possible.
Use Windows authentication in your web app, then examine the User object
from your web page code. It should be WindowsPrincipal with WindowsIdentity,
and with identity.Name set to windows account name.
I might be wrong in some technical details as this is what I remember, but
in general it works.

Best regards
Rafal Gwizdala

"Dave" <no****@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Greetings,

I have a web application that will be hosted on our intranet. I would
like to determine, via code the user's windows login name and domain in
the following format: DOMAIN\loginname

Is this possible? Thanks,

-Dave

Nov 19 '05 #2
Simplistically put, you need the following:
1) In IIS console you need to set the Authentication method for the
application folder to Integrated Windows Security (typically this is just
unchecking anonymous access)
2) Make sure the NT folder's security permissions allow access for the
required users i.e. Authenticated Users...or at least the users / groups
notes in next step
3) In web.config enable impersonation <identity impersonate="true">
And allow all users...or at least the domain users and/or groups who
should have access
i.e. <authorization>
<allow users="*">
</authorization>
4) Use System.Security.Principal (vb Imports or c# Using)
5) Get the name in code i.e.in vb
' get the domain\user name
Dim userName As String = WindowsIdentity.GetCurrent.Name

I would strongly reccomend you look at
http://msdn.microsoft.com/library/de...cnetlpmsdn.asp
(can also get this as a book, which I highly reccomend)
"Dave" <no****@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Greetings,

I have a web application that will be hosted on our intranet. I would
like to determine, via code the user's windows login name and domain in
the following format: DOMAIN\loginname

Is this possible? Thanks,

-Dave

Nov 19 '05 #3
Hi Dave,

Use following steps:

1) In Web.Config file, set Windows authentication and deny anonymous:

<authentication mode="Windows"/>
<authorization>
<deny users="?" /> <!-- deny anonymous -->
<allow users="*" /> <!-- Allow all users -->
</authorization>

2) In code use:
Page.User.Identity.Name
It gives DOMAIN\loginname.

HTH

Elton Wang
el********@hotmail.com


"Dave" wrote:
Greetings,

I have a web application that will be hosted on our intranet. I would like
to determine, via code the user's windows login name and domain in the
following format: DOMAIN\loginname

Is this possible? Thanks,

-Dave

Nov 19 '05 #4
Thank you everybody for the responses, I appreciate it. I will give them a
try this morning.

-Dave
"Elton W" <El****@discussions.microsoft.com> wrote in message
news:E8**********************************@microsof t.com...
Hi Dave,

Use following steps:

1) In Web.Config file, set Windows authentication and deny anonymous:

<authentication mode="Windows"/>
<authorization>
<deny users="?" /> <!-- deny anonymous -->
<allow users="*" /> <!-- Allow all users -->
</authorization>

2) In code use:
Page.User.Identity.Name
It gives DOMAIN\loginname.

HTH

Elton Wang
el********@hotmail.com


"Dave" wrote:
Greetings,

I have a web application that will be hosted on our intranet. I would
like
to determine, via code the user's windows login name and domain in the
following format: DOMAIN\loginname

Is this possible? Thanks,

-Dave

Nov 19 '05 #5

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

Similar topics

4
by: Prehaut Anselme | last post by:
Hi, I need to create a WebRequest with an automatic proxy I have the specification of this porxy (host & port) I ask the user their own login and password, but the proxy tells me that the...
5
by: Dave Kolb | last post by:
Is there any other solution for an ASPNET application to access network resources other than running as SYSTEM, using delegation (a nightmare to get to work) or the COM+ solution? I cannot seem to...
2
by: J | last post by:
Hello. I apologize if this isn't the appropriate group for this question but I was wondering if it's possible to allow regular windows domain users to change their passwords through an .asp page? ...
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...
6
by: MuZZy | last post by:
Hi, I am looking to find a way to get currently logged in user's object GUID without querying ActiveDirectory. For example, when i log in to my laptop from home, I'm not on the office network so...
0
JustRun
by: JustRun | last post by:
Hi , I use .NET 2.xx for developing an intranet site, The IIS (my application) on Server1 (Domain controller) the SQl server 2000 on Server2. and both servers running through windows 2003. I...
4
by: =?Utf-8?B?QXZhRGV2?= | last post by:
ASP.Net 2. We are migrating to Windows 2008 64 bit Server with IIS 7 from Windows 2003 32 Bit with IIS 6. A few library classes we wrote uses impersonation in code like explained in this...
8
by: Brett | last post by:
I wrote an ASP.NET application that queries a SQL Server database (on a different box from the web server) and displays the result in a GridView. The datasource for the GridView is a SQLDataSource....
4
by: Brett | last post by:
I have an ASP.NET 2.0 application that uses Forms Authentication. The startup page contains just a login control, and the site works well on an IIS 6 web server. I am now setting the site up on...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
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.