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

How to get current logged in Windows username?



I want to automate the process of logging into an intranet. I want to pull
out the username of the Windows user logged into the machine running the
browser and use the username in my app. How can I get the logged in
username?

Do I have to disable the anonymous access in IIS? I rather not because the
site is running under a certain domain user which has access to certain
folder and network shares and the site needs thsi access for reading and
writing files.

--
John Dalberg
Nov 19 '05 #1
6 4575
Hi John,

If you use Windows authentication and deny anonymous
access, you can use HttpContext.Current.User.Identity.Name
to get domain log on user name.

HTH

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

-----Original Message-----
I want to automate the process of logging into an intranet. I want to pullout the username of the Windows user logged into the machine running thebrowser and use the username in my app. How can I get the logged inusername?

Do I have to disable the anonymous access in IIS? I rather not because thesite is running under a certain domain user which has access to certainfolder and network shares and the site needs thsi access for reading andwriting files.

--
John Dalberg
.

Nov 19 '05 #2
On Wed, 6 Apr 2005 16:14:41 -0700, Eltoon Wang wrote:
Hi John,

If you use Windows authentication and deny anonymous
access, you can use HttpContext.Current.User.Identity.Name
to get domain log on user name.

I will explain what I need to do and someone may tell me the proper set up
for this.

I have an ASP.NET intranet that maintains its own user database where users
log in through a form. I would like to streamline the login process so that
users do not have to log in manually to the Intranet. If they are logged in
to the domain and click on the Intranet's url, they are logged in the
Intranet automatically. The Intranet app knows who they are and
authenticate them behind the scene. My idea is that the Window's username
is synced with the Intranet username. Somehow I want my asp.net to pull out
the username from Windows and if it exists in the Intranet database, log in
the user. The Intranet website runs under a domain user which has rights to
certain documents folders for reading and writing purposes. That user is
the anonymous user under which the site runs. If I disable anonymous
security, then the Intranet website will run under which user? The logged
in user? The site needs to run under a single user no matter who's logged
in so that the web app has rights to certain folders locally.
Do I enable impersonation? What's the proper set up for this? LDAP?

TIA

John Dalberg

-----Original Message-----
I want to automate the process of logging into an

intranet. I want to pull
out the username of the Windows user logged into the

machine running the
browser and use the username in my app. How can I get the

logged in
username?

Do I have to disable the anonymous access in IIS? I

rather not because the
site is running under a certain domain user which has

access to certain
folder and network shares and the site needs thsi access

for reading and
writing files.

--
John Dalberg
.

Nov 19 '05 #3
On Wed, 6 Apr 2005 16:14:41 -0700, Eltoon Wang wrote:
Hi John,

If you use Windows authentication and deny anonymous
access, you can use HttpContext.Current.User.Identity.Name
to get domain log on user name.


How can you do something similar with Form authentication?

John Dalberg
-----Original Message-----
I want to automate the process of logging into an

intranet. I want to pull
out the username of the Windows user logged into the

machine running the
browser and use the username in my app. How can I get the

logged in
username?

Do I have to disable the anonymous access in IIS? I

rather not because the
site is running under a certain domain user which has

access to certain
folder and network shares and the site needs thsi access

for reading and
writing files.

--
John Dalberg
.

--

John Dalberg
Nov 19 '05 #4
Try going through this articles:-

http://support.microsoft.com/default...b;EN-US;308157

http://www.c-sharpcorner.com/Code/20...cationWithAD.a
sp

Hope it helps
Patrick

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #5
On Sun, 17 Apr 2005 21:46:07 -0700, Patrick Olurotimi Ige wrote:
Try going through this articles:-

http://support.microsoft.com/default...b;EN-US;308157

http://www.c-sharpcorner.com/Code/20...cationWithAD.a
sp

Thanks. These articles explain how forms authentication work which I
already know. The point I was making is how to know who is the current user
who authenticated on the Intranet form and if their session is still
active. I wanted to get this info from my app which appears inside the
Intranet. I can't read the Intranet app's cookie because I have no access
to it because my app is a separate app and not part of it.

It seems using Windows authentication is a better way. It also means that
users do not need to authenticate to the Intranet if they are already
authenticated in Windows.

--
John Dalberg
Nov 19 '05 #6
On Wed, 6 Apr 2005 16:14:41 -0700, Eltoon Wang wrote:
Hi John,

If you use Windows authentication and deny anonymous
access, you can use HttpContext.Current.User.Identity.Name
to get domain log on user name.

Now I am in a delimma. For HttpContext.Current.User.Identity.Name to work,
"anonymous access" needs to be turned off but I need the Intranet app run
under a domain user who has access to network shares. Otherwise if I have
intergrated Windows security used then I have to maintain all kinds of ntfs
permissions and probably all kinds of others issues which I can't think of
right now. Access to folders is maintained by the Intranet app.

John Dalberg


-----Original Message-----
I want to automate the process of logging into an

intranet. I want to pull
out the username of the Windows user logged into the

machine running the
browser and use the username in my app. How can I get the

logged in
username?

Do I have to disable the anonymous access in IIS? I

rather not because the
site is running under a certain domain user which has

access to certain
folder and network shares and the site needs thsi access

for reading and
writing files.

--
John Dalberg
.

--
John Dalberg
Nov 19 '05 #7

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

Similar topics

1
by: Rudolf Bargholz | last post by:
Hi, DB2 v7.1 FP3 on Windows 2003 I am trying to acheive the following: create trigger ADD_LHL after insert on MAINTABLE for each row mode db2sql insert into LOGTABLE
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). ...
1
by: Sudhakara.T.P. | last post by:
Hi, I have an application in VB.NET windows application, wherein the administrator has the option to change the authentication mode ie., whether the application should work as a normal database...
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
5
by: mvr | last post by:
Hi all How to get the Windows current logged user name using Classic ASP. If no direct way are there any work arounds. Thanks mvr
0
by: D-Someone | last post by:
We have an active directory user that just had her username renamed. When the user is running an application that calls our CurrentUser web service method (which returns the value of...
3
by: Lattis | last post by:
I have the following problem: User A is logged in to a windows 2000 terminal. He runs an application which runs under the credentials of a different user. If I try to see the current user...
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...
1
by: ranju | last post by:
I am trying to spawn a process (say an exe file) with different user crendentials than that of the current user. 1) Called LogonUserEx() to logon the user and recieve a handle to the token that...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.