473,668 Members | 2,552 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 1624
System.Environm ent.UserDomainN ame/UserName
"Sylvain Larin" <slarin@NOSPAM_ gmail.com> wrote in message
news:Oq******** *******@TK2MSFT NGP09.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.GetDomai n();

myDomain.SetPri ncipalPolicy(Pr incipalPolicy.W indowsPrincipal );

WindowsPrincipa l mWinPrin mWinPrin =
(WindowsPrincip al)Thread.Curre ntPrincipal ;

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******** *******@TK2MSFT NGP09.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
3657
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 = HttpContext.Current.User.Identity as WindowsIdentity; if (id != null) {
79
14064
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 operating system would be appropriate. However, I do not know how to retrieve the information. Could you help? Klaus
8
5371
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 is used by the user 2- check if a link to my application is there 3- if so, obtain the path (ANY PATH) to the quick-launch-folder from existing button(s)
4
3048
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 the User Usergroup doesn't have access to. Any idea how I would go on about it?? kind regards
1
5051
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 with the ADSI NT Provider and only supported in the LDAP Provider. So given an UserId (UID) how can I read the First Name and Last Name using LDAP Provider. If anybody can help me with a C# sample code it would of great help. Thanks in advance.
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
2464
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 for each web service method call. To get client information using integrated Windows authentication with ASP.NET client. You need to disable "Anonymous Access" and enable "Integrated Windows authentication". IE will automatically pass in the...
3
2004
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 context. This is typically caused by the context not yet being set. Description: An unhandled exception occurred during the execution of
6
3459
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 an application pool that is does not have administrator privileges can't even enumerate the list of application pools. I can access the application pool by hard-coding the name, but even then the WAMUserPass is an empty property value...
0
8459
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8367
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
8889
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8790
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
8570
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,...
1
6206
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
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.