您获得在C#中的Windows安装SID? [英] Your to get the windows installation SID in c#?

查看:131
本文介绍了您获得在C#中的Windows安装SID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题已经被问过很多次左右,但他们没有回答我的问题。
我从为Comptiat A +学习知道,使用自动时(无人值守)安装的技术人员总是要回去换机器SID可以在每台机器上启动操作系统之前。似乎有很多有关如何获得与网络,这样的SID的问题,但我知道有也是不能更改的计算机SID。对于那些你们谁使用修正 - It工具的启动盘,有一个按钮,更改SID,这将让窗户无法引导其是否已经激活。

I know this question has been asked many times on SO, but none of them answer my question. I know from studying for the Comptiat A+ that when using automated (unattended) installations techs always have to go back and change the MACHINE SID before the OS can be activated on each machine. There seems to be a lot of questions about how to get the SID with networks and such, but I know there is also a machine SID that cant be changed. For those of you who have used Fix-It Utilities boot disk, there is a button, "change SID" and that will make windows fail to boot if its already activated.

我的问题是类似的这个的一个,但他的问题从来没有真正回答。我的问题是,我该如何使用C#拿到机器的Windows安装SID。

My question is similar to this one, but his question was never really answered. My question is, how do I get the MACHINE Windows Installation SID using c#.

推荐答案

嗯,这取决于你想要的计算机SID (认真!)。有本地计算机用于自身的SID ......对于这一点,你只需要获得本地管理员用户的SID,并删除-500从最终拿到电脑的SID。

Well, it depends which computer SID you want (seriously!). There's the SID that the local computer uses for itself... For this, you just need to get the SID of the local Administrator user, and remove the "-500" from the end to get the computer's SID.

在C#在.NET 3.5:

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获取 - 以美元符号结束一个

On the other hand, there's the SID that Active Directory uses to identify each domain member computer... That one you fetch by getting the SID of the machine account in the domain--the one that ends with a dollar sign.

这篇关于您获得在C#中的Windows安装SID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆