如何判断计算机是否属于 C# 中特定 Windows 域的一部分

发布于 2024-08-02 16:46:15 字数 328 浏览 3 评论 0原文

我有一个内部 C# 应用程序,我想开始在外部部署它。我有一些功能只希望内部用户可以使用,但我不想为多个版本而烦恼。我也不想改变内部用户当前使用该程序的方式。

所以,我的想法是: 1) 检查程序运行所在PC的域。如果是我公司的域,那就开启内部功能。该程序可以在与域断开连接并离线运行的 PC 上运行。

2) 在其之上有一个密码选项以启用内部功能。

因此,对于域计算机上的内部用户来说,它看起来与以往完全相同。 对于非域计算机上的内部用户,他们能够打开内部功能。 对于外部用户来说,他们无法获得内部功能。

在 C# 中实现“计算机是域的一部分,即使处于离线状态”的最佳方法是什么?

I've got an internal C# application that I want to start deploying externally. I've got features that I only want available to internal users, but I don't want to bother with multiple releases. I also don't want to change the way that internal users are currently using the program.

So, what I'm thinking is:
1) Check the domain of the PC that the program is running on. If it's my company's domain, then turn on the internal features. The program may run on PCs that are disconnected from the domain and running offline.

2) Have a password option on top of that to enable internal features.

So, for internal users on domain machines, it looks exactly the same as it always did.
For internal users on non-domain machines, they have the ability to turn on the internal features.
For external users, they don't get the internal features.

What's the best way to implement the "is the computer part of a domain, even if offline" in C#?

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

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

发布评论

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

评论(3

晨与橙与城 2024-08-09 16:46:15
Console.WriteLine(Environment.UserDomainName);
Console.WriteLine(Environment.UserDomainName);
‖放下 2024-08-09 16:46:15

我认为它比这更复杂,因为这很容易查找和创建欺骗域。

我建议在您的 LDAP 目录中设置一个特定值,并通过 LDAP 查找该值(可能使用一些加密来使其更加困难)。这将具有您想要的优势,但又不会那么容易被绕过。

它仍然可以被绕过,只是不那么容易。

I think it's more complicated than that, because that would be easy to look for and createa spoofing domain.

I'd suggest setting a specific value in your LDAP directory and looking through LDAP for that value (possibly with some encryption to make it more difficult). This would have the advantage you want without being quite so easily bypassed.

It could still be bypassed, just not quite so easily.

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