title: Setting up samba 4 AD with an LDAP backend
body: <p><b>Case:</b></p>
  
  <p>For a couple of months now I've been following various tutorials, documentation and examples but somehow my end result always ends up not working like in any of the tutorials.</p>
  
  <p>What I need to do is set up an active directory using Samba 4.0 on an Ubuntu Server 16.04 LTS. The samba should use a ldap-backend that is running on another Ubuntu Server 16.04 LTS. Windows clients will use the lan to login to the domain with ldap accounts.</p>
  
  <p>A bonus would be to have a master-master connection from that ldap server to another ldap server, but since I already succeeded in doing something similar like that I will focus on the problem of setting up the Samba with Ldap backend.</p>
  
  <p>I'm getting pertty frustrated since even though I follow tutorials and read a lot about the subject, it somehow never ends up in the result in which I can actually login to the domain, be it a samba account, be it ldap. The only thing close to this is that I at some point was able to login with a unix account, but no active directory services at that time.</p>
  
  <p><b>Documentation that I followed:</b></p>
  
  <pre><code>https://help.ubuntu.com/lts/serverguide/samba-ldap.html
  https://wiki.samba.org/index.php/Samba,_Active_Directory_%26_LDAP
  https://help.ubuntu.com/lts/serverguide/samba-dc.html
  https://www.techrepublic.com/article/how-to-configure-ubuntu-linux-server-as-a-domain-controller-with-samba-tool/
  </code></pre>
  
  <p><b>Steps performed:</b></p>
  
  <p>Used servers:</p>
  
  <pre><code>- cloud.smoothalicious.info
  - router.smoothalicious.info
  - monfig.smoothalicious.info
  </code></pre>
  
  <p>In this order:</p>
  
  <p>Installed ldap on both cloud and router. After which I implemented replication services succesfully. Cloud is the master (producer) and router is the slave (consumer). After this I imported the samba scheme and added the samba indices on the master ldap (cloud). Although replication was succesfull before, it failed with the samba indices without any error messages in syslog, auth.conf or any logs of ldap. Manually I added the indices on my own, giving up on replication at that time.</p>
  
  <p>On monfig I installed Samba 4.0 and used the samba provision tool to configure it. Although I could finally find the active directory through a Windows 10 client, I could not login to it with a samba user account which I added to the domain.</p>
  
  <p><i>The above steps are that of my previous setup, the new one follows.</i></p>
  
  <p>Since this obviously was a big bust I decided to start over with a new tutorial. This was just setting up a Samba AD with a ldap-backend. (source: <a href="https://www.unixmen.com/setup-samba-domain-controller-with-openldap-backend-in-ubuntu-13-04/" rel="nofollow noreferrer">https://www.unixmen.com/setup-samba-domain-controller-with-openldap-backend-in-ubuntu-13-04/</a>) This time I got as far as populating the ldap tree with smbldap-populate, which was succesful. Unfortunatly I was not able to find those groups with getent group. The error I get is:</p>
  
  <pre><code>nss_ldap: failed to bind to LDAP server ldapi:///cloud.smoothalicious.info: Can't contact LDAP server
  </code></pre>
  
  <p><b>Side note:</b></p>
  
  <p>I don't seek answers, although they are welcome. I seek a tutorial that I can follow that does not end in me having different results that the tutorials shows me, even though I followed it in the detail &lt;- this is frustrating, and it happens a lot.</p>