Joining a Samba DC to an Existing Active Directory

From SambaWiki
Revision as of 08:14, 2 August 2011 by Wodin (talk | contribs) (→‎Joining the existing domain as a DC: Remove old "net vampire" instructions.)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Samba4 joining a domain as a DC

As of Samba4 alpha11, Samba4 now has the ability to join an existing Active Directory domain as an additional domain controller. The process of joining a Samba4 server to an existing domain is a bit different to provisioning a new domain. This process is the equivalent of the 'dcpromo' command on Windows servers.

This HOWTO will assume you configured and installed Samba in the default location of /usr/local/samba. It assumes you are joining Samba to an existing domain called 'samba.example.com'.

Note that some of the features mentioned in this HOWTO are only available in versions of Samba4 later than alpha12, or using a git checkout from February 26th 2010 or later.

Also note that the following steps are the same regardless of whether you are joining Samba to an existing Windows based domain or an existing Samba based domain.

Getting ready for joining Samba as a DC to an existing domain

You need to build Samba4 as usual, but don't do the provision step. You should remove any existing smb.conf in /usr/local/samba/etc/smb.conf

You should have your existing domain setup correctly as your default realm in /etc/krb5.conf, and you should have these options setup in /etc/krb5.conf:

[libdefaults]
 dns_lookup_realm = true
 dns_lookup_kdc = true
 default_realm = SAMBA.EXAMPLE.COM

You should then test to make sure that DNS and kerberos are setup correctly to point at your existing domain controller. Test that it is all working by trying a kinit as a domain administration:

kinit administrator
Password: XXXXXXXX

Once all that is setup you can move on to the main domain join step

Joining the existing domain as a DC

Run the following command as root:

bin/samba-tool join samba.example.com DC -Uadministrator --realm=samba.example.com

It should show a set of debug messages about replicating the domain contents, like this:

Partition[CN=Configuration,DC=sample,DC=example,DC=com] objects[1596] linked_values[1]

then it will show a message like this:

Joined domain V2 (SID S-1-5-21-3565189888-2228146013-2029845409) as a DC

at this point you have joined your Samba4 server to the existing domain, and you are ready to start your Samba domain controller.

Starting Samba

You start samba as a DC in the same way that you start it as a normal server, just run the command 'samba' from the sbin directory of your installation.

When you first start Samba as a new DC in an existing Windows domain, you may find errors messages like these in the samba log file:

UpdateRefs failed with WERR_DS_DRA_BAD_NC/NT code 0xc00020f8 for 5344d0a6-78a1-4758be69-66d933f1123._msdcs.samba.example.com CN=RID Manager$,CN=System,DC=samba,DC=example,DC=com

This is caused by the Windows domain controller not yet having run its Knowledge Consistency Checker (KCC) which means it has not yer created connections to the new Samba DC.

To fix this, you can either run "repadmin /kcc" on the Windows DC as an administrator, or you can use the Samba net (or samba-tool) command to do the same thing, like this:

bin/net drs kcc -Uadministrator windowsdc.samba.example.com

or, for recent versions of Samba 4:

bin/samba-tool drs kcc -Uadministrator windowsdc.samba.example.com

You should then check that replication between the Windows DC and the Samba DC is working correctly by using:

net drs showrepl

or:

samba-tool drs showrepl
Default-First-Site-Name\Windows
DSA Options: 0x00000001
Site Options: (none)
DSA object GUID: 794640f3-18cf-40ee-a211-a93992b67a64
DSA invocationID: 794640f3-18cf-40ee-a211-a93992b67a64

==== INBOUND NEIGHBORS ====

DC=samba,DC=example,DC=com
       Default-First-Site-Name\SAMBA via RPC
               DSA object GUID: 5344d0a6-78a1-4758-be69-b66d933f1123
               Last attempt @ Fri Feb 26 17:25:41 2010 EST was successful.
               0 consecutive failure(s).
               Last success @ Fri Feb 26 17:25:41 2010 EST

CN=Configuration,DC=samba,DC=example,DC=com
       Default-First-Site-Name\SAMBA via RPC
               DSA object GUID: 5344d0a6-78a1-4758-be69-b66d933f1123
               Last attempt @ Fri Feb 26 17:25:41 2010 EST was successful.
               0 consecutive failure(s).
               Last success @ Fri Feb 26 17:25:41 2010 EST

CN=Schema,CN=Configuration,DC=samba,DC=example,DC=com
       Default-First-Site-Name\SAMBA via RPC
               DSA object GUID: 5344d0a6-78a1-4758-be69-b66d933f1123
               Last attempt @ Fri Feb 26 17:25:41 2010 EST was successful.
               0 consecutive failure(s).
               Last success @ Fri Feb 26 17:25:41 2010 EST

Testing Replication

To check that replication is working correctly between your two domain controllers, try adding a user on the Samba DC using either the Samba command line tools, or the Windows GUI admin tools. Then check that the user shows up within a few seconds on your Windows domain controller.

Similarly, try modifying a user on the Windows domain controller and check that the modifies show up correctly on the Samba server

ldapcmp

You may wish to use ldapcmp to verify that the same data is being served from all domain controllers.

Report your success/failure!

Samba4 as a replicating domain controller is still developing rapidly, and we like to hear from users about their successes and failures. While Samba4 is still in alpha release we would encourage you to report both your successes and failures to the samba-technical mailing list on http://lists.samba.org

Please be aware that Samba4 is not complete, so you should deploy it carefully until it is ready for a non-alpha release.

A note on DNS updates

As of Samba4 alpha12 Samba4 has the ability to automatically update a Windows or bind9 DNS server with the correct set of DNS entries when it becomes a domain controller.

For this to work correctly between Samba and Windows you may find that you need a set of 5 patches to bind9. Those patches are located in the examples/bind9-patches directory of the Samba4 source tree. The patches have been submitted to the bind9 developers and will be incorporated in the future release of bind, but in the meantime you should be able to build bind9 yourself from sources and apply the patches.

The way the automatic DNS updates works is that Samba regularly (every 10 minutes) calls out to the samba_dnsupdate script that is installed along with Samba. That script reads a template file of DNS names to update in the DNS zone from /usr/local/samba/private/dns_update_list.

The contents of this file look like this:

A                                                        ${DNSDOMAIN} $IP
A                                                        ${HOSTNAME} $IP
CNAME ${NTDSGUID}._msdcs.${DNSDOMAIN}                    ${HOSTNAME}
SRV _kerberos._tcp.${SITE}._sites.dc._msdcs.${DNSDOMAIN} ${HOSTNAME} 88
SRV _ldap._tcp.${SITE}._sites.dc._msdcs.${DNSDOMAIN}     ${HOSTNAME} 389
SRV _kerberos._tcp.dc.dc._msdcs.${DNSDOMAIN}             ${HOSTNAME} 88
SRV _ldap._tcp.dc.dc._msdcs.${DNSDOMAIN}                 ${HOSTNAME} 389
SRV _ldap._tcp.${DOMAINGUID}.domains._msdcs.${DNSDOMAIN} ${HOSTNAME} 389
SRV _ldap._tcp.${SITE}._sites.gc._msdcs.${DNSDOMAIN}     ${HOSTNAME} 3268
SRV _ldap._tcp.gc._msdcs.${DNSDOMAIN}                    ${HOSTNAME} 3268
SRV _ldap._tcp.pdc._msdcs.${DNSDOMAIN}                   ${HOSTNAME} 389
SRV _gc._tcp.${SITE}._sites.${DNSDOMAIN}                 ${HOSTNAME} 3268
SRV _kerberos._tcp.${SITE}._sites.${DNSDOMAIN}           ${HOSTNAME} 88
SRV _ldap._tcp.${SITE}._sites.${DNSDOMAIN}	         ${HOSTNAME} 389
SRV _gc._tcp.${DNSDOMAIN}                                ${HOSTNAME} 3268
SRV _kerberos._tcp.${DNSDOMAIN}                          ${HOSTNAME} 88
SRV _kpasswd._tcp.${DNSDOMAIN}                           ${HOSTNAME} 464
SRV _ldap._tcp.${DNSDOMAIN}                              ${HOSTNAME} 389
SRV _kerberos._udp.${DNSDOMAIN}                          ${HOSTNAME} 88
SRV _kpasswd._udp.${DNSDOMAIN}                           ${HOSTNAME} 464

at runtime, Samba will substitute the variables in this file, and call out to the bind9 nsupdate command using the -g option to enable TSIG-GSS DNS updates. It will only make updates for DNS names that it detects are not currently correctly set.

You can add your own names to dns_update_list list if you want, and Samba will add those on the DNS server. You may also choose not to use TSIG-GSS and instead use a fixed DNS key setup in another bind9 server. To do that you will need to modify the 'nsupdate' command that Samba runs, which is settable using the "nsupdate command" smb.conf option. The default is "/usr/bin/nsupdate -g"

The $IP entries for A records are replaced with the IP interface addresses that Samba detects at runtime, based on the "interfaces=" smb.conf option.


Samba4 joining a domain as a RODC (Status for a work in progress)

For the TODO list see Support RODC TODO

Main features implemented

  • Joinining as a RODC to Windows DC

To do that one should do a net (or samba-tool) vampire, the command line looks something like this:

sudo bin/samba-tool join win.dev RODC -UAdministrator%password --target-dir=/home/ant/prefix.win/
  • Added support for RODC FAS
  • Added support for unidirectional replication
  • Added support for read-only database

Main features in the TODO list

  • Support Administrator role separation
  • Support Credential caching
  • Join Windows as a RODC in Samba4 domain - blocked by kerberos tgt stuff.