views:

49

answers:

1

We use Configuration managar to install operating systems, that for some genius reason does not have a simple way to set rules for machine names.

So im looking for a C# API that allows me to change the computer name ( NETBIOS) and change it in Active directory at the same time. I want to set the name AFTER im connected to AD so i can check if the machine had a old name and belonged to a none spesfic OU.

I have tried:

[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
static extern bool SetComputerNameEx(COMPUTER_NAME_FORMAT NameType,string lpBuffer);

This one does change the local machine name, but this will corrupt the AD connection.

+1  A: 

For all Windows OSes since XP you can simply use the command-line program NETDOM.EXE to change the computer name on both the machine itself and Active Directory... no programming required.

ewall