Detect If Windows User Has Admin Rights Using Java

While at first glance, Java people may think of using Java Authentication and Authorization Service (JAAS) as the solution to access a Windows user’s rights if one is part of the Administrator group or not, there is actually a Sun implementation of JAAS in Java’s library jar “rt.jar” with a package name of com.sun.security.auth.

The class is called NTSystem and the method below returns true if the user logged in to the Windows workstation has admin rights or none.

The SID S-1-5-32-544 is the id of the Administrator group in the Windows operating system.

Related Posts Plugin for WordPress, Blogger...

3 comments

  1. I am getting following error while writing code in eclipse:
    Access restriction: The method getGroupIDs() from the type NTSystem is not accessible due to restriction on required library C:\Program Files\Java\jre7\lib\rt.jar

    1. @ramanuj: sorry, you’ll have to google that. as i did not encounter that problem so i cannot give a solution

Leave a Reply

Your email address will not be published. Required fields are marked *