473,662 Members | 2,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

who is logged in user, from Active Dir?

How can I get the current logged in user on the computer? We're all Active
Directory here -- Netbios is not turned on however. I need to get the name
the user logged in as, when he started up his machine...

TY
jason shohet
Nov 18 '05 #1
11 2114
Jason Shohet wrote:
How can I get the current logged in user on the computer? We're all
Active Directory here -- Netbios is not turned on however. I need
to get the name the user logged in as, when he started up his
machine...


Jason,
If your IIS Application is using Windows Authentication and you have
Identity Impersonate enabled in web.config, then you can get the current
user's credential using: WindowsIdentity .GetCurrent().N ame

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP

Hire top-notch developers at
http://www.able-consulting.com
Nov 18 '05 #2
hi Carl,
we're not using any authentication on the site -- its just a regular asp.net
intranet site that shows a list of employees. We'd like to allow employees
to edit a few records in a database. But first we have to know who they are
logged in as -- on the box. But I don't want to have the user have to log
in to the site... If i turn on windows authentication in iis (windows 2003
server), will that cause an ugly challenge-response window?

TY

"Carl Prothman [MVP]" <ca****@spamcop .net> wrote in message
news:u0******** ******@TK2MSFTN GP14.phx.gbl...
Jason Shohet wrote:
How can I get the current logged in user on the computer? We're all
Active Directory here -- Netbios is not turned on however. I need
to get the name the user logged in as, when he started up his
machine...


Jason,
If your IIS Application is using Windows Authentication and you have
Identity Impersonate enabled in web.config, then you can get the current
user's credential using: WindowsIdentity .GetCurrent().N ame

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP

Hire top-notch developers at
http://www.able-consulting.com

Nov 18 '05 #3
Not if using IE. (Firefox will still prompt). We use it all the time
(Windows 2000 Server IIS 5)

uncheck anonymous, and check integrated

add <authenticati on mode="Windows" /> to web.config also

you do NOT need to turn on Identity Impersonate in web.config to get
username!

Dim sCurrentuser As String = HttpContext.Cur rent.User.Ident ity.Name will do
it from a class
or simply Page.User.Ident ity.Name from a web form.

Greg

"Jason Shohet" <__******@yahoo .com> wrote in message
news:OQ******** *****@TK2MSFTNG P11.phx.gbl...
hi Carl,
we're not using any authentication on the site -- its just a regular
asp.net intranet site that shows a list of employees. We'd like to allow
employees to edit a few records in a database. But first we have to know
who they are logged in as -- on the box. But I don't want to have the
user have to log in to the site... If i turn on windows authentication in
iis (windows 2003 server), will that cause an ugly challenge-response
window?

TY

"Carl Prothman [MVP]" <ca****@spamcop .net> wrote in message
news:u0******** ******@TK2MSFTN GP14.phx.gbl...
Jason Shohet wrote:
How can I get the current logged in user on the computer? We're all
Active Directory here -- Netbios is not turned on however. I need
to get the name the user logged in as, when he started up his
machine...


Jason,
If your IIS Application is using Windows Authentication and you have
Identity Impersonate enabled in web.config, then you can get the current
user's credential using: WindowsIdentity .GetCurrent().N ame

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP

Hire top-notch developers at
http://www.able-consulting.com


Nov 18 '05 #4
Greg,

Half way there but still 1 problem. I turned on integrated authentication,
& put the code in you specified. It works fine on the server itself, and I
can get the logged in user. But when I browsed from my machine to the
server, it prompted me for username & password. I'm on an XP client, but
of course logged in against Active Directory a few days ago (i generally
don't turn my machine off, I just lock it ea. night :) ). Not sure why its
prompting me...
Nov 18 '05 #5
OK, fraid of that.

Not sure about your network topography (also I'm not a network guru).

We connect to our intranet using http://intranet This "intranet" alias is
on our local dns server. If I try and type just the ip address it will
prompt for me too.

Couple things you can do:

Add the ip address to each browser's list of local address (in the security
tab).
Or add the ip addresss to your local hosts file.
C:\WINDOWS\syst em32\drivers\et c\hosts (no extension)

Obviously neither is very convenient.

The best is to have your "intranet" published on a DNS server.

But like I said, I am not a network guy and maybe talking out my *ss. :^)

Greg

"Jason Shohet" <__******@yahoo .com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Greg,

Half way there but still 1 problem. I turned on integrated
authentication, & put the code in you specified. It works fine on the
server itself, and I can get the logged in user. But when I browsed from
my machine to the server, it prompted me for username & password. I'm on
an XP client, but of course logged in against Active Directory a few days
ago (i generally don't turn my machine off, I just lock it ea. night
:) ). Not sure why its prompting me...

Nov 18 '05 #6
wait, my computer is the only one w/ the prob, its working on others... i'll
reboot & see if that works.
Its been a few weeks...
Nov 18 '05 #7
Greg, VERY bizarre.

When I log on as Joe, Cathy or Rufus on my machine, they have no
problem getting authenticated & don't get interrogated. When I log on as
myself, I get the Abu Graib interrogation.. ... I don't get it. Is
something wrong with me :)
Have the network guys somehow cursed me so that I don't work with windows
integrated logon?

TY
Nov 18 '05 #8
Sounds like you might have NTFS permisions restrictions set on the virtual
directory on the web site. Maybe you're not part of a group? Having said
that, if you don't have identity impersonate turned on in web.config (which
you shouldn't) this shouldn't be happening. Without it on, it will just
look like the ASPNET user is accessing the folder to NTFS.

If you want to restrict the site to specific users\groups in AD, use code
like this in web.config:

<authorizatio n>
<allow roles="SRVWEB2\ Permissions - HR" />
<allow users="OURDOMAI N\burnsg" />
<deny users="*" />
</authorization>

"Jason Shohet" <__******@yahoo .com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Greg, VERY bizarre.

When I log on as Joe, Cathy or Rufus on my machine, they have no
problem getting authenticated & don't get interrogated. When I log on as
myself, I get the Abu Graib interrogation.. ... I don't get it. Is
something wrong with me :)
Have the network guys somehow cursed me so that I don't work with windows
integrated logon?

TY

Nov 18 '05 #9
We're not restricting anything in the web.config at all !

The authentication works on 2/3 of the people I've tested, 1/3 it doesn't
work....
I'm going around to peoples' pc's to see if I can detect a pattern. We're
all on active directory however, the same domain.

Nov 18 '05 #10

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

Similar topics

7
17272
by: fr? | last post by:
Hi, i have a website , on wich users have to log in credentials are checked against mysql db some session vars are set during login for use somewhere else in the code. Is there a way to prohibit a user to log in twice. A was thinking about setting some flag in the db, but in that case i need some timeout in case a pc can crash for instance so the user does
4
7370
by: Akhlaq Khan | last post by:
we are developing an intranet application (web based) which needs to detect the logged in user ID of the user hitting the website. the intranet is huge and based on win2k active directory (around 20-30 different domains) with 25K+ users. i dont want to use "NT challenge response" for this pupose. I am exploring ways using ADSI and WMI to query the Active directory by using the IP address in the incoming web request and trying to figure...
1
7306
by: anonymous | last post by:
Hi all, I've been searching the way to achieve the following task. But no luck so far. I have a web site(main site), which requires authentication. This authentication is set at Windows directory level, so user will see the pop up gray box in order to log in rather than custom web page. The username and password are stored at active directory level, thus this is the windows integrated security.
1
2533
by: Mike Moore | last post by:
Does anyone have suggestions on the best way to check if a user is logged into asp.net web application? We are not using forms authentication. We are authenticating our users against active directory. I some people use the database to determine if a user is logged in between web pages and check in the web forms.
4
10116
by: Jarod_24 | last post by:
How do a windows-service detect whether a user is logged or not on a computer? So far i've found nothing in the windows api or any code examples that will allow me to figure this out. The solution i have today is to use Diagnostics.Process.GetProcesses and then iterate through the array i get and look for explorer.exe Explorer.exe is not loaded when a user is logged out of a computer. I found this on winlogon states:...
1
4097
maxamis4
by: maxamis4 | last post by:
Hello folks, Here is the backgroup. I am creating an agent that can find a user in LDAP and return the last logon date. Now i am not sure if with active directory you can user the SAMAccountName to retrieve the last computer the users logged on to. But i am looking for a place where i can learn this information. I was hoping someone out there could point me in the right direction. Below is my code which i have been working on. It can...
15
2682
by: paul814 | last post by:
Is it possible to display the logged in user that is accessing the form, in a textbox? so say I have txtname I want to display the username of the person that is logged in to the PC in that box, can I do this? How would this be done?
0
2121
by: thephatp | last post by:
Is there any possible way to get the currently logged in (active) user from within a service? I need the service to start at runtime. I need to capture log on / log off / switch user events. I haven't gotten to that yet, but it IS possible from within a windows service, correct? I figured I'd ask because of my current problem. Line of code in question: System.Security.Principle.WindowsIdentity.GetCurrent().Name From within an...
13
6733
by: snowinfo | last post by:
Hi all, any way to count the number of users i have logged into my site? any help/code appreciated, craig
0
8343
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8762
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
8545
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
8633
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
7365
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6185
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
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
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
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

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.