How can I add a computer in a domain programmatically (using .NET)?

I need to write a program or script that performs several operations with (or) the server after installing Windows. Among them is adding a server to the domain.

Is there a way to do this programmatically or using a script command?

+5
source share
3 answers

If you want to do this using a domain controller:

Source: net computer \\computername /add

If you want to do this from a workstation:

Source: NETDOM JOIN /DOMAIN:[DOMAINNAME] /USERD:[USERNAME] /PASSWORDD:[PASSWORD]

+2
source

It is not easy if you are writing a program, but it is possible, and you can find relevant code examples.

, . NetUserAdd. http://msdn.microsoft.com/en-us/library/aa370254%28VS.85%29.aspx. , Active Directory (- ) OU, . , ( , . ).

SID , , API LSA, LsaSetTrustedDomainInformation. http://support.microsoft.com/kb/145697.

omputer , , . , , ( ).

P.S. , .

+1

, , , , Samba.

If I remember correctly, the Samba distribution includes a command line utility that does exactly what you want (it can add hosts to the domain); I can’t remember the exact name of the utility, but it should still be there. I think his goal was to automatically transfer the old Windows NT domain to Samba!

0
source

All Articles