如何检查用户在任何系统上的访问级别 [英] How to check access level of user on any system

查看:132
本文介绍了如何检查用户在任何系统上的访问级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的RCP应用程序中,我们在菜单贡献下新增了一个菜单作为命令。现在我们要根据登录到系统的用户来启用或禁用这个新菜单。基本上,我们只想为管理员登录启用菜单,而不是为任何其他用户启用菜单。

In our RCP application we have newly added a menu as command under menu contributions. Now that we want to enable or disable this new menu depending the user who has logged on to the system. Basically we want to enable the menu only for the Administrator login and not for any other user.

如何实现?

提前感谢

推荐答案

您可以检索登录的用户名称:

You can retrieve the logged in user's name as :

String user=System.getProperty("user.name"); 

您可以检索登录的用户详细信息 如java-forums.org中所述

You can retrieve the logged in user detail as described in java-forums.org:

public static void ntSystemDetails() {

    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());
    for (String group : NTSystem.getGroupIDs()) {
        System.out.println("Groups  " + group);
    }
}

如果您收到以下错误:

   NTSystem is not accessible due to restriction on required library ...

然后,按照 https ://stackoverflow.com/a/2174607/607637

了解Windows操作系统中的知名安全标识符 ,请参阅此页面 http://support.microsoft.com/kb/243330

To know about Well-known security identifiers in Windows operating systems, see this page http://support.microsoft.com/kb/243330

然后
我希望你得到足够的提示。

Then I hope that you get enough hints.

这篇关于如何检查用户在任何系统上的访问级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆