By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,356 Members | 1,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,356 IT Pros & Developers. It's quick & easy.

How to get current logged in Windows username?

P: n/a


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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.