C# 远程服务器许可证唯一标识符

发布于 2024-11-05 05:06:11 字数 310 浏览 0 评论 0原文

我正在为我们的程序编写一个基本的许可课程。我想将此许可证绑定到服务器,这样他们就无法移动许可证并期望它能够工作。

该程序通过服务器上的共享驱动器在每个工作站上本地运行。我们的大多数客户都在点对点网络上运行,因为他们是较小的公司并且只有几台计算机。

我想获得服务器的唯一标识符,以便当工作站启动应用程序时,它将验证许可证是否在正确的服务器上运行。

我几乎已经完成了课程,但我无法弄清楚如何获取服务器的一致唯一标识符。

另外,我是用 C#.net 编写的。

有什么建议吗?

谢谢!

I am writing a basic licensing class for our program. I would like to tie this license to the server so they cannot move the license and expect it to work.

The program is run locally on each workstation from a shared drive on the server. Majority of our customers run on a peer 2 peer network since they are smaller companies and only have a few computers.

I'd like to get a unique identifier for the server so when the workstation starts the application, it will verify the license is running against the correct server.

I have almost completed the class except I cannot figure out how to get a consistent unique identifier for the server.

Also, I am writing this in C#.net.

Any suggestions?

Thanks!

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

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

发布评论

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

评论(2

嗼ふ静 2024-11-12 05:06:11

听起来您想要计算机的安全标识符 (SID)。

string fqdn = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).HostName;

int firstDot = fqdn.IndexOf('.');
string host = fqdn.Substring(0, firstDot);
string domain = fqdn.Substring(firstDot + 1);

NTAccount account = new NTAccount(domain, host + "$");
SecurityIdentifier sid =
    (SecurityIdentifier)account.Translate(typeof(SecurityIdentifier));

// we're done, show the results:
Console.WriteLine(account.Value);
Console.WriteLine(sid.Value);

(用于获取从 此处,但它有效。)

参考下面的讨论,对用户来说最“温和”的方式是通过主机名进行许可。这就是 dotNetCharting 的做法(或者几年前我购买他们的软件时就是这样做的)。基于硬件或计算机的 SID 很容易发生更改,并且当硬件更改或重新安装操作系统时需要重新许可/激活。上面代码中的第一行返回完全限定的域,您可以将其用于此目的。

Sounds like you want the computer's Security Identifier (SID).

string fqdn = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).HostName;

int firstDot = fqdn.IndexOf('.');
string host = fqdn.Substring(0, firstDot);
string domain = fqdn.Substring(firstDot + 1);

NTAccount account = new NTAccount(domain, host + "$");
SecurityIdentifier sid =
    (SecurityIdentifier)account.Translate(typeof(SecurityIdentifier));

// we're done, show the results:
Console.WriteLine(account.Value);
Console.WriteLine(sid.Value);

(Code to get identifier copied from here. Tested, though. It works.)

In reference to the discussion below, the way that would be most "gentle" to your users is to license by host name. This is the way dotNetCharting does it (or did it a few years ago when I bought their software). Basing on hardware or the computer's SID is prone to change and necessitates relicensing/activation when the hardware changes or the OS is re-installed. The first line in the code above returns the fully qualified domain, which you could use for this purpose.

雨落星ぅ辰 2024-11-12 05:06:11

获取CPU、系统硬盘和主板的序列号,然后对其进行哈希处理。当然,您可以混淆您所获取的硬件序列号/型号信息。

有关如何获取信息的 codeproject 文章: http://www.codeproject.com/ KB/system/GetHardwareInformation.aspx

Get the serial number of the CPU and system harddrive and mainboard then hash it. You can off course mix up what hardware serials/models information you take.

Article on codeproject that explains how to get the information: http://www.codeproject.com/KB/system/GetHardwareInformation.aspx

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