Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2490 > unrolled thread

Re: How to check if User has admin privileges or not ?

Started byakinny@gmail.com
First post2013-02-11 13:19 -0800
Last post2013-02-17 14:37 -0800
Articles 3 — 3 participants

Back to article view | Back to comp.lang.java.help

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to check if User has admin privileges or not ? akinny@gmail.com - 2013-02-11 13:19 -0800
    Re: How to check if User has admin privileges or not ? Lew <lewbloch@gmail.com> - 2013-02-11 14:00 -0800
    Re: How to check if User has admin privileges or not ? Roedy Green <see_website@mindprod.com.invalid> - 2013-02-17 14:37 -0800

#2490 — Re: How to check if User has admin privileges or not ?

Fromakinny@gmail.com
Date2013-02-11 13:19 -0800
SubjectRe: How to check if User has admin privileges or not ?
Message-ID<eb5757a6-fdee-49d0-b8bc-a7dfd3fcf42a@googlegroups.com>
On Friday, October 9, 2009 2:26:45 AM UTC-4, Matrixinline wrote:
> Hi All,
> 
> Can we check the user has admin privileges or not on the local system
> through Java ?
> Please let me know if you know any hint about it ?
> 
> thanks
> Anup

Anup did you find a solution to this? I am running into similar issues please let me know. I would appreciate your help.

Java User

[toc] | [next] | [standalone]


#2491

FromLew <lewbloch@gmail.com>
Date2013-02-11 14:00 -0800
Message-ID<6600bb46-93e7-4890-a8f5-17bfc421cb80@googlegroups.com>
In reply to#2490
aki...@gmail.com wrote:
> Matrixinline wrote:
>> Can we check the user has admin privileges or not on the local system
>> through Java ?
> 
> Anup did you find a solution to this? I am running into similar issues please let me know. I would appreciate your help.

It is unlikely that Anup will answer after over four years. You would have been better off just 
asking your question in the newsgroup.

You can use JNI, but why should Java know if a user has admin privileges? That is system-specific, 
and not really Java's job.

Even if a user has admin privileges, the program might be restricted from performing certain actions.

The usual means is to try what you need to do and catch exceptions. Warn the user if they're running 
the program with insufficient privilege or whatever.

You could also RTFM for API calls that might help you.

This might, for example, turn up 
http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#exec(java.lang.String)
and related calls that would let you call out to the system to determine rights.

Do you know how to determine the user's rights with OS-specific utilities?

Again, next time just start a new thread. Years-old threads aren't likely to be much help.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#2507

FromRoedy Green <see_website@mindprod.com.invalid>
Date2013-02-17 14:37 -0800
Message-ID<mjm2i8l0m8fu7rsj38cgj8905pfak9755t@4ax.com>
In reply to#2490
On Mon, 11 Feb 2013 13:19:38 -0800 (PST), akinny@gmail.com wrote,
quoted or indirectly quoted someone who said :

>> Can we check the user has admin privileges or not on the local system
>> through Java ?
>> Please let me know if you know any hint about it ?
>> 
>> thanks
>> Anup
>
>Anup did you find a solution to this? I am running into similar issues please let me know. I would appreciate your help.

Java's scheme for handling this sort of thing is called Permissions.
You can ask "Do I have permission to do this specific thing e.g. write
this file"  Or you can try to do it and get an exception.  You might
be able to use this rather than knowing the Unix status.
If you need the Unix status, that is platform specific and can't very
well be part of Java.  You would need JNI to access it.

see http://mindprod.com/jgloss/jni.html
http://mindprod.com/jgloss/permission.html

-- 
Roedy Green Canadian Mind Products http://mindprod.com
The first 90% of the code accounts for the first 90% of the development time.
The remaining 10% of the code accounts for the other 90% of the development 
time. 
~ Tom Cargill  Ninety-ninety Law 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.help


csiph-web