如何知道来宾用户是否正在运行应用程序 - C#?

发布于 2024-09-07 02:16:04 字数 68 浏览 2 评论 0原文

我有一个 winForm 应用程序,我想知道访客用户正在运行它。 我怎样才能通过c#代码知道它?

谢谢。

I have a winForm application and I want to know of a guest user is running it.
how can I know it by c# code?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

晨曦÷微暖 2024-09-14 02:16:04

这是巴里所说的优化版本。

   if (System.Security.Principal.WindowsIdentity.GetCurrent().IsGuest)
   {
     //User is Guest
   }

Here's an optimized version of what Barry said.

   if (System.Security.Principal.WindowsIdentity.GetCurrent().IsGuest)
   {
     //User is Guest
   }
客…行舟 2024-09-14 02:16:04
if (System.Security.Principal.WindowsIdentity.GetCurrent().IsGuest == true)
   {
     //User is Guest
   }
if (System.Security.Principal.WindowsIdentity.GetCurrent().IsGuest == true)
   {
     //User is Guest
   }
迷你仙 2024-09-14 02:16:04

这完全取决于您的用户的设置方式。
您可以使用组成员身份来确定用户是否是来宾,或者他们可能正在使用来宾帐户(尽管某些组织可能会禁用该帐户)。

That would depend entirely on how your users are setup.
You could use group membership to determine if a user is a Guest or they might be using the Guest account (although some organisations might disable that one).

坚持沉默 2024-09-14 02:16:04

您使用域身份验证吗?
如果您使用域身份验证,请获取当前用户详细信息

Environment.UserName or Enviroenment.UserDomainName;

并检查用户是否是会员。

Are you using Domain Auth?
If you are using Domain Auth, get the current user details with

Environment.UserName or Enviroenment.UserDomainName;

and check if user is a member or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文