473,508 Members | 2,509 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieve current user in Windows

I want to give the access right to my application based on who is
currently logued in Windows. How can I get the current username from
Windows?

TIA
Jul 21 '05 #1
2 1609
System.Environment.UserDomainName/UserName
"Sylvain Larin" <slarin@NOSPAM_gmail.com> wrote in message
news:Oq***************@TK2MSFTNGP09.phx.gbl...
I want to give the access right to my application based on who is currently
logued in Windows. How can I get the current username from Windows?

TIA

Jul 21 '05 #2
Hi

AppDomain myDomain = Thread.GetDomain();

myDomain.SetPrincipalPolicy(PrincipalPolicy.Window sPrincipal);

WindowsPrincipal mWinPrin mWinPrin =
(WindowsPrincipal)Thread.CurrentPrincipal ;

This also allows you to check if the user belongs to certain groups etc,

Henk

"Sylvain Larin" <slarin@NOSPAM_gmail.com> wrote in message
news:Oq***************@TK2MSFTNGP09.phx.gbl...
I want to give the access right to my application based on who is currently
logued in Windows. How can I get the current username from Windows?

TIA

Jul 21 '05 #3

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

Similar topics

2
3648
by: Stefano | last post by:
Hi all, is it possibile to retrieve the current Windows User Handle from ASP code? I would like to retrieve the correspondent in ASP for thi piece of ASP.NET code: WindowsIdentity id =...
79
13963
by: Klaus Bonadt | last post by:
In order to protect software from being copied without licence, I would like to use something like a key, which fits only to the current system. The serial number of the CPU or the current...
8
5362
by: Dutchy | last post by:
Dear reader, In an attempt to obtain the path to the quick-launch-folder in order to create a shortcut to my application-updates during installation , I thought to: 1- check if quick launch...
4
3025
by: Norman Fritag | last post by:
Hi there, I would like to retrieve of a secured database the Username and the group that he / she belongs to, to apply access rights to some button click events, which are accessing forms that...
1
5034
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
2
326
by: Sylvain Larin | last post by:
I want to give the access right to my application based on who is currently logued in Windows. How can I get the current username from Windows? TIA
1
2450
by: John Yung | last post by:
Hi, I have a client (C# MS Excel Project) calling a Web Service to retrieve and update data. One of the business requirement is the client's NT Login ID, IP Address and computer name must be log...
3
1997
by: ipramod | last post by:
Hi, I have a code snippet C# when executed gives the following exception on IE. ___________________________________________________________________ Unable to retrieve the user sid from...
6
3452
by: Dylan Nicholson | last post by:
Running as an administrator, I can retrieve the account password stored by IIS for any application pool (using the WAMUserPass property). But, unsurprisingly, an ASP.NET application running inside...
0
7231
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
7133
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
7336
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
7405
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
7504
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
4724
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...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
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 ...
0
435
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.