Results 1 to 8 of 8
- 02-04-2010, 12:44 PM #1
Member
- Join Date
- Feb 2010
- Posts
- 7
- Rep Power
- 0
- 02-04-2010, 02:33 PM #2
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
This maybe?
Java Code:System.out.println( System.getProperty("user.name") );
- 02-04-2010, 02:51 PM #3
Member
- Join Date
- Feb 2010
- Posts
- 7
- Rep Power
- 0
Thanks FON for your quick reply.
System.out.println( System.getProperty("user.name") );
Is displays only username not role. I have to identify that user belongs to Admin group or not.
- 02-04-2010, 05:23 PM #4
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
Ok, this is about using
Java Authentication and Authorization Service (JAAS)
Here is some code and links to get you starting
I hope this will help
but you have to do further research by yourself ;)
In rt.jar that comes with your virtual machine
there is package : "com.sun.security.auth"
as SUN's impl. of JAAS
In order for this code sample to run in your IDE
be sure that u have set classpath right
(maybe you have to change your system library)
Output is:Java Code:com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem(); System.out.println(NTSystem.getName()); System.out.println(NTSystem.getDomain()); System.out.println(NTSystem.getDomainSID()); System.out.println(NTSystem.getImpersonationToken()); System.out.println(NTSystem.getPrimaryGroupID()); System.out.println(NTSystem.getUserSID()); System.out.println(NTSystem.getGroupIDs());
Java Code:dren JAVAMACHINE S-1-5-21-299502267-220523388-725345543 3696 S-1-5-21-299502267-220523388-725345543-513 S-1-5-21-299502267-220523388-725345543-1003 [Ljava.lang.String;@19821f
Now those S-1-5 are security identifiers
which maybe could help you resolve issuse like user groups and permissions.
Here is link for their meaning:
Well-known security identifiers in Windows operating systems
I don't know if this is good approach
but at least it will give you some ideas :)
cheers!
- 02-05-2010, 01:22 PM #5
Member
- Join Date
- Feb 2010
- Posts
- 7
- Rep Power
- 0
helpful information
Hi FON,
Thanks a lot for the information. It is helpful.
I have came across another solution is implementing Windows API. But for that we have to use Jnative or JNI API.
Our current application is already using Jnative API. Looking for an example to implement CheckTokenMembership() using Jnative API.
I know that this not right forum to post Jnative related questions.
CheckTokenMembership Function (Windows)
-Ravi T
- 02-05-2010, 03:37 PM #6
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
Well in this context i believe it is right place.
Don't hesitate to post your solution at the end of your research
I'm pretty sure the are people here how would like to know solution
for this interesting problem.
A question for you:
are those SID's in link I posted enough to solve your problem,
or to be more precise :
if in my code I check some user's SID and that SID IS NOT type.. :
SID: S-1-5-21domain-500
Name: Administrator
Description: A user account for the system administrator. By default, it is the only user account that is given full control over the system.
...is it good enough to restrict this user?
thanx for your answer in advance!
good luck!
- 02-11-2010, 08:40 AM #7
Member
- Join Date
- Feb 2010
- Posts
- 7
- Rep Power
- 0
It is working fine
Hi FON,
Thanks a lot for your support.
I'm planning to user following SID to detect admin rights. Please see the description, i.e every domain admin group also part of this group. Considering this group for validation.
I have tested on multiple XP systems. It is as it expected.
SID: S-1-5-32-544
Name: Administrators
Description: A built-in group. After the initial installation of the operating system, the only member of the group is the Administrator account. When a computer joins a domain, the Domain Admins group is added to the Administrators group. When a server becomes a domain controller, the Enterprise Admins group also is added to the Administrators group.
public static boolean isAdmin()
{
com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem();}
String groups[] = NTSystem.getGroupIDs();
for(String group : groups)
{
if( group.equals("S-1-5-32-544"))
return true;
}
return false;
- 02-11-2010, 01:25 PM #8
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
Hi thalupularavi,
you are very welcome,
I'm so glad you find a solution for your problem.
A lot of people start some Thread, post their problem, and after some time
they just leave it like that, so thread stays useless.
So thank you very much for sharing final solution with us
that's what forum should be about.
It takes time and lot of machines to test the solution for this sort of problem, I hope your tests end well and that check of
SID: S-1-5-32-544 is good enough for this purpose.
hope to hear more from your in coming days
cheers :)
Similar Threads
-
How to manage a Session for a user in Emailing system using JAVA ?
By balap_chander in forum Java ServletReplies: 1Last Post: 08-27-2009, 11:16 AM -
detecting location of ipaddress
By tej in forum NetworkingReplies: 5Last Post: 05-08-2009, 02:37 PM -
Detecting software installed in PC
By Lukalo in forum Advanced JavaReplies: 3Last Post: 02-13-2009, 03:04 AM -
Detecting user movement of a JFrame
By dklett in forum AWT / SwingReplies: 4Last Post: 08-27-2008, 07:01 AM -
Detecting Browser Settings
By arupranjans in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 07-31-2007, 02:31 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks