How to get current logged in Windows username?

J

John Dalberg

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.
 
E

Eltoon Wang

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
(e-mail address removed)
 
J

John Dalberg

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
 
J

John Dalberg

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


 
J

John Dalberg



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.
 
J

John Dalberg

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




 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top