.NETGURU
How do I get Windows Environment Variable USERNAME from an Intranet App?
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngfreeforall' list.


chris
I've tried using the Environment class, but the UserName property returns
ASPNET, the windows user that started the thread. I've tried other
combinations, such as using a WindowsIdentity to populate a WindowsPrincipal
object, but with the same end result. I would like to get the
%USERNAME% environment variable to transparently identify the current user
of an intranet app. I'd like to do this without authenticating the user, as
they would already have logged in to our intranet to use their computer.

TIA,

-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com

Reply to this message...
 
    
Barry J. Akester
Try this...

lblLabel.Text =3D User.Identity.Name;

Barry

-----Original Message-----
From: chris [mailto:Click here to reveal e-mail address]
Sent: Monday, August 12, 2002 1:22 PM
To: aspngfreeforall
Subject: [aspngfreeforall] How do I get Windows Environment Variable
USERNAME from an Intranet App?

I've tried using the Environment class, but the UserName property
returns
ASPNET, the windows user that started the thread. I've tried other
combinations, such as using a WindowsIdentity to populate a
WindowsPrincipal
object, but with the same end result. I would like to get the
%USERNAME% environment variable to transparently identify the current
user
of an intranet app. I'd like to do this without authenticating the user,
as
they would already have logged in to our intranet to use their computer.

TIA,

-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com

| ASP.net DOCS =3D http://www.aspng.com/docs
| [aspngfreeforall] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT
| news://ls.asplists.com =3D NEWSGROUP

Reply to this message...
 
    
chris
Thanks. I researched it a little and found that it doesn't look like it will
work in the context I need it. I ran a trace on the page that I tested this
in, and the stateless nature of http is the killer of this idea. setting
lblLabel.Text = Environment.UserName; output ASPNET, which is the user that
kicked off the threat as far as the computer is concerned. I also tried
building a winform and accessing the same environment variable that way; in
the constructor of Form1:

string user = Environment.UserName;
lblLabel.Text = "Hey there, " + user + "!!";

The result was "Hey there, chris!". So it looks like if I want to use the
scheme I originally planned for, I'll have to use winforms. No thanks, I'll
stick with ASP.NET.

-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com

-----Original Message-----
From: Barry J. Akester [mailto:Click here to reveal e-mail address]
Sent: Monday, August 12, 2002 12:48 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: How do I get Windows Environment Variable
USERNAME from an Intranet App?

Try this...

lblLabel.Text = User.Identity.Name;

Barry

-----Original Message-----
From: chris [mailto:Click here to reveal e-mail address]
Sent: Monday, August 12, 2002 1:22 PM
To: aspngfreeforall
Subject: [aspngfreeforall] How do I get Windows Environment Variable
USERNAME from an Intranet App?

I've tried using the Environment class, but the UserName property
returns
ASPNET, the windows user that started the thread. I've tried other
combinations, such as using a WindowsIdentity to populate a
WindowsPrincipal
object, but with the same end result. I would like to get the
%USERNAME% environment variable to transparently identify the current
user
of an intranet app. I'd like to do this without authenticating the user,
as
they would already have logged in to our intranet to use their computer.

TIA,

-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com

| ASP.net DOCS = http://www.aspng.com/docs
| [aspngfreeforall] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/aspngfreeforall = JOIN/QUIT
| news://ls.asplists.com = NEWSGROUP

| ASP.net DOCS = http://www.aspng.com/docs
| [aspngfreeforall] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/aspngfreeforall = JOIN/QUIT
| news://ls.asplists.com = NEWSGROUP

Reply to this message...
 
    
Srinivasa Sivakumar
Chris,

I think you are trying to get the Windows OS login from ASP.NET.

What you can do it, enable the Windows authentication from the Web.config
file and look at the "AUTH_USER" server variable. May be this will help you.

----- Original Message -----
From: "chris" <Click here to reveal e-mail address>
To: "aspngfreeforall" <Click here to reveal e-mail address>
Sent: Monday, August 12, 2002 2:03 PM
Subject: [aspngfreeforall] RE: How do I get Windows Environment Variable
USERNAME from an Intranet App?

> Thanks. I researched it a little and found that it doesn't look like it
will
> work in the context I need it. I ran a trace on the page that I tested
this
[Original message clipped]

Reply to this message...
 
    
Barry J. Akester
Have you tried turing on impersonation?

<authentication mode=3D"Windows" />=20
<identity impersonate=3D"true" />

Barry

-----Original Message-----
From: chris [mailto:Click here to reveal e-mail address]
Sent: Monday, August 12, 2002 3:03 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: How do I get Windows Environment Variable
USERNAME from an Intranet App?

Thanks. I researched it a little and found that it doesn't look like it
will
work in the context I need it. I ran a trace on the page that I tested
this
in, and the stateless nature of http is the killer of this idea. setting
lblLabel.Text =3D Environment.UserName; output ASPNET, which is the user
that
kicked off the threat as far as the computer is concerned. I also tried
building a winform and accessing the same environment variable that way;
in
the constructor of Form1:

string user =3D Environment.UserName;
lblLabel.Text =3D "Hey there, " + user + "!!";

The result was "Hey there, chris!". So it looks like if I want to use
the
scheme I originally planned for, I'll have to use winforms. No thanks,
I'll
stick with ASP.NET.

-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com

-----Original Message-----
From: Barry J. Akester [mailto:Click here to reveal e-mail address]
Sent: Monday, August 12, 2002 12:48 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: How do I get Windows Environment Variable
USERNAME from an Intranet App?

Try this...

lblLabel.Text =3D User.Identity.Name;

Barry

-----Original Message-----
From: chris [mailto:Click here to reveal e-mail address]
Sent: Monday, August 12, 2002 1:22 PM
To: aspngfreeforall
Subject: [aspngfreeforall] How do I get Windows Environment Variable
USERNAME from an Intranet App?

I've tried using the Environment class, but the UserName property
returns
ASPNET, the windows user that started the thread. I've tried other
combinations, such as using a WindowsIdentity to populate a
WindowsPrincipal
object, but with the same end result. I would like to get the
%USERNAME% environment variable to transparently identify the current
user
of an intranet app. I'd like to do this without authenticating the user,
as
they would already have logged in to our intranet to use their computer.

TIA,

-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com

| ASP.net DOCS =3D http://www.aspng.com/docs
| [aspngfreeforall] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT
| news://ls.asplists.com =3D NEWSGROUP

| ASP.net DOCS =3D http://www.aspng.com/docs
| [aspngfreeforall] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT
| news://ls.asplists.com =3D NEWSGROUP

| ASP.net DOCS =3D http://www.aspng.com/docs
| [aspngfreeforall] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT
| news://ls.asplists.com =3D NEWSGROUP

Reply to this message...
 
 
System.Environment
System.Security.Principal.WindowsIdentity
System.Security.Principal.WindowsPrincipal




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification