LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get current windows user's group and permissions

I am writing an application that will be running under Windows XP. Upon the startup of my application I need to get the current loged in user name, on which group it belongs to and what  are his permissions. Can someone help please?

Edgar
0 Kudos
Message 1 of 5
(4,810 Views)

You can use GetCurrentUser function from the Programmer's Toolbox to obtain the name the user is logged in: this function uses SDK GetUserName function.

I am afraid that getting the user permissions will involve heavily digging into system informations, registry and SDK functions: a long way I'm not able to drive you through... Smiley Sad



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 5
(4,792 Views)
Thanks. Does anyone know how to get the group name of the current user? 
0 Kudos
Message 3 of 5
(4,775 Views)
Hey Edgar,

As Roberto mentioned in general this can get very complicated.  I think I may have found an example on the web that gets the user groups, but this assumes you are using Windows Active Directories for your permissions.  It also looks like it is in C++.

For more information, I would recommend trying to take a look at the MSDN.  Hope this helps.

Example of getting user groups
Pat P.
Software Engineer
National Instruments
0 Kudos
Message 4 of 5
(4,756 Views)
I recall writing a "shutdown" DLL module years ago that used the "access token" feature deep down at the NT internal API call level.  To quote from the MSDN site for "access token" from their security glossary found at: http://msdn2.microsoft.com/en-us/library/ms721532.aspx
 
-----------------------------
 
access token
An access token contains the security information for a logon session. The system creates an access token when a user logs on, and every process executed on behalf of the user has a copy of the token. The token identifies the user, the user's groups, and the user's privileges. The system uses the token to control access to securable objects and to control the ability of the user to perform various system-related operations on the local computer. There are two kinds of access token, primary and impersonation.

See also impersonation token, primary token, privilege, process, and security identifier.

-----------------------------

I found the original source code example I once heavily borrowed from for my "shutdown" module, it can be found at the following URL.  This one shows how use the access token in order to perform a system shutdown of an NT system.  This MSDN article is called "How to Shut Down the System" and is located at: http://msdn2.microsoft.com/en-us/library/aa376871.aspx

Jumper Bones

--
To whom it may concern: My alias is also my nickname, I've had it since I was a (very) skinny basketball-playing teen. OK, so I've got a 38 inch waist now, but my hometown friends haven't shaken that appellation for me. I trust that you will someday be OK with that alias, as I have been with that nickname.
0 Kudos
Message 5 of 5
(4,733 Views)