473,466 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to detect current user of windows

40 New Member
Hello friends,

I want to detect the current user which is logged on to windows system using vb.net.
This is required to notify end user under what privilages application is running.

Please help
Jul 3 '08 #1
10 2384
Curtis Rutland
3,256 Recognized Expert Specialist
Environment.UserName
Jul 3 '08 #2
cloud255
427 Recognized Expert Contributor
One day ...

people started consulting text books before posting questions
and magically the forum only consisted of questions that actually require
experience and logic to solve ...

one day ...
Jul 3 '08 #3
Curtis Rutland
3,256 Recognized Expert Specialist
One day ...

people started consulting text books before posting questions
and magically the forum only consisted of questions that actually require
experience and logic to solve ...

one day ...
You said it, bro. The only reason I bothered answering this one is because I knew it off the top of my head and it literally took two words.
Jul 3 '08 #4
vijayB
40 New Member
One day ...

people started consulting text books before posting questions
and magically the forum only consisted of questions that actually require
experience and logic to solve ...

one day ...
Thanks for the help friendzzzzz
But this is not the solution I was looking for. I know we can get current user name using Environment.
What I was looking for is, current user, i.e., whether the current user is having administrator privilages or it is a restricted account.

Anyways, I have found the solution for this, yesterday itself.
Thanks once again for your valuable help.
Jul 4 '08 #5
alag20
84 New Member
Thanks for the help friendzzzzz
But this is not the solution I was looking for. I know we can get current user name using Environment.
What I was looking for is, current user, i.e., whether the current user is having administrator privilages or it is a restricted account.

Anyways, I have found the solution for this, yesterday itself.
Thanks once again for your valuable help.
We are happy that you found your solution. Though your question seemed as if you wanted to get their name rather than their rights!
Jul 4 '08 #6
vijayB
40 New Member
We are happy that you found your solution. Though your question seemed as if you wanted to get their name rather than their rights!

Ya, I m really sorry. Next time I will be more specific.
Thanks.
Jul 4 '08 #7
Curtis Rutland
3,256 Recognized Expert Specialist
If you don't mind, post your solution. That way, anyone else searching for the same kind of help will be able to get the help they need as well.

Thanks.
Jul 4 '08 #8
vijayB
40 New Member
If you don't mind, post your solution. That way, anyone else searching for the same kind of help will be able to get the help they need as well.

Thanks.

Ya sure, it will be my pleasure.
Here is the solution;

Function IsAdministrator() As Boolean

System.AppDomain.CurrentDomain.SetPrincipalPolicyS ystem.Security.Principal.PrincipalPolicy.WindowsPr incipal)
Dim WP As System.Security.Principal.WindowsPrincipal
WP = System.Threading.Thread.CurrentPrincipal
Return WP.IsInRole(System.Security.Principal.WindowsBuilt InRole.Administrator)

End Function

One just needs to call this function, to get current role of administrator.
Jul 7 '08 #9
Curtis Rutland
3,256 Recognized Expert Specialist
Thanks for posting it.
Jul 7 '08 #10
Daxthecon
63 New Member
I know what you thought the original question was is easy and in a book but I honestly forgot it and I don't have the book on me. Could anyone reference a google search real quick to help me find the answer to the original question(a list of those codes to gather the information that the windows authentication stores and transfers). It would be greatly appreciated. I'm in such a mind fog right now. Please forgive me.
Jul 7 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Martin Clark | last post by:
Hi, I have a C# Windows .net application (not asp.net) which uses a datagrid to display information. The datagrid is populated from a DataView, in which I specify a sort order ("ORDER BY...
23
by: David McCulloch | last post by:
QUESTION-1: How can I detect if Norton Internet Security is blocking pop-ups? QUESTION-2a: How could I know if a particular JavaScript function has been declared? QUESTION-2b: How could I...
5
by: John Lee | last post by:
Hi, I have a component with some static public methods and is it possible from inside my method to decide if my component is invoked by an ASP.NET application (such as web service) or a windows...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
9
by: Rich | last post by:
Please help. Looking for a script to detect and display what version of Windows a user is running. Thanks in advance. Rich
6
by: Fred Hedges | last post by:
Using .NET 1.1, I need to be able to detect if Themes are enabled or disabled, not for a specific application, but for the system as a whole (ie. the current user). The reason I need to be able to...
4
by: Uldis Bojars | last post by:
Hi! How can Javascript code detect if a user has been authenticated to see a page, that is, if he has entered a username and password for HTTP authentification to see the current page. Possibly...
12
by: Phil | last post by:
I can check for MdiChildren.Length=0, but which event handler should I put this in to detect when a child window is closed? TIA Phil.
0
by: =?Utf-8?B?am1hZ2FyYW0=?= | last post by:
My program needs to do X when someone 'starts using' their Windows user account, and it should do Y when they 'stop using' their Windows user account. By 'starts using' I mean they log on, unlock...
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
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
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...
1
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.