查找当前用户是否为管理员

huangapple go评论85阅读模式
英文:

Find if current user is Admistrator

问题

有没有办法找出当前执行应用程序的用户是否是管理员?

我在 http://golang.org/pkg/os/user/ 上查找了一下,没有找到关于权限的任何信息。

英文:

Is there a way of finding if the current user executing the application is an Administrator?

I looked around http://golang.org/pkg/os/user/ and couldn't find anything about Permissions.

答案1

得分: 1

这更多是一个特定于操作系统的问题。我假设你在谈论Windows,所以我查了一下:http://support.microsoft.com/kb/243330

这篇文章说管理员的SID是:'S-1-5-32-544'。这意味着如果用户在Administrators组中,user.Gid的值将是这个。

此外,似乎还有一个特殊的系统管理员SID为S-1-5-21domain-500。

英文:

This is more of an OS specific question. I assume you are talking about Windows so I looked up: http://support.microsoft.com/kb/243330

This says that the SID of administrators is: 'S-1-5-32-544'. This means that the user.Gid will be that value if in group Administrators.

Also there seems to be a special System Administrator SID of S-1-5-21domain-500.

huangapple
  • 本文由 发表于 2014年3月18日 05:32:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/22465886.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定