【问题标题】:Your to get the windows installation SID in c#?您要在 c# 中获取 Windows 安装 SID?
【发布时间】:2016-08-22 05:18:51
【问题描述】:

我知道这个问题在 SO 上已经被问过很多次了,但没有一个回答我的问题。 我从 Comptiat A+ 的研究中了解到,在使用自动(无人值守)安装时,技术人员总是必须返回并更改 MACHINE SID,然后才能在每台机器上激活操作系统。似乎有很多关于如何通过网络获取 SID 等问题,但我知道还有一个机器 SID 无法更改。对于那些使用过 Fix-It Utilities 启动盘的人来说,有一个按钮,“更改 SID”,如果它已经激活,它将导致 Windows 无法启动。

我的问题与this 类似,但他的问题从未真正得到回答。我的问题是,如何使用 c# 获取 MACHINE Windows 安装 SID。

【问题讨论】:

    标签: c# windows sid


    【解决方案1】:

    嗯,这取决于您想要哪个计算机 SID(说真的!)。有本地计算机自己使用的SID...为此,您只需要获取本地Administrator用户的SID,并将末尾的“-500”去掉即可获得计算机的SID。

    在 .NET 3.5 上的 C# 中:

    using System;
    using System.Security.Principal;
    using System.DirectoryServices;
    using System.Linq;
    public static SecurityIdentifier GetComputerSid()
    {
        return new SecurityIdentifier((byte[])new DirectoryEntry(string.Format("WinNT://{0},Computer", Environment.MachineName)).Children.Cast<DirectoryEntry>().First().InvokeGet("objectSID"), 0).AccountDomainSid;
    }
    

    另一方面,Active Directory 使用 SID 来识别每个域成员计算机...您通过获取域中机器帐户的 SID 来获取该 SID - 以美元符号结尾的那个。

    【讨论】:

    • @JABFreeware 根据维基百科:In the context of the Microsoft Windows NT line of operating systems, a Security Identifier (commonly abbreviated SID) is a unique, immutable identifier of a user, user group, or other security principal.In other words, duplicated SIDs are usually not a problem with Microsoft Windows systems.
    • 基本上没有合法的Windows安装可以共享相同的密钥:) 谢谢+1。这应该很好用!!!
    • 伟大的专业知识!此本地计算机 SID 是否会随着 Windows 的新安装而改变?即它是特定于操作系统实例的,还是基于硬件的?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-22
    • 2017-04-25
    • 1970-01-01
    • 1970-01-01
    • 2022-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多