LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Checking user's privileges (group).

Trying to implement an Admin configuration on a program and I want the VI to check what group the current user is logged in on.  I have searched the registry in vain and only found out where the User Name is located.
 
Does anyone know where/if this property is located in the registry or is there another way to implement this check using .NET?  (Heard that was gonna be a pain though)
 
TIA
 
Sincerely,
 
 
Jason
0 Kudos
Message 1 of 12
(5,359 Views)
Your question is not totally clear. What do you mean by "check what group the current user is logged in on"? Are you referring to a Windows group? Is the computer in a domain? Is it an NT domain, or Active Directory? Or are you referring to the local computer's groups? For .NET you need the WindowsPrincipal class. It has a method called "IsInRole".
Message 2 of 12
(5,348 Views)

I want to be able to check the Group the user is in (Admin, Standard User, Guest, etc.).

So if a Standard User logs into the computer they will not be able to acess the Admin option on the VI because of a check that is done to verify if the user has the appropriate permissions.  Where as if an Administrator logged in then they would be able to acess the Admin option on the VI.

Message Edited by B5J20 on 07-27-2006 10:55 AM

0 Kudos
Message 3 of 12
(5,344 Views)
What you're asking for isn't particularly easy, unfortunately. The Windows API has a few functions for this, but based on what I've seen they seem to be a real pain to try to use. There's an example on devX.com that shows you how to to use these functions. You may want to simplify that example into a simple DLL that you call from LabVIEW.

As far as .NET is concerned, it's a lot easier, but for some reason, you can't access the required class from LabVIEW. The "IsInRole" method I mentioned before is the one you want, and in a VB.NET or C# app you can do what you need in about 4 lines of code. So, if you want to go this route you can write a really simple DLL that has just one function that gets you the information you need.

A completely different track is to not use the Windows groups and have your own user management. Not that difficult to do.

Wish I could give you a perfect answer, but I don't think there is one for this.
Message 4 of 12
(5,333 Views)
0 Kudos
Message 5 of 12
(5,318 Views)
I can seem to access the class just fine. Here's a screenshot and copy of my code. Does this work on your end?

Message Edited by Jarrod S. on 07-28-2006 08:49 AM

Jarrod S.
National Instruments
Download All
0 Kudos
Message 6 of 12
(5,313 Views)
Well, I wasn't trying to access the mscorlib assembly. I was trying to access the System.Security assembly.

I did, however, try your code. I get an error code 1172, "Incorrect function", at the constructor node. Does the code work on your machine?
0 Kudos
Message 7 of 12
(5,307 Views)

I get the same error when I run it on my machine.

 




Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 8 of 12
(5,300 Views)

To be honest I couldn't ever get the sUserPrincipalName correct for some reason. I wasn't getting the incorrect function error. I did find a better solution, however, that just uses the current user, eliminating the need to specify it by name. How does this work?

Jarrod S.
National Instruments
Message 9 of 12
(5,299 Views)

Hey this works great,

Thanks




Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 10 of 12
(5,297 Views)