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

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 2098
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().Name

--

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**************@TK2MSFTNGP14.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().Name

--

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 <authentication 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.Current.User.Identity.Name will do
it from a class
or simply Page.User.Identity.Name from a web form.

Greg

"Jason Shohet" <__******@yahoo.com> wrote in message
news:OQ*************@TK2MSFTNGP11.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**************@TK2MSFTNGP14.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().Name

--

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\system32\drivers\etc\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****************@TK2MSFTNGP09.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:

<authorization>
<allow roles="SRVWEB2\Permissions - HR" />
<allow users="OURDOMAIN\burnsg" />
<deny users="*" />
</authorization>

"Jason Shohet" <__******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.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
I understand. I am just saying you COULD restrict using web.config. Sounds
to me like you ARE restricting using NTFS permissions on the web server.

But, like I said (or thought I did). NTFS permissions should not be
blocking different users unless you have identity impersonate turned on in
web.config. If you DON'T have it turned on, then as far as NTFS permissions
are concerned everybody is connecting as the ASPNET user.

Take a look at the NTFS permissions for your virtual directory on the web
server.

Greg

"Jason Shohet" <__******@yahoo.com> wrote in message
news:uE**************@TK2MSFTNGP09.phx.gbl...
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 #11
I especially coded in the web.config:

<authentication mode="Windows" />
<identity impersonate="false" />

but still, I and certain others can't log in, and others can. Bizarre
Nov 18 '05 #12

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

Similar topics

7
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...
4
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...
1
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...
1
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...
4
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...
1
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...
15
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...
0
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...
13
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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,...
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.