<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<book>
  <bookinfo>
    <title>Samba &#38; LDAP</title>

    <subtitle>...on Debian made simple!</subtitle>

    <author>
      <othername>mawi</othername>

      <email>samba@mawi.org</email>
    </author>

    <copyright>
      <year>2003</year>
    </copyright>

    <abstract>
      <para>Short articles aiming to provide a concise roadmap and a stepwise
      test-oriented deployment tutorial of samba 2.2.x with LDAP as a backend
      on Debian Linux. For initiated users, yet not overly *nix technical.
      Does not provide background or in depth information - intended as a
      complement roadmap for other in depth documentation, a fairly full list
      of which is provided in the bibliography.</para>
    </abstract>

    <releaseinfo>The latest version of this document is kept in several
    formats here: <ulink
    url="http://mawi.org/sambaldap/Samba_and_LDAP_on_Debian.html">HTML</ulink>,
    <ulink url="http://mawi.org/sambaldap/Samba_and_LDAP_on_Debian.pdf">PDF</ulink>,
    <ulink url="http://mawi.org/sambaldap/Samba_and_LDAP_on_Debian.chm">HTML
    Help</ulink>, <ulink
    url="http://mawi.org/sambaldap/Samba and LDAP on Debian.xml"> original
    docbook XML source</ulink>.</releaseinfo>

    <revhistory>
      <revision>
        <revnumber>0.1</revnumber>
        <revdescription>Beta, unfinished and untested. Just putting it "out there" to hopefully get some initial feedback.</revdescription>
        <date>25 Aug 2003</date>
        <authorinitials>mawi</authorinitials>
      </revision>
    </revhistory>
  </bookinfo>

  <preface>
    <title>Why I wrote this...</title>
    <para>I want to make a "cheat sheet" that includes a working 
    configuration based on most available instructions, to get a server up quickly. A guide that just says what and not how.</para>
    
    <para>I wanted to write a text that explains how to get a samba server up
    and running with OpenLDAP as a backend, from the perspective of primarily
    serving windows users. </para>

    <para>Most other articles are lengthy, so I wanted a concise one to be
    available. I also wanted it to be stepwise, with tests after each step.</para>
    
    <para>The cheat sheet is the goal, and not even started - I have some </para>

    <para><emphasis>Please send feedback!</emphasis> I really want this guide
    to work out - despite much testing there&#39;s always that little bug,
    omission or lack of clarity - mail me with your
    impressions/comments/errata/suggestions/&#34;I used your
    article...&#34;-mails...</para>

    <para>First we try out samba without ldap, then uninstall it and compile
    LDAP and samba to make them work together, testing at the end of each
    section. Finally, we refine (actually redo) the LDAP directory structure
    and iron out wrinkles to make the solution behave as a windows user would
    expect, ie: <itemizedlist><listitem><para>make samba autoadd machines as
    we add them to the domain from the client (using the smbldap-tools
    scripts)</para></listitem><listitem><para>ensure password sync</para></listitem><listitem><para>check
    that the administrator group is working</para></listitem></itemizedlist>
    The smbldap-tools are a large part of that section, largely because
    they&#39;ve apparently become a standard way to ease administrative tasks,
    etc. However, they do seem to require configuring Linux authentication in
    order to work properly <footnote><para>I welcome any and all information
    about what the configuration prerequisites/requirements exactly are to get
    the smbldap-tools working.</para></footnote> which is why we will then
    start with configuring that end before installing the scripts.</para>

    <para></para>
  </preface>

  <article id="testSamba">
    <title>Test drive!</title>

    <subtitle>Samba done quick - single player game!</subtitle>

    <para>This small article will guide you through installing default Debian
    Samba and testing it.</para>

    <warning>
      <para>This small chapter is a waste of time! This is only to allow you
      to quickly test samba.</para>

      <para>On the other hand - you should finish it in 15-30 minutes at the
      most!</para>
    </warning>

    <para>At this point, do have a look at the <link linkend="prerequisites">pre-requisites</link>.</para>

    <qandaset defaultlabel="number">
      <?dbhtml toc="1" ?>

      <title>Steps</title>

      <qandaentry>
        <question>
          <para>Install the standard Debian Samba package</para>
        </question>

        <answer>
          <para>We use apt-get to install the package:
          <programlisting>
<command>apt-get</command>
<parameter>install libcupsys2 libtiff3g samba samba-common samba-doc smbclient smbfs</parameter>
</programlisting>This should both install and start the samba service.</para>
        </answer>
      </qandaentry>

      <qandaentry>
        <question>
          <para>Create a test share and configure samba to allow access to it</para>
        </question>

        <answer id="smbtestconf">
          <para>Lets create one in tmp, for example:
          <programlisting>cd /tmp
mkdir test 
chmod 777 test</programlisting> We&#39;re gonna configure <footnote
          id="sambaConfig"><para>Before getting ahead of ourselves, suffice it
          to say that samba is configured through it&#39;s config file which
          you can edit directly (and most changes are reflected immediately -
          but that differs somewhat) or use a frontend like the accompanying
          SWAT - which we will look at briefly below. The samba config file is
          in /etc/samba in Debian.</para></footnote> samba using a typical
          test configuration (no security, etc - nothing). First we backup the
          original config file and then edit.
          <programlisting>cd /etc/samba
mv smb.conf smb_orig.conf
nano smb.conf</programlisting> Into the now empty config file, enter one of
          the simplest configurations we can use (compare by glancing at the
          backup config you just made): <example id="smbConfigSimple"><title>Simplest
          samba configuration</title><programlisting># ------------------------------------------------------
# Test smb.conf file 
# mawi 2003-07-28
# ------------------------------------------------------
[global] <co id="p1glob-co" linkends="p1glob" />
workgroup = TESTSAMBA-GRP <co id="p1grp-co" linkends="p1grp" />
netbios name = TESTSAMBA <co id="p1name-co" linkends="p1name" />
security = SHARE <co id="p1sec-co" linkends="p1sec" />
[test] <co id="p1share-co" linkends="p1share" />
path = /tmp/test 
read only = no
guest ok = yes</programlisting></example> <calloutlist><callout
          arearefs="p1glob-co" id="p1glob"><para>Main section in the samba
          config</para></callout><callout arearefs="p1grp-co" id="p1grp"><para>As
          in windows - the netbios workgroup name. Doesn&#39;t matter for this
          test.</para></callout><callout arearefs="p1name-co" id="p1name"><para>The
          netbios name that we want this machine to have. Use the hostname of
          the computer for simplicity&#39;s sake.</para></callout><callout
          arearefs="p1sec-co" id="p1sec"><para>Interesting: The security model
          for the samba machine. See samba doc for more info, or hold on.</para></callout><callout
          arearefs="p1share-co" id="p1share"><para>Here we tell samba to share
          a directory - each general share we want is defined by it&#39;s own
          section. The parameters are pretty self explanatory - we indicate
          what folder the share is, and then that guests are ok and writing is
          ok.</para></callout></calloutlist></para>
        </answer>
      </qandaentry>

      <qandaentry>
        <question>
          <para>Test samba</para>
        </question>

        <answer>
          <para>We will make sure that samba is running, then we will test by
          accessing the share, then optionally test adding the samba to a
          domain / and or adding a client to samba (and have it act as a PDC,
          if only briefly). Make sure that samba is running by restarting it
          ;): <programlisting>/etc/init.d/samba restart</programlisting></para>

          <formalpara>
            <title>List share from linux machine (locally, loopback)</title>

            <para>Try listing the samba shares using the command/program
            smbclient <footnote id="sambaPrograms"><para>Samba includes not
            just the server programs, but also client, administration, etc
            programs - the whole enchilada.</para></footnote> and the list (L)
            switch: <programlisting>smbclient -L TESTSAMBA <co id="p2name-co"
linkends="p2name" />
</programlisting> <calloutlist><callout arearefs="p2name-co" id="p2name"><para>Enter
            the hostname of the computer (as you did in <link
            linkend="smbConfigSimple">the config file</link> above).</para></callout></calloutlist>
            Hopefully, you get a listing of the test share.</para>
          </formalpara>

          <formalpara>
            <title>List and access share from a windows machine</title>

            <para>Then try accessing the samba machine (use
            <command>net view</command> <parameter>SAMBAHOSTNAME</parameter>)
            and access the share from a windows machine, as usual (using
            \\IPADDRESS\test). If your network <footnote id="network"><para>Instructions
            for getting your computers talking to each other is way out of
            scope for this article.</para></footnote> is working ok,
            everything should go fine.</para>
          </formalpara>

          <formalpara>
            <title>Add the samba machine to an existing windows domain</title>

            <para>Optionally, if you have a domain controller ready and
            administrator account to it: <screen>
smbpasswd -r SERVER -j RUBIES -UAdministrator%PASSWORDHERE 
<lineannotation>name and passwd of your admin acct here</lineannotation>
</screen></para>
          </formalpara>
        </answer>
      </qandaentry>

      <qandaentry>
        <question>
          <para>Install, enable and look at <glossterm linkend="swat">SWAT</glossterm></para>
        </question>

        <answer>
          <para>Install SWAT using apt-get: <screen>
<command>apt-get</command>
<parameter>install swat</parameter>
</screen> Then you need to edit inet.d conf to make the web server allow
          access to swat using port 901 (which is the port swat uses). In
          Debian, the line is already there (last in the file), you just need
          to uncomment it to enable it, and then restart inetd (and samba just
          to make sure). <programlisting>nano /etc/inetd.conf<co
id="p3inetd-co" linkends="p3inetd" />
/etc/init.d/inetd restart
/etc/init.d/samba restart</programlisting> <calloutlist><callout
          arearefs="p3inetd-co" id="p3inetd"><para>Edit and uncomment swat
          line, should be last in file</para></callout></calloutlist> Now try
          the SWAT gui by surfing to it, using http://HOSTNAME:901. Have a
          look at all the tabs - pretty useful. In addition, the help links
          are great - now is a good time to view the help on the
          &#34;security&#34; setting in the config file. On the globals tab,
          find security, click help and get wiser!</para>
        </answer>
      </qandaentry>

      <qandaentry>
        <question>
          <para>Uninstall samba again</para>
        </question>

        <answer>
          <para>This will uninstall so that we may go on to the next chapter
          &#34;a-fresh&#34; <footnote><para>I am not sure if this will
          uninstall everything, but mostly everything...</para></footnote>:
          <programlisting>/etc/init.d/samba stop
apt-get remove samba-doc samba samba-common smbclient smbfs swat winbind</programlisting></para>
        </answer>
      </qandaentry>
    </qandaset>

    <para>Didn&#39;t that go quick, huh?</para>
  </article>

  <article id="testLDAP">
    <title>OpenLDAP run-through</title>

    <subtitle>OpenLDAP done quick - single player game!</subtitle>

    <para>This small article will guide you through compiling and testing
    OpenLDAP.</para>

    <para>To be continued...</para>
  </article>

  <chapter id="ldapSamba1">
    <title>Basic install</title>

    <subtitle>Getting ready for some multiplayer action!</subtitle>

    <section id="c1s1">
      <title>Get, install and test OpenLDAP</title>

      <para>We will install and configure the basic openldap system so that we
      can test samba using it. This will omit configuring <glossterm
      linkend="nss">nss</glossterm>, <glossterm linkend="pam">pam</glossterm>
      and automating scripts and so on. This section is based on the excellent
      (and much more in-depth) article <xref linkend="amers03a" />, highly
      recommended!</para>

      <qandaset defaultlabel="number">
        <?dbhtml toc="1" ?>

        <title>Steps</title>

        <qandaentry>
          <question>
            <para>Get source</para>
          </question>

          <answer>
            <para>First we create a directory to store the source in, I
            suggest in /usr/local/src/: <programlisting>cd /usr/local/src/
mkdir slapd <lineannotation>slapd is the name of the server daemon program of OpenLDAP</lineannotation>
cd slapd/
</programlisting> Then we download the source and install dependencies to
            slapd, all using the Debian tool apt-get:
            <programlisting>apt-get source slapd
apt-get build-dep slapd
</programlisting> Lastly, we install SSL development libraries (optional, if
            you wanna go SSL or not, but it won&#39;t hurt and only takes a
            sec): <programlisting>apt-get install libssl-dev
</programlisting></para>
          </answer>
        </qandaentry>

        <qandaentry>
          <question>
            <para>Edit build config, build and install OpenLDAP</para>
          </question>

          <answer>
            <para>We will make a small adjustment to the build configuration
            (the &#34;rules&#34; <footnote><para>the rules file is always
            located in the &#34;debian&#34; folder of a source package
            (directory)</para></footnote> file), first we go into the
            downloaded source directory: <programlisting>cd openldap2-2.0.23/
nano debian/rules <co id="c1p1rules-co" linkends="c1p1rules" />
</programlisting> <calloutlist><callout arearefs="c1p1rules-co" id="c1p1rules"><para>In
            the (rather short) &#34;rules&#34; file, search for
            &#34;without-tls&#34; and replace it with with &#34;with-tls&#34;.
            One change only.</para></callout></calloutlist> <xref
            linkend="amers03a" /> says to run the rules file manually, but go
            with the standard dpkg-buildpackage tool (I like standard stuff):
            <programlisting>dpkg-buildpackage
</programlisting> Hopefully, this goes alright. Finally we install the newly
            built packages using dpkg -i (for install). To do this we leave
            the extracted source directory: <programlisting>cd ..
dpkg -i slapd_2.0.23-6_i386.deb \ 	<lineannotation>notice backslash to split command into several lines</lineannotation>
&#62; libldap2_2.0.23-6_i386.deb \
&#62; libldap2-dev_2.0.23-6_i386.deb \
&#62; ldap-utils_2.0.23-6_i386.deb
</programlisting> <xref linkend="amers03a" /> says that debconf<footnote><para>The
            Debian configuration program that may be invoked when installing
            new programs (packages)</para></footnote> will ask you some
            questions at this point but I did not get any questions.</para>
          </answer>
        </qandaentry>

        <qandaentry>
          <question>
            <para>Configure OpenLDAP, add testdata and test</para>
          </question>

          <answer>
            <para>We will edit the default configuration file, add two records
            and test the server by querying it. The configuration file is
            /etc/ldap/slapd.conf <programlisting>cd /etc/ldap/
nano slapd.conf
</programlisting> The following is a simple configuration that works:
            <programlisting># /etc/ldap/slapd.conf
include /etc/ldap/schema/core.schema <co id="c2p2com-co" linkends="c2p2com" />
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/inetorgperson.schema
#include /etc/ldap/schema/nis.schema
#include /etc/ldap/schema/redhat/rfc822-MailMember.schema
#include /etc/ldap/schema/redhat/autofs.schema
#include /etc/ldap/schema/redhat/kerberosobject.schema
#include /etc/ldap/schema/samba.schema

pidfile //var/run/slapd.pid
argsfile //var/run/slapd.args

#Sample Access Control
# Allow read access of root DSE
# Allow self write access
# Allow authenticated users read access
# Allow anonymous users to authenticate
access to dn=&#34;&#34; by * read
access to *
	by self write
	by users read
	by anonymous auth
# if no access controls are present, the default is:
# Allow read by all
# rootdn can always write


###############################################
############# ldbm database definitions#############
###############################################
database ldbm
suffix &#34;dc=e-mf,dc=net&#34; <co id="c2p2suffix-co" linkends="c2p2suffix" />
rootdn &#34;cn=Manager,dc=e-mf,dc=net&#34; <co id="c2p2rootdn-co"
linkends="c2p2rootdn" />
rootpw SECRET <co id="c2p2pwd-co" linkends="c2p2pwd" />

# The database directory MUST exist prior to running slapd AND
# should only be accessibleby the slapd/tools. Mode 700 recommended.
directory /var/lib/ldap/e-mf.net

# Indices to maintain
index primaryGroupID eq
index rid eq
index uid eq
#index uidNumber eq
#index gidNumber eq
index cn pres,sub,eq
index objectClass eq
index default sub
# ends
</programlisting> <calloutlist><callout arearefs="c2p2com-co" id="c2p2com"><para>Notice
            how I am at this point only leaving some schemas active
            (uncommented)</para></callout><callout arearefs="c2p2suffix-co"
            id="c2p2suffix"><para>Edit the suffix</para></callout><callout
            arearefs="c2p2rootdn-co" id="c2p2rootdn"><para>Enter the rootdn
            name. Note: all is case sensitive here!</para></callout><callout
            arearefs="c2p2pwd-co" id="c2p2pwd"><para>Password, you can copy
            and use <command>slappasswd</command> crypt or md5 hash to not
            store in cleartext</para></callout></calloutlist> Let&#39;s try
            starting the openldap server: <programlisting>/etc/init.d/slapd start
</programlisting> Now add a couple of records to our directory, first create a
            file (<filename>base.ldif</filename>) with the following test
            data: <programlisting>dn: dc=e-mf,dc=net <lineannotation>of course, edit this...</lineannotation>
objectClass: domain
dc: e-mf <lineannotation>...and this...</lineannotation>

dn: ou=Users,dc=e-mf,dc=net <lineannotation>...and this</lineannotation>
objectClass: top
objectClass: organizationalUnit
ou: Users
description: System Users
</programlisting> Now add the data from that file using the ldapadd command:
            <programlisting>
<command>ldapadd</command> -x -D &#34;cn=Manager,dc=e-mf,dc=net&#34; -f <filename>base.ldif</filename> -W</programlisting>
            (See the man page for ldapadd for info on the switches). You will
            get prompted for the password you just set. Lastly, test by
            querying for the records: <programlisting>
ldapsearch -x -W -D &#34;cn=Manager;dc=e-mf;dc=net&#34;
</programlisting> All records will be displayed. That wraps it up - OpenLDAP
            is basically ready to rumble!! Let&#39;s see if we can get our
            other contestant out in the ring!</para>
          </answer>
        </qandaentry>

        <qandaentry>
          <question>
            <para>Optional but nice: Get LDAPManager and view the directory</para>
          </question>

          <answer>
            <para><note><para>This is totally optional - but
            <emphasis>recommended</emphasis> and may please you if you feel
            dissapointed by the lack of *thump* in the result of our OpenLDAP
            installation.</para></note> There is a program called LDAPManager
            that will allow you to browse an LDAP directory very nicely. It is
            a java program and to install we need to install Java from Sun,
            download LDAPManager, extract and run the .jar. You then specify
            the server (ip) to connect to and connect using the rootdn as with
            ldapadd and ldapsearch above.</para>

            <para>LDAPManager can be downloaded from its page: <ulink
            url="http://www-unix.mcs.anl.gov/~gawor/ldap/"></ulink> and <ulink
            url="http://www.iit.edu/~gawojar/ldap/"></ulink>.</para>
          </answer>
        </qandaentry>
      </qandaset>
    </section>

    <section id="c1s2">
      <title>Get, build and test Samba 2.2.x</title>

      <para>This is basically a remake of the <link linkend="testSamba">introductory</link>
      article, but this time we get the sources, modify the build parameters
      and build Samba ourselves - with support for using LDAP as the user
      authentication backend <footnote><para>Samba 2.x does not include
      support for LDAP backend in it&#39;s default package - it needs to be
      compiled on a machine with LDAP on it.</para></footnote> .</para>

      <qandaset defaultlabel="number">
        <?dbhtml toc="1" ?>

        <title>Steps</title>

        <qandaentry>
          <question>
            <para>Download and extract source</para>
          </question>

          <answer>
            <para>First we create a directory to store the source in, I
            suggest in /usr/local/src/: <programlisting>
cd /usr/local/src/
mkdir samba
cd samba/
</programlisting> Then we download the source. Here you have some different
            options, you can use apt-get or find the source file on the net
            and use <command>wget</command> to download it to the directory.
            I&#39;m gonna go for the latter, and I found an URL to the source
            (2.2.8 http://us1.samba.org/samba/ftp/samba-2.2.8a.tar.gz ).
            <programlisting>
apt-get install wget <lineannotation>install wget, if you don&#39;t have it</lineannotation>
wget http://us1.samba.org/samba/ftp/samba-2.2.8a.tar.gz <lineannotation>I paste the URL I found</lineannotation>
</programlisting> Finally, we extract the source so we can use it:
            <programlisting>
tar xvzf samba_2.2.8a.tar.gz <lineannotation>skip v (verbose) if you don&#39;t want clutter</lineannotation>
</programlisting></para>
          </answer>
        </qandaentry>

        <qandaentry>
          <question>
            <para>Edit build config, build and install Samba</para>
          </question>

          <answer>
            <para>Configuring the Samba build requires changes to some
            different files, so we will make a backup of these files first.
            <programlisting>cd /samba-2.2.8a/debian <lineannotation>go into the extracted source directory</lineannotation>
mkdir ../../ldap-deb-bak <lineannotation>create backup directory</lineannotation>
cp rules libpam-smbpass.files \
samba-common.conffiles winbind.files ../../ldap-deb-bak/ <lineannotation>then make backups</lineannotation>
</programlisting> Three files require simple edits:
            <programlisting>nano libpam-smbpass <lineannotation>to empty</lineannotation>
nano samba-common.conffiles <lineannotation>to empty</lineannotation> 
nano winbind.files <lineannotation>remove lib/security/pam winbind.so</lineannotation>
</programlisting> The rules file (fourth and final) requires the following
            edits: <example><title>Samba build rules edits</title><programlisting>
--with-pam				<lineannotation>remove this</lineannotation>
--with-pam_smbpass		<lineannotation>remove this</lineannotation>

--with-automount \ 			<lineannotation>add this</lineannotation>
--with-acl-support \			<lineannotation>add this</lineannotation>
--with-profile \				<lineannotation>add this</lineannotation>
--disable-static \			<lineannotation>add this</lineannotation>
--with-ldapsam)			<lineannotation>add this</lineannotation>

131 #install -m 0644 source/nsswitch/pam_winbind.so \		<lineannotation>comment this line</lineannotation>
132 #$(DESTDIR)/lib/security/		<lineannotation>comment this line</lineannotation>
142 #mv $(DESTDIR)/usr/bin/pam_smbpass.so $(DESTDIR)/lib/security/	<lineannotation>comment this line</lineannotation>
182 #cp debian/samba.pamd $(DESTDIR)/etc/pam.d/samba	<lineannotation>comment this line</lineannotation>
</programlisting></example> These packages need to be installed before
            building, and then we go out and see the build packages and
            install them: <programlisting>
apt-get install libcupsys2 libtiff3g debhelper \
libcupsys2-dev autoconf libpam0g-dev libreadline4-dev
dpkg-buildpackage
cd ..
dpkg -i \
samba-common_2.2.8a-0.1_i386.deb \
libsmbclient_2.2.8a-0.1_i386.deb \
libsmbclient-dev_2.2.8a-0.1_i386.deb \
samba_2.2.8a-0.1_i386.deb \
smbclient_2.2.8a-0.1_i386.deb \
smbfs_2.2.8a-0.1_i386.deb \
swat_2.2.8a-0.1_i386.deb \
winbind_2.2.8a-0.1_i386.deb \
samba-doc_2.2.8a-0.1_all.deb
</programlisting> If all goes well, Samba should be installed and running
            <emphasis>with</emphasis> LDAP support (unconfigured).</para>
          </answer>
        </qandaentry>

        <qandaentry>
          <question>
            <para>Configure and test</para>
          </question>

          <answer>
            <para>To test samba and start a small <glossterm linkend="smbconf">smb.conf</glossterm>,
            then test using it: Go through the <link linkend="smbtestconf">configure
            and test</link> part of the <link linkend="testSamba">quick
            walk-through</link>, then come back here and we will make some
            changes in order to activate the LDAP backend and test that.</para>

            <para>Assuming that you created the simple config, lets go through
            the basic changes necessary to test the samba-ldap
            interoperability. We need to add the samba schema to the OpenLDAP
            config - ie copy the file to the schemas directory and then
            reference it in our slapd.conf: Now we need to edit the samba
            config, telling it to use LDAP for authentication and then we need
            to give samba the LDAP manager password so it can access it for
            us. First we edit smb.conf: <example><title>smb.conf edits to
            enable LDAP backend</title><programlisting>;LDAP-specific settings
ldap admin dn= &#34;cn=Manager,dc=e-mf,dc=net&#34; 	<lineannotation>your specifics from slapd.conf</lineannotation>
ldap port = 389
ldap ssl = no
ldap suffix = &#34;ou=Users,dc=e-mf,dc=net&#34;		<lineannotation>where shall samba put/check for users?</lineannotation>
</programlisting></example> Finally, we give samba the LDAP manager password,
            and at this point, I found restarting the services may be
            necessary; <screen>smbpasswd -w secret <lineannotation>your password goes here, of course</lineannotation>
/etc/init.d/slapd restart
/etc/init.d/samba restart
</screen></para>

            <para>Samba should now be able to create a user account for us in
            the LDAP directory based on a *nix system account (the alternative
            is to add the user <link linkend="usermanadd">account manually</link>).
            You make a *nix account into a samba account with
            <command>smbpasswd</command>. So to create a samba user we add the
            user and then run <command>smbpasswd</command> to add the user to
            the directory and set the password. We will check it out using
            ldapsearch (or LDAPmanager) and test that we can use the user when
            accessing samba: <screen>useradd -c &#34;Samba User account&#34; -d /dev/null -s /bin/false nils
ldapadd -x -h localhost -D &#34;cn=Manager,dc=e-mf,dc=net&#34; -f nils.ldif -W
smbpasswd -a nils
ldapsearch -x -W -D &#34;cn=Manager;dc=e-mf;dc=net&#34;
smbclient -L HOSTNAME -Unils%PASSWORDHERE <lineannotation>replace here of course</lineannotation>
</screen> Then try accessing the server and a share from a windows machine. If
            you like, to further test, try opening up SWAT and deny nils
            access to the share, and so on. <tip><title>Further testing</title><para>Other
            tests at this point could be to <link linkend="faqSambaPDC">make
            samba DC</link> and test <link linkend="faqAddWin">add a windows
            client machine</link>. Instructions on how to do this - without
            LDAP considerations - can be found elsewhere.</para></tip></para>
          </answer>
        </qandaentry>
      </qandaset>

      <para>So far so good? Next up we do a little linux changes, redo the
      LDAP structure and enable some scripts to throw the switch on the
      machine as a PDC.</para>
    </section>
  </chapter>

  <chapter id="ldapSambaWin">
    <title>Samba LDAP as a DC</title>

    <section id="linuxldapAuth">
      <title>Making Debian authenticate via LDAP <footnote><para>Based on
      <xref linkend="amers03a" /></para></footnote></title>

      <subtitle>Let&#39;s change som Linux configs!</subtitle>

      <para>We will install and configure <glossterm linkend="nss"></glossterm>,
      PAM, passwd and ssh authentication to use LDAP. Then we will test by
      adding a user to the system and use ssh to log in as that user. This has
      nothing to do with samba except to unify the account datastore and
      (important) make sure smbldap-tools run.</para>

      <para>Install: <screen>apt-get install libnss-ldap libpam-ldap</screen>
      Configure (make some backups): <screen>
mv /etc/libnss-ldap.conf /etc/libnss-ldap.conf_DEB-orig
nano /etc/libnss-ldap.conf  <lineannotation>example <link linkend="libnssldap">here</link></lineannotation>

nano /etc/nsswitch.conf <lineannotation>look <link linkend="nsswitchconf">here</link></lineannotation>
nano /etc/pam_ldap.conf <lineannotation>example <link linkend="pamldap">here</link></lineannotation>
nano /etc/libnss-ldap.conf  <lineannotation>look <link linkend="libnssldap">here</link> for example</lineannotation> 

cp passwd passwd_DEB-orig
nano /etc/pam.d/passwd <lineannotation>check <link linkend="pamdpasswd">example</link></lineannotation>
</screen> We also need to update our ldap configuration, we need to add a nss
      user to the directory and in fact I advise a new structure as opposed to
      the quick install tests (which almost had no structure). We also edit
      slapd.conf to enable the nis schema: <screen>
nano /etc/ldap/slapd.conf <lineannotation>uncomment nis.schema line at the beginning of the file</lineannotation>
TODO: clear existing directory contents
ldapadd -x -D &#34;cn=Manager,dc=e-mf,dc=net&#34; -f base.ldif -W 
	<lineannotation>Create a new base structure in a ldif file, details of my simple example <link
linkend="baseldif">here</link>
</lineannotation>
</screen></para>

      <para>Configure ssh (/etc/pam.d/ssh) to authenticate via LDAP, test:
      <screen>cd /etc/pam.d/
cp ssh ssh_DEB-orig
nano ssh <lineannotation>check <link linkend="pamdssh">example file</link></lineannotation>
</screen> To test, add a user to the directory only and try logging in using
      ssh with that user. Make sure the users entry in the directory has a
      valid shell. TODO: FIXME</para>
    </section>

    <section>
      <title>Install, configure &#38; test smbldap-tools</title>

      <para>We need to add the sources for the Debian packages of the
      smbldap-tools to our apt source list file, after which we will install,
      configure and test. First we edit the apt sources list (<filename>/etc/apt/sources.list</filename>)
      and add the following lines: <example><title>smbldap-tools sources for
      /etc/apt/sources.list</title><programlisting>
# smbldap-tools:
deb ftp://ftp.samba.gr.jp/pub/samba-jp/debian/woody ./
deb-src ftp://ftp.samba.gr.jp/pub/samba-jp/debian/woody ./
</programlisting></example> We can now install using: <screen>
<command>apt-get install</command><parameter>smbldap-tools</parameter>
</screen> The Debian package places the configuration file for the tools in
      the samba configuration directory, <filename>/etc/samba/smbldap_conf.pm</filename>,
      and you need to make atleast fourteen small edits. The config file is
      rather lengthy so I placed an annotated example and list of the edits in
      an <link linkend="smbldap-tools-conf">appendix</link>, so go there and
      have a look now! :-)</para>

      <para>We now test that the scripts are configured correctly and working,
      by adding necessary groups and administrator accounts. We will restart
      slapd first: <screen>
/etc/init.d/slapd restart
TODO: restart auth or whatever?
TODO: users?
TODO: test 1 - show user
TODO: test 2 - add group
smbldap-groupadd Machines
to check if it seems to work: tail /var/log/auth.log
smbldap-groupadd -g 200 DomainAdmins <lineannotation>Single word groupname is easiest for smb.conf, it seems</lineannotation>

smbldap-useradd -a -m -g 200 administrator
smbldap-passwd administrator

smbldap-useradd -a -m -g 200 root	<lineannotation>necessary for adding w2k/XP machines, see <link
linkend="faqAddWin">FAQ</link>
</lineannotation>
smbldap-usermod -u 0 -g 0 root
smbldap-passwd root
</screen></para>

      <para>We now edit <glossterm linkend="smbconf">smb.conf</glossterm> to
      make use of the smbldap-tools, and edit/add these lines:
      <example><title>smbldap-tools edits to smb.conf</title><programlisting>
add user script = /usr/sbin/smbldap-useradd -w -d /dev/null -g Machines -c &#34;Machine account&#34; -s /bin/false %u
password change script = 
domain admin group = 
TODO: Check and complete this!
</programlisting></example></para>

      <para>Finally, in order to throw the switch on samba as a DC we add the
      following lines to smb.conf: <example><title>smb.conf edits for samba as
      DC</title><programlisting>
TODO: FIXME!
</programlisting></example> After these last edits, restart the services and
      test the configuration from the windows world by: (1) Adding a computer
      to the domain (see <link linkend="faqAddWin">FAQ</link> for tips on how
      to seek out bugs in the setup), (2) add a user using the smbldap-useradd
      script/command and log in as that user, then (3) change the password for
      that user (4) try logging on using ssh (set users shell to a valid shell
      using LDAPmanager) and (5) log on as a domain administer and test that
      you are getting administrative access.</para>
    </section>
  </chapter>

  <article>
    <title>Small FAQ</title>

    <qandaset defaultlabel="number">
      <?dbhtml toc="1" ?>

      <qandaentry>
        <question>
          <para>How to add a user account manually</para>
        </question>

        <answer id="usermanadd">
          <para>There are several ways to add a user account (SWAT for
          example) - to add one manually first add it to the *nix system using
          either <command>useradd</command> or <command>adduser</command>,
          then add the user to the directory by creating a file with the data
          and adding it using ldapadd and then making it a samba account and
          setting it&#39;s password by using <command>smbpasswd</command>.</para>

          <para>You will want to think about whether the user shall be able to
          logon to the Linux machine. So assuming we have created a file with
          the userdata &#34;nils.ldif&#34;: <example><title>Simple user ldif
          file to add to LDAP directory</title><programlisting>dn: uid=nils, ou=Users, dc=e-mf, dc=net
objectClass: inetOrgPerson
objectClass: top
objectClass: organizationalPerson
cn: Nils Nilsson test user
sn: Nilsson
title: Testuser
description: NA
</programlisting></example> We add this user in these three steps:
          <screen>useradd -c &#34;Samba User account&#34; -d /dev/null -s /bin/false nils
ldapadd -x -h localhost -D &#34;cn=Manager,dc=e-mf,dc=net&#34; -f nils.ldif  -W
smbpasswd -a nils
</screen> Notice how the user is not given a valid shell (-s) so he cannot
          login on the linux machine and no no valid home directory (-d).</para>
        </answer>
      </qandaentry>

      <qandaentry>
        <question>
          <para>How to make samba act as a PDC</para>
        </question>

        <answer id="faqSambaPDC">
          <para>TODO</para>
        </answer>
      </qandaentry>

      <qandaentry>
        <question>
          <para>How to add a windows client machine</para>
        </question>

        <answer id="faqAddWin">
          <formalpara>
            <title>Make sure &#34;root&#34; account exists in samba</title>

            <para>Apparently, in order to add a win2k/XP machine, there must
            exist a root user in the LDAP directory. With the smbldap-tools
            installed we add the user like so: <screen>smbldap-useradd -a -m -g 200 root	<lineannotation>Notice adding to admin group, which we have set to GID 200.</lineannotation>
smbldap-usermod -u 0 -g 0 root	<lineannotation>TODO: hmm...? check this! </lineannotation>
smbldap-passwd root
</screen> For vanilla samba (without LDAP and the smbldap-tools package) we
            set the password of the root account for samba using
            <command>smbpasswd</command>: <screen>smbpasswd -a root <lineannotation>TODO: check !</lineannotation>
</screen></para>
          </formalpara>

          <para>To add a computer to the domain, ensuring that it gets/has an
          account is the first step. If using LDAP and the smbldap-tools are
          installed and configured (and add user script of smb.conf set and
          working) we should be able to add a windows machine from it -
          remotely - so that samba adds the machine account to the LDAP
          directory automatically.</para>

          <para>Otherwise, we need to add an account for the machine manually
          like so: <screen>useradd -c &#34;Windows NT Computer account&#34; -d /dev/null -s /bin/false rudolf$
<lineannotation>
-c = comment
-d = home dir
-s = shell
</lineannotation>
smbpasswd -m -a rudolf	<lineannotation>create machine account in samba database</lineannotation>
</screen> After the account issue has been taken care of we can set the
          windows client to the domain from the windows computer as usual -
          <emphasis>except</emphasis> that we need to supply the root account
          (and no other) when doing so. We then reboot. All done!</para>
        </answer>
      </qandaentry>
    </qandaset>
  </article>

  <appendix id="prerequisites">
    <title>Prerequisites</title>

    <para>I am assuming that you know a little about linux, and especially
    Debian linux. For example:</para>

    <itemizedlist>
      <listitem>
        <para>Familiarity with installing software (atleast you have used
        apt-get, dselect and maybe dpkg)</para>
      </listitem>

      <listitem>
        <para>Basic *nix know-how (you know how to edit a text file in linux)</para>
      </listitem>

      <listitem>
        <para>Windows network administration (you know your way around the
        windows <glossterm linkend="net">&#34;net&#34;</glossterm> command)</para>
      </listitem>

      <listitem>
        <para>A test environment - do yourself a favor and get everything set
        for testing. You need a linux machine, a windows machine and a
        functioning network between them - preferably without another windows
        PDC on it (<glossterm linkend="afaics">AFAICS</glossterm>). If yo have
        access to VMWare go for it - it really makes creating and manipulating
        testbeds easy! My environment was to VMWare machines on my workstation
        - one running linux with a bridged NIC and a host only NIC to a
        virtual VMWare net to which the windows machine had it&#39;s only NIC
        attached.</para>
      </listitem>
    </itemizedlist>

    <para>You will see me editing using nano throughout this article</para>
  </appendix>

  <appendix id="smbldap-tools-conf">
    <title>The smbldap-tools config file</title>

    <para>The Debian package of the tools places the configuration file in the
    samba configuration directory (/etc/samba/). This is an example of it with
    the fourteen necessary changes annotated. Most are fairly self
    explanatory. Besides these fourteen, many other parameters exist that give
    the scripts a necessary description of your environment.</para>

    <example>
      <title>smbldap-tools config, smbldap_conf.pm</title>

      <programlisting>#!/usr/bin/perl
use strict;
package smbldap_conf;

# $Id: smbldap_conf.pm,v 1.14 2002/06/01 04:30:48 olem Exp $
#
# smbldap-tools.conf : Q  &#38; D configuration file for smbldap-tools

#  This code was developped by IDEALX (http://IDEALX.org/) and
#  contributors (their names can be found in the CONTRIBUTORS file).
#
#                 Copyright (C) 2001-2002 IDEALX
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
#  USA.

#  Purpose :
#       . be the configuration file for all smbldap-tools scripts

use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS
$UID_START $GID_START $smbpasswd $slaveLDAP $masterLDAP
$with_smbpasswd $mk_ntpasswd
$ldap_path $ldap_opts $ldapsearch $ldapsearchnobind
$ldapmodify $ldappasswd $ldapadd $ldapdelete $ldapmodrdn
$suffix $usersdn $computersdn
$groupsdn $scope $binddn $bindpasswd
$slaveDN $slavePw $masterDN $masterPw
$_userLoginShell $_userHomePrefix $_userGecos
$_defaultUserGid $_defaultComputerGid
$_skeletonDir $_userSmbHome
$_userProfile $_userHomeDrive
$_userScript $usersou $computersou $groupsou
);

use Exporter;
$VERSION = 1.00;
@ISA = qw(Exporter);

@EXPORT = qw(
$UID_START $GID_START $smbpasswd $slaveLDAP $masterLDAP
$with_smbpasswd $mk_ntpasswd
$ldap_path $ldap_opts $ldapsearch $ldapsearchnobind $ldapmodify $ldappasswd
$ldapadd $ldapdelete $ldapmodrdn $suffix $usersdn
$computersdn $groupsdn $scope $binddn $bindpasswd
$slaveDN $slavePw $masterDN $masterPw
$_userLoginShell $_userHomePrefix $_userGecos
$_defaultUserGid $_defaultComputerGid $_skeletonDir
$_userSmbHome $_userProfile $_userHomeDrive $_userScript
$usersou $computersou $groupsou
);


##############################################################################
#
# General Configuration
#
##############################################################################

#
# UID and GID starting at...
#

$UID_START = 1000;
$GID_START = 1000;

##############################################################################
#
# LDAP Configuration
#
##############################################################################

# Notes: to use to dual ldap servers backend for Samba, you must patch
# Samba with the dual-head patch from IDEALX. If not using this patch
# just use the same server for slaveLDAP and masterLDAP.
#
# Slave LDAP : needed for read operations
#
# Ex: $slaveLDAP = &#34;127.0.0.1&#34;;
$slaveLDAP = &#34;127.0.0.1&#34;;

#
# Master LDAP : needed for write operations
#
# Ex: $masterLDAP = &#34;127.0.0.1&#34;;
$masterLDAP = &#34;127.0.0.1&#34;;

#
# LDAP Suffix
#
# Ex: $suffix = &#34;dc=IDEALX,dc=ORG&#34;;
$suffix = &#34;dc=e-mf,dc=net&#34;; <co id="tc-ldaproot-co"
linkends="tc-ldaproot" />

#
# Where are stored Users
#
# Ex: $usersdn = &#34;ou=Users,$suffix&#34;; for ou=Users,dc=IDEALX,dc=ORG
$usersou = q(_USERS_); <co id="tc-usersname-co" linkends="tc-usersname" />

$usersdn = &#34;ou=$usersou,$suffix&#34;;

#
# Where are stored Computers
#
# Ex: $computersdn = &#34;ou=Computers,$suffix&#34;; for ou=Computers,dc=IDEALX,dc=ORG
$computersou = q(_COMPUTERS_); <co id="tc-compsname-co"
linkends="tc-compsname" />

$computersdn = &#34;ou=$computersou,$suffix&#34;;

#
# Where are stored Groups
#
# Ex $groupsdn = &#34;ou=Groups,$suffix&#34;; for ou=Groups,dc=IDEALX,dc=ORG
$groupsou = q(_GROUPS_); <co id="tc-groupsname-co" linkends="tc-groupsname" />

$groupsdn = &#34;ou=$groupsou,$suffix&#34;;

#
# Default scope Used
#
$scope = &#34;sub&#34;;

#
# Credential Configuration
#
# Bind DN used
# Ex: $binddn = &#34;cn=Manager,$suffix&#34;; for cn=Manager,dc=IDEALX,dc=org
$binddn = &#34;Manager&#34;; <co id="tc-binddn-co" linkends="tc-binddn" />
#
# Bind DN passwd used
# Ex: $bindpasswd = &#39;secret&#39;; for &#39;secret&#39;
$bindpasswd = &#34;asda1452&#34;; <co id="tc-bindpwd-co" linkends="tc-bindpwd" />

#
# Notes: if using dual ldap patch, you can specify to different configuration
# By default, we will use the same DN (so it will work for standard Samba
# release)
#
$slaveDN = $binddn;
$slavePw = $bindpasswd;
$masterDN = $binddn;
$masterPw = $bindpasswd;

##############################################################################
#
# Unix Accounts Configuration
#
##############################################################################

# Login defs
#
# Default Login Shell
#
# Ex: $_userLoginShell = q(/bin/bash);
$_userLoginShell = q(_LOGINSHELL_); <co id="tc-defshell-co"
linkends="tc-defshell" />

#
# Home directory prefix (without username)
#
#Ex: $_userHomePrefix = q(/home/);
$_userHomePrefix = q(/home/); 
#
# Gecos
#
$_userGecos = q(System User);

#
# Default User (POSIX and Samba) GID
#
$_defaultUserGid = 100; <co id="tc-defusergid-co" linkends="tc-defusergid" />

#
# Default Computer (Samba) GID
#
$_defaultComputerGid = 553; <co id="tc-defcompgid-co" linkends="tc-defcompgid" />

#
# Skel dir
#
$_skeletonDir = q(/etc/skel); <co id="tc-skeldirpath-co"
linkends="tc-skeldirpath" />

##############################################################################
#
# SAMBA Configuration
#
##############################################################################

#
# The UNC path to home drives location without the username last extension
# (will be dynamically prepended)
# Ex: q(\\\\My-PDC-netbios-name\\homes) for \\My-PDC-netbios-name\homes
$_userSmbHome = q(\\\\_PDCNAME_\\homes); <co id="tc-homeshare-co"
linkends="tc-homeshare" />

#
# The UNC path to profiles locations without the username last extension
# (will be dynamically prepended)
# Ex: q(\\\\My-PDC-netbios-name\\profiles) for \\My-PDC-netbios-name\profiles
$_userProfile = q(\\\\_PDCNAME_\\profiles\\); <co id="tc-profileshare-co"
linkends="tc-profileshare" />

#
# The default Home Drive Letter mapping
# (will be automatically mapped at logon time if home directory exist)
# Ex: q(U:) for U:
$_userHomeDrive = q(_HOMEDRIVE_:); <co id="tc-homedrive-co"
linkends="tc-homedrive" />

#
# The default user netlogon script name
# if not used, will be automatically username.cmd
#
#$_userScript = q(startup.cmd); # make sure script file is edited under dos  <co
id="tc-script-co" linkends="tc-script" />


##############################################################################
#
# SMBLDAP-TOOLS Configuration (default are ok for a RedHat)
#
##############################################################################

# Allows not to use smbpasswd (if $with_smbpasswd == 0 in smbldap_conf.pm) but
# prefer mkntpwd... most of the time, it&#39;s a wise choice :-)
$with_smbpasswd = 0;
$smbpasswd = &#34;/usr/bin/smbpasswd&#34;;
$mk_ntpasswd = &#34;/usr/local/sbin/mkntpwd&#34;;

$ldap_path = &#34;/usr/bin&#34;;
$ldap_opts = &#34;-x&#34;;
$ldapsearch = &#34;$ldap_path/ldapsearch $ldap_opts -h $slaveLDAP -D &#39;$slaveDN&#39; -w &#39;$slavePw&#39;&#34;;
$ldapsearchnobind = &#34;$ldap_path/ldapsearch $ldap_opts -h $slaveLDAP&#34;;
$ldapmodify = &#34;$ldap_path/ldapmodify $ldap_opts -h $masterLDAP -D &#39;$masterDN&#39; -w &#39;$masterPw&#39;&#34;;
$ldappasswd = &#34;$ldap_path/ldappasswd $ldap_opts -h $masterLDAP -D &#39;$masterDN&#39; -w &#39;$masterPw&#39;&#34;;
$ldapadd = &#34;$ldap_path/ldapadd $ldap_opts -h $masterLDAP -D &#39;$masterDN&#39; -w &#39;$masterPw&#39;&#34;;
$ldapdelete = &#34;$ldap_path/ldapdelete $ldap_opts -h $masterLDAP -D &#39;$masterDN&#39; -w &#39;$masterPw&#39;&#34;;
$ldapmodrdn = &#34;$ldap_path/ldapmodrdn $ldap_opts -h $masterLDAP -D &#39;$masterDN&#39; -w &#39;$masterPw&#39;&#34;;


1;

# - The End
</programlisting>

      <calloutlist>
        <callout arearefs="tc-ldaproot-co" id="tc-ldaproot">
          <para>Root suffices of LDAP (as in slapd.conf)</para>
        </callout>

        <callout arearefs="tc-usersname-co" id="tc-usersname">
          <para>Name of LDAP directory holding all users</para>
        </callout>

        <callout arearefs="tc-compsname-co" id="tc-compsname">
          <para>Name of LDAP directory to place computer accounts.</para>
        </callout>

        <callout arearefs="tc-groupsname-co" id="tc-groupsname">
          <para>Name of the LDAP directory holding all domain groups</para>
        </callout>

        <callout arearefs="tc-binddn-co" id="tc-binddn">
          <para>The name of the rootdn to use to bind to the LDAP directory</para>
        </callout>

        <callout arearefs="tc-bindpwd-co" id="tc-bindpwd">
          <para>The password of the rootDN as you&#39;ve set in slapd.conf</para>
        </callout>

        <callout arearefs="tc-defshell-co" id="tc-defshell">
          <para>Default shell of all new created accounts</para>
        </callout>

        <callout arearefs="tc-defusergid-co" id="tc-defusergid">
          <para>Default Group ID of all users created</para>
        </callout>

        <callout arearefs="tc-defcompgid-co" id="tc-defcompgid">
          <para>Default Group ID (GID) of computers to be given by the scripts</para>
        </callout>

        <callout arearefs="tc-skeldirpath-co" id="tc-skeldirpath">
          <para>Location of home directory skeleton for all new users</para>
        </callout>

        <callout arearefs="tc-homeshare-co" id="tc-homeshare">
          <para>Sharename of home</para>
        </callout>

        <callout arearefs="tc-profileshare-co" id="tc-profileshare">
          <para>Sharename of profile shares</para>
        </callout>

        <callout arearefs="tc-homedrive-co" id="tc-homedrive">
          <para>Driveletter for home directory</para>
        </callout>

        <callout arearefs="tc-script-co" id="tc-script">
          <para>Name of script for all users</para>
        </callout>
      </calloutlist>
    </example>
  </appendix>

  <appendix>
    <title>Config files</title>

    <para>These are the final versions of the configuration files mentioned in
    my articles. They do not represent final-optimized versions - they are
    simplistic and minimal versions in the spirit of the article, provided
    here in one place - far from a production grade configuration.</para>

    <example id="baseldif">
      <title>base.ldif - basic directory structure</title>

      <programlisting>
TODO: FIX ME
</programlisting>

      <para>This base.ldif does not include groups since I create them using
      the smbldap-tools</para>
    </example>

    <example id="libnssldap">
      <title>/etc/libnss-ldap.conf</title>

      <programlisting>
######################### /etc/libnss-ldap.conf ########################
host localhost
base ou=Users,dc=e-mf,dc=net
uri ldap://10.0.0.33 <lineannotation>host address</lineannotation>
ldap_version 3

binddn cn=nss,dc=e-mf,dc=net <lineannotation>the nss user you added previously</lineannotation>
bindpw qwerty

#nss_base_passwd ou=Users,dc=e-mf,dc=net
nss_base_passwd dc=e-mf,dc=net  <lineannotation>root suffix - since we have accounts in two places (?)</lineannotation>
nss_base_group  ou=Groups,dc=e-mf,dc=net <lineannotation>where to store groups</lineannotation>
#######################################################################
</programlisting>

      <para>src: <xref linkend="amers03a" /></para>
    </example>

    <example id="pamldap">
      <title>/etc/pam_ldap.conf</title>

      <programlisting>
########################## /etc/pam_ldap.conf #########################
# http://homex.subnet.at/~max/ldap/
#
# pam_ldap.conf for all client machines

host virtdeb <lineannotation>enter hostname, base LDAP surfix, host address...</lineannotation>
base dc=e-mf,dc=net
uri ldap://10.0.0.33/
ldap_version 3

rootbinddn cn=Manager,dc=e-mf,dc=net <lineannotation>...and rootdn to access</lineannotation>

pam_password crypt
#######################################################################
</programlisting>

      <para>src: <xref linkend="amers03a" /></para>
    </example>

    <example id="pamdssh">
      <title>/etc/pam.d/ssh</title>

      <programlisting>
#%PAM-1.0
auth       required     pam_env.so
#auth       required     pam_nologin.so
auth       sufficient     pam_ldap.so
auth	   required	pam_unix.so

account    sufficient   pam_ldap.so
account    required     pam_unix.so

session    sufficient   pam_ldap.so
session    required     pam_unix.so
session    optional     pam_lastlog.so # [1]
session    optional     pam_motd.so # [1]
session    optional     pam_mail.so standard noenv # [1]
session    required     pam_limits.so

password   sufficient   pam_ldap.so
password   required     pam_unix.so

# Alternate strength checking for password. Note that this
# requires the libpam-cracklib package to be installed.
# You will need to comment out the password line above and
# uncomment the next two in order to use this.
#
# password required       pam_cracklib.so retry=3 minlen=6 difok=3
# password required       pam_unix.so use_authtok nullok md5
</programlisting>

      <para>Note the changes to original. src: <xref linkend="amers03a" /></para>
    </example>

    <example id="pamdpasswd">
      <title>/etc/pam.d/passwd</title>

      <programlisting>
#
# The PAM configuration file for the Shadow `passwd&#39; service
#

# The standard Unix authentication modules, used with NIS (man nsswitch) as
# well as normal /etc/passwd and /etc/shadow entries. For the login service,
# this is only used when the password expires and must be changed, so make
# sure this one and the one in /etc/pam.d/login are the same. The &#34;nullok&#34;
# option allows users to change an empty password, else empty passwords are
# treated as locked accounts.
#
# (Add `md5&#39; after the module name to enable MD5 passwords the same way that
# `MD5_CRYPT_ENAB&#39; would do under login.defs).
#
# The &#34;obscure&#34; option replaces the old `OBSCURE_CHECKS_ENAB&#39; option in
# login.defs. Also the &#34;min&#34; and &#34;max&#34; options enforce the length of the
# new password.


password     sufficient      pam_ldap.so
password     required        pam_unix.so nullok obscure min=4 max=8 md5

# Alternate strength checking for password. Note that this
# requires the libpam-cracklib package to be installed.
# You will need to comment out the password line above and
# uncomment the next two in order to use this.
# (Replaces the `OBSCURE_CHECKS_ENAB&#39;, `CRACKLIB_DICTPATH&#39;)
#
# password required       pam_cracklib.so retry=3 minlen=6 difok=3
# password required       pam_unix.so use_authtok nullok md5</programlisting>
    </example>

    <para>Note the changes to original. src: <xref linkend="amers03a" /></para>

    <example id="nsswitchconf">
      <title>/etc/nsswitch.conf</title>

      <programlisting>
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc&#39; and `info&#39; packages installed, try:
# `info libc &#34;Name Service Switch&#34;&#39; for information about this file.

passwd:         ldap compat
group:          ldap compat
shadow:         ldap compat

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis
</programlisting>

      <para>Note the changes to original. src: <xref linkend="amers03a" /></para>
    </example>
  </appendix>

  <bibliography>
    <bibliodiv>
      <title>Top reads!</title>

      <biblioentry id="amers03a">
        <abbrev>amers03a</abbrev>

        <title>Using OpenLDAP on Debian Woody to serve Linux and Samba users</title>

        <author>
          <firstname>Markus</firstname>

          <surname>Amersdorfer</surname>
        </author>

        <date>August 2003</date>

        <releaseinfo>URL: <ulink url="http://homex.subnet.at/~max/ldap/"></ulink>
        <emphasis>Recommended!</emphasis> If you don&#39;t like me, this is
        where you should go. Best of all writings I&#39;ve looked at.</releaseinfo>
      </biblioentry>

      <biblioentry id="amers03b">
        <abbrev>amers03b</abbrev>

        <title>How to join a Windows client to a domain</title>

        <author>
          <firstname>Markus</firstname>

          <surname>Amersdorfer</surname>
        </author>

        <date>August 2003</date>

        <releaseinfo><ulink
        url="http://homex.subnet.at/~max/comp-06_samba-pdc.shtml"></ulink></releaseinfo>
      </biblioentry>

      <biblioentry id="idealx1">
        <title>Samba LDAP How to</title>

        <author>
          <firstname>Olivier</firstname>
          <surname>Lemaire</surname>
        </author>

        <publisher>
          <publishername>IDEALX S.A.S</publishername>
        </publisher>

        <releaseinfo>URL: <ulink url="http://www.idealx.org/prj/samba/samba-ldap-howto.pdf"></ulink> If not
        the first than one of the first samba LDAP how-to&#39;s. Almost all
        other articles have some info from this one. (Project info: <ulink url="http://www.idealx.org/prj/samba/index.en.html"/></releaseinfo>
      </biblioentry>

      <biblioentry id="howto3">
        <abbrev>howtono3</abbrev>
        <author>
        <firstname>David</firstname>
        <surname>Trask</surname>
        </author>

        <title>The latest SAMBA-LDAP-PDC How-to (another one)</title>

        <releaseinfo> URL (PDF): <ulink url="http://www.vcs.u52.k12.me.us/LDAP/The_SAMBA-LDAP_How-to.pdf"/>
        URL (HTML): <ulink
        url="http://www.vcs.u52.k12.me.us/LDAP/The_SAMBA-LDAP_How-to.html"></ulink>
        The only simple info on editing the idealx scripts config file,
        smbldap_conf.pm.</releaseinfo>
      </biblioentry>

      <biblioentry>
        <releaseinfo>URL: <ulink
        url="http://www.mandrakesecure.net/en/docs/samba-pdc.php"></ulink></releaseinfo>

        <publisher>
          <publishername>Mandrake</publishername>
        </publisher>
      </biblioentry>

      <biblioentry>
        <releaseinfo>URL: <ulink
        url="http://network.gouldacademy.org/randomfiles/sambaldap/SambaLDAP/index.html"></ulink>
        Nice and concise, some info pieces here that are no where else - on
        the idealx scripts.</releaseinfo>
      </biblioentry>
    </bibliodiv>

    <bibliodiv>
      <title>Runners up!</title>

      <biblioentry id="icoup">
        <abbrev>icoup03</abbrev>

        <title>SAMBA (v 2.2) PDC LDAP v.3 howto (unofficial)</title>

        <author>
          <firstname>Ignacio</firstname>

          <surname>Coupeau</surname>
        </author>

        <date>May 2003</date>

        <publisher>
          <publishername>University of Navarra</publishername>
        </publisher>

        <releaseinfo>URL: <ulink
        url="http://www.unav.es/cti/ldap-smb/ldap-smb-2_2-howto.html"></ulink>
        Mr Coupeau obviously has alot of experience and previously this was
        one of the few sources of info available (I think). Now there is alot
        more available and even though some valuable info is available here
        and no where else, it is crudely written and unstructured.</releaseinfo>
      </biblioentry>

      <biblioentry>
        <title>Using an LDAP Directory for Samba Authentication</title>

        <author>
          <firstname>Tom</firstname>

          <surname>Syroid</surname>
        </author>

        <publisher>
          <publishername>IBM Developerworks</publishername>
        </publisher>

        <releaseinfo>URL: <ulink
        url="http://www.ibm.com/servers/esdd/tutorials/smb_ldap/smb_ldap-ltr.pdf"></ulink>
        Not bad but like most stuff very Red Hat focused, I started out using
        this because it is well written and simple. Mr Syroid also has a good
        article on samba as a PDC (no LDAP).</releaseinfo>
      </biblioentry>
    </bibliodiv>

    <bibliodiv>
      <title>Other references</title>

      <biblioentry>
        <title>Samba LDAP Debian How-to</title>

        <releaseinfo>URL: <ulink
        url="http://howto.aphroland.de/HOWTO/LDAP/FrontPage"></ulink> Nice but
        technical. Amersdorfer seems to have used this one to some extent.</releaseinfo>
      </biblioentry>

      <biblioentry>
        <releaseinfo>URL: <ulink
        url="http://www-106.ibm.com/developerworks/linux/library/l-samba/"></ulink></releaseinfo>
      </biblioentry>

      <biblioentry>
        <title>LDAP System Administration</title>

        <publisher>
          <publishername>O&#39;Reilly</publishername>
        </publisher>

        <isbn>1-56592-491-6</isbn>

        <author>
          <firstname>Gerald</firstname>

          <surname>Carter</surname>
        </author>

        <releaseinfo>Good for explaining LDAP, OpenLDAP, Linux authentication,
        etc. Not much on samba though.</releaseinfo>
      </biblioentry>
    </bibliodiv>
  </bibliography>

  <glossary>
    <glossdiv>
      <title>Some terms used</title>

      <glossentry id="net">
        <glossterm>NET command (windows)</glossterm>

        <glossdef>
          <para>Actually <emphasis>many</emphasis> commands to view, test,
          administer and manipulate windows network access from a windows
          machine. Examples include: net view, net use, net print, etc.</para>
        </glossdef>
      </glossentry>

      <glossentry id="nss">
        <glossterm>Name Service Switch</glossterm>

        <acronym>NSS</acronym>

        <glossdef>
          <para>handles mapping between names and numbers, dealing with groups
          and access. See <ulink
          url="http://nakedape.cc/wiki/index.cgi/NameServiceSwitch">nakedape
          wikipedia</ulink>.</para>
        </glossdef>
      </glossentry>

      <glossentry id="pam">
        <glossterm>Pluggable Authentication Module</glossterm>

        <acronym>PAM</acronym>

        <glossdef>
          <para>handles authentication for access to different resources on
          the machine. Like so many things in Linux, you configure it a little
          differently between distros (because they include different
          options).</para>
        </glossdef>
      </glossentry>

      <glossentry id="swat">
        <glossterm>Samba Web Administration T (something)</glossterm>

        <acronym>SWAT</acronym>

        <glossdef>
          <para>A web based administration program for samba, installed by
          default - but not enabled by default!</para>
        </glossdef>
      </glossentry>

      <glossentry id="smbconf">
        <glossterm>Samba configuration file</glossterm>

        <acronym>smb.conf</acronym>

        <glossdef>
          <para>The samba configuration file, in Debian located in
          /etc/samba/. The default is nicely documented, although I recommend
          glancing at it using SWAT - and clicking &#34;advanced view&#34;,
          then use the help links to read up on interesting looking
          parameters.</para>
        </glossdef>
      </glossentry>

      <glossentry id="afaics">
        <glossterm>As Far As I Can See</glossterm>

        <acronym>AFAICS</acronym>

        <glossdef>
          <para>Extremely silly but useful and after a while more so
          (addictive) typical newspost and netspeak short.</para>
        </glossdef>
      </glossentry>
    </glossdiv>
  </glossary>
</book>