473,396 Members | 1,945 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,396 software developers and data experts.

User Identify

When working in the Web, I automatically have access to the
User.Identity.Name property. How do I find the same information in a console
application?

Thanks in advance for your assistance!
Nov 17 '05 #1
2 1721
Jim Heavey wrote:
When working in the Web, I automatically have access to the
User.Identity.Name property. How do I find the same information in a console
application?

Thanks in advance for your assistance!


Is Thread.CurrentPrincipal.Identity.Name what you're looking for?

Jon

Nov 17 '05 #2
It should be noted that this doesn't necessarily represent the user that
is currently logged into the machine. For most cases, this will be the
case, because the current principal will be the windows principal.

However, the principal can be changed to any implementation of
IPrincipal depending on the nature of the application.

For ASP.NET, the principal is set according how access/membership is set
up. If you are using windows authentication, then the principal will be the
WindowsPrincipal representing the logged in user. If you are using forms
based authentication/authorization, then the principal is representative of
that user which is logged in (ASP.NET 2.0 has a much more detailed
architecture for setting this up, using SQL Server to store principal and
role information, or access).

In the end, if you want to get the windows account name associated with
the current thread, you can use the static UserName property on the
Environment class. This will work regardless of what the principal is set
to for the application.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Jim Heavey wrote:
When working in the Web, I automatically have access to the
User.Identity.Name property. How do I find the same information in a
console
application?

Thanks in advance for your assistance!


Is Thread.CurrentPrincipal.Identity.Name what you're looking for?

Jon

Nov 17 '05 #3

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

Similar topics

60
by: Fotios | last post by:
Hi guys, I have put together a flexible client-side user agent detector (written in js). I thought that some of you may find it useful. Code is here: http://fotios.cc/software/ua_detect.htm ...
1
by: edt | last post by:
Is it possible to identify the user (i.e. username) in an intranet (local area network) environment using php? I would like to develop an intranet website with user-dependant information with php...
0
by: Ronald S. Cook | last post by:
I've got everything working with Forms Authentication except for one thing. When a persistent user (i.e. that checked "Remember Me" in the past and therefore now have a cookie) returns to the site,...
3
by: Jim Heavey | last post by:
I am not quites sure which happens first... the Form Load Event for the form or the form load event for the user control. I am wanting to obtain the User.Identify.Name in the UserControl, but I am...
17
by: Alphonse Giambrone | last post by:
I am building a web app for users to add/edit data. They may add/edit several records during a session. When they are done (not necessarily immediately, could be 10 or more minutes later), I need...
7
by: msc | last post by:
Hi guys, How to get the user information like userid written in C language.
7
by: phal | last post by:
Hi I think there are many different browsers to browse to the Internet, how can I write the javascript to identify different browser and display according to the users. Some browser disable the...
2
by: sparks | last post by:
Just died a little db of our time sheets and think that I might have a problem. I just put a pulldown of the employees and a week that they are entering time. Then in a continuous list in a sub...
3
by: shapper | last post by:
Hello, On my web site I have a property, Visitor, which is available for Anonymous users: public class Visitor { public CultureInfo Culture { get; set; } public List<GuidPolls { get; set;...
0
by: abhamjee | last post by:
I have seen posts on how to identify a Blackberry device and this works well. However, has anyone tried to identify the user? The Blackberry server will know who is currently browsing but can this...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...
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,...

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.