簡體   English   中英

可以確定OS用戶是否是使用Applet的管理員?

[英]It is possible to determine if the OS user is administrator using Applets?

可以確定OS用戶是否是使用Applet的管理員(在Java Applet內部)? 怎么樣?

我需要確定用戶是否主要具有Windows的管理員權限,但我還將獲得有關Linux和OSX的信息。

我知道我可以通過“ System.getProperty(“ XXX”)“獲得一些信息,但是對於用戶是否為系統管理員一無所獲。

我通過Javascript獲得的其他信息(操作系統,瀏覽器等)

提前致謝。

我認為不是更好的解決方案(跨平台),但我認為這可能會更好……但是對於大多數情況,卻是解決方案。

private static boolean isAdminWin()
{
    String groups[] = (new com.sun.security.auth.module.NTSystem()).getGroupIDs();
    for (String group : groups) {
      if (group.equals("S-1-5-32-544"))
      return true;
    }
    return false;
}   

public static String getOSName()
{
    return System.getProperty("os.name");
}   


private static boolean isAdminLinux()
{
    return getUserName.equalsIgnoreCase("root"); 
}

public static boolean isAdmin()
{
    if (getOSName().toUpperCase().startsWith("WINDOWS")){
        return isAdminWin();
    } else {
        return isAdminLinux();
    }
}

任何更好的解決方案都歡迎!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM