Do you want to set the SID for installing Windows in C #?

I know this question has been asked many times on SO, but none of them answered my question. I know from studying Comptiat A + that when using automated (unattended) installation technologies, you always need 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 on how to get the SID with networks, etc., but I know that there are also SID machines that cannot be changed. For those of you who have used the Fix-It Utilities boot disk, there is a β€œchange SID” button, which will make Windows unable to boot if it is already activated.

My question is similar to this , but never answered his question. My question is: how do I get the SIN to install MACHINE using C #.

+4
source share
1 answer

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

In C # on .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; } 

On the other hand, there is a SID that Active Directory uses to identify each member computer of the domain ... The one you retrieve when you receive the SID of the computer account in the domain is the one that ends with a dollar sign.

+5
source

All Articles