How can I connect a Windows 8 PC to a Samba domain

I am using Samba 3, and want to join my Windows 8 PC to the Samba domain.

Windows 8 cannot join out of the box, so I added the following registry entries:

HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters
        DWORD DomainCompatibilityMode 1
        DWORD DNSNameResolutionRequired 0 

And now it talks to the Samba server ok, however I get the following error: Samba Windows 8 error

And I notice that the machine name created on the samba server does not match its name:

win-8jq3fg1n74e$:x:30003:30003:Machine:/var/lib/nobody:/bin/false

It is like it is using an internal name.

The following is the error in the smb.log

[2012/10/21 14:26:16.099520,  0] passdb/pdb_interface.c:348(pdb_default_create_user) _samr_create_user: Running the command `/usr/sbin/useradd  -c Machine -d /var/lib/nobody -s /bin/false win-8jq3fg1n74e$' gave 9        
[2012/10/21 14:26:28.143224,  0] lib/util_sock.c:474(read_fd_with_timeout)
[2012/10/21 14:26:28.143420,  0] lib/util_sock.c:1441(get_peer_addr_internal)
  getpeername failed. Error was Transport endpoint is not  connected
  read_fd_with_timeout: client 0.0.0.0 read error = Connection reset by peer.

There are two things I did to get this to work, though I believe the first might be all that is required:

  1. It appears that while you set the machine name fairly early on in the setup, it doesn't actually take until another reboot. So internally it is win-xxxxxxxxxxx until a reboot where it then takes on the machine name defined in the Computer Name dialog above.

  2. Setting a primary suffix in the Computer Name dialog

With the registry settings in the OP and an additional boot (and possibly ensuring there is a suffix), joining Samba domains works fine.