1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5 >Storing Samba's User/Machine Account information in an LDAP Directory</TITLE
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.77"><LINK
10 TITLE="SAMBA Project Documentation"
11 HREF="samba-howto-collection.html"><LINK
13 TITLE="Optional configuration"
14 HREF="optional.html"><LINK
16 TITLE="Stackable VFS modules"
19 TITLE="HOWTO Access Samba source code via CVS"
20 HREF="cvs-access.html"></HEAD
31 SUMMARY="Header navigation table"
40 >SAMBA Project Documentation</TH
62 HREF="cvs-access.html"
75 NAME="SAMBA-LDAP-HOWTO"
77 >Chapter 20. Storing Samba's User/Machine Account information in an LDAP Directory</H1
87 >This document describes how to use an LDAP directory for storing Samba user
88 account information traditionally stored in the smbpasswd(5) file. It is
89 assumed that the reader already has a basic understanding of LDAP concepts
90 and has a working directory server already installed. For more information
91 on LDAP architectures and Directories, please refer to the following sites.</P
98 HREF="http://www.openldap.org/"
100 >http://www.openldap.org/</A
105 >iPlanet Directory Server - <A
106 HREF="http://iplanet.netscape.com/directory"
108 >http://iplanet.netscape.com/directory</A
114 HREF="http://www.ora.com/"
116 >O'Reilly Publishing</A
118 a guide to LDAP for System Administrators which has a planned release date of
119 early summer, 2002.</P
121 >Two additional Samba resources which may prove to be helpful are</P
128 HREF="http://www.unav.es/cti/ldap-smb/ldap-smb-2_2-howto.html"
130 >Samba-PDC-LDAP-HOWTO</A
132 maintained by Ignacio Coupeau.</P
136 >The NT migration scripts from <A
137 HREF="http://samba.idealx.org/"
141 geared to manage users and group in such a Samba-LDAP Domain Controller configuration.
153 >20.2. Introduction</H1
155 >Traditionally, when configuring <A
156 HREF="smb.conf.5.html#ENCRYPTPASSWORDS"
164 information such as username, LM/NT password hashes, password change times, and account
165 flags have been stored in the <TT
168 > file. There are several
169 disadvantages to this approach for sites with very large numbers of users (counted
170 in the thousands).</P
176 >The first is that all lookups must be performed sequentially. Given that
177 there are approximately two lookups per domain logon (one for a normal
178 session connection such as when mapping a network drive or printer), this
179 is a performance bottleneck for lareg sites. What is needed is an indexed approach
180 such as is used in databases.</P
184 >The second problem is that administrators who desired to replicate a
185 smbpasswd file to more than one Samba server were left to use external
193 and wrote custom, in-house scripts.</P
197 >And finally, the amount of information which is stored in an
198 smbpasswd entry leaves no room for additional attributes such as
199 a home directory, password expiration time, or even a Relative
204 >As a result of these defeciencies, a more robust means of storing user attributes
205 used by smbd was developed. The API which defines access to user accounts
206 is commonly referred to as the samdb interface (previously this was called the passdb
207 API, and is still so named in the CVS trees). In Samba 2.2.3, enabling support
208 for a samdb backend (e.g. <TT
219 >) requires compile time support.</P
221 >When compiling Samba to include the <TT
227 option, smbd (and associated tools) will store and lookup user accounts in
228 an LDAP directory. In reality, this is very easy to understand. If you are
229 comfortable with using an smbpasswd file, simply replace "smbpasswd" with
230 "LDAP directory" in all the documentation.</P
232 >There are a few points to stress about what the <TT
238 does not provide. The LDAP support referred to in the this documentation does not
245 >A means of retrieving user account information from
246 an Windows 2000 Active Directory server.</P
250 >A means of replacing /etc/passwd.</P
254 >The second item can be accomplished by using LDAP NSS and PAM modules. LGPL
255 versions of these libraries can be obtained from PADL Software
257 HREF="http://www.padl.com/"
259 >http://www.padl.com/</A
261 the details of configuring these packages are beyond the scope of this document.</P
270 >20.3. Supported LDAP Servers</H1
272 >The LDAP samdb code in 2.2.3 has been developed and tested using the OpenLDAP
273 2.0 server and client libraries. The same code should be able to work with
274 Netscape's Directory Server and client SDK. However, due to lack of testing
275 so far, there are bound to be compile errors and bugs. These should not be
276 hard to fix. If you are so inclined, please be sure to forward all patches to
278 HREF="samba-patches@samba.org"
280 >samba-patches@samba.org</A
283 HREF="jerry@samba.org"
295 >20.4. Schema and Relationship to the RFC 2307 posixAccount</H1
297 >Samba 2.2.3 includes the necessary schema file for OpenLDAP 2.0 in
300 >examples/LDAP/samba.schema</TT
301 >. (Note that this schema
302 file has been modified since the experimental support initially included
303 in 2.2.2). The sambaAccount objectclass is given here:</P
306 CLASS="PROGRAMLISTING"
307 >objectclass ( 1.3.1.5.1.4.1.7165.2.2.2 NAME 'sambaAccount' SUP top STRUCTURAL
310 MAY ( cn $ lmPassword $ ntPassword $ pwdLastSet $ logonTime $
311 logoffTime $ kickoffTime $ pwdCanChange $ pwdMustChange $ acctFlags $
312 displayName $ smbHome $ homeDrive $ scriptPath $ profilePath $
313 description $ userWorkstations $ primaryGroupID $ domain ))</PRE
316 >The samba.schema file has been formatted for OpenLDAP 2.0. The OID's are
317 owned by the Samba Team and as such is legal to be openly published.
318 If you translate the schema to be used with Netscape DS, please
319 submit the modified schema file as a patch to <A
320 HREF="jerry@samba.org"
325 >Just as the smbpasswd file is mean to store information which supplements a
329 > entry, so is the sambaAccount object
330 meant to supplement the UNIX user account information. A sambaAccount is a
334 > objectclass so it can be stored individually
335 in the directory. However, there are several fields (e.g. uid) which overlap
336 with the posixAccount objectclass outlined in RFC2307. This is by design.</P
338 >In order to store all user account information (UNIX and Samba) in the directory,
339 it is necessary to use the sambaAccount and posixAccount objectclasses in
340 combination. However, smbd will still obtain the user's UNIX account
341 information via the standard C library calls (e.g. getpwnam(), et. al.).
342 This means that the Samba server must also have the LDAP NSS library installed
343 and functioning correctly. This division of information makes it possible to
344 store all Samba account information in LDAP, but still maintain UNIX account
345 information in NIS while the network is transitioning to a full LDAP infrastructure.</P
354 >20.5. Configuring Samba with LDAP</H1
362 >20.5.1. OpenLDAP configuration</H2
364 >To include support for the sambaAccount object in an OpenLDAP directory
365 server, first copy the samba.schema file to slapd's configuration directory.</P
372 >cp samba.schema /etc/openldap/schema/</B
375 >Next, include the <TT
382 The sambaAccount object contains two attributes which depend upon other schema
383 files. The 'uid' attribute is defined in <TT
387 the 'displayName' attribute is defined in the <TT
389 >inetorgperson.schema</TT
391 file. Both of these must be included before the <TT
397 CLASS="PROGRAMLISTING"
398 >## /etc/openldap/slapd.conf
400 ## schema files (core.schema is required by default)
401 include /etc/openldap/schema/core.schema
403 ## needed for sambaAccount
404 include /etc/openldap/schema/cosine.schema
405 include /etc/openldap/schema/inetorgperson.schema
406 include /etc/openldap/schema/samba.schema
408 ## uncomment this line if you want to support the RFC2307 (NIS) schema
409 ## include /etc/openldap/schema/nis.schema
414 >It is recommended that you maintain some indices on some of the most usefull attributes,
415 like in the following example, to speed up searches made on sambaAccount objectclasses
416 (and possibly posixAccount and posixGroup as well).</P
419 CLASS="PROGRAMLISTING"
420 ># Indices to maintain
421 ## required by OpenLDAP 2.0
424 ## support pb_getsampwnam()
426 ## support pdb_getsambapwrid()
429 ## uncomment these if you are storing posixAccount and
430 ## posixGroup entries in the directory as well
434 ##index memberUid eq</PRE
444 >20.5.2. Configuring Samba</H2
446 >The following parameters are available in smb.conf only with <TT
452 was included with compiling Samba.</P
459 HREF="smb.conf.5.html#LDAPSSL"
467 HREF="smb.conf.5.html#LDAPSERVER"
475 HREF="smb.conf.5.html#LDAPADMINDN"
483 HREF="smb.conf.5.html#LDAPSUFFIX"
491 HREF="smb.conf.5.html#LDAPFILTER"
499 HREF="smb.conf.5.html#LDAPPORT"
506 >These are described in the <A
507 HREF="smb.conf.5.html"
511 page and so will not be repeated here. However, a sample smb.conf file for
512 use with an LDAP directory could appear as</P
515 CLASS="PROGRAMLISTING"
516 >## /usr/local/samba/lib/smb.conf
519 encrypt passwords = yes
521 netbios name = TASHTEGO
524 # ldap related parameters
526 # define the DN to use when binding to the directory servers
527 # The password for this DN is not stored in smb.conf. Rather it
528 # must be set by using 'smbpasswd -w <TT
534 # passphrase in the secrets.tdb file. If the "ldap admin dn" values
535 # changes, this password will need to be reset.
536 ldap admin dn = "cn=Samba Manager,ou=people,dc=samba,dc=org"
538 # specify the LDAP server's hostname (defaults to locahost)
539 ldap server = ahab.samba.org
541 # Define the SSL option when connecting to the directory
542 # ('off', 'start tls', or 'on' (default))
545 # define the port to use in the LDAP session (defaults to 636 when
549 # specify the base DN to use when searching the directory
550 ldap suffix = "ou=people,dc=samba,dc=org"
552 # generally the default ldap search filter is ok
553 # ldap filter = "(&(uid=%u)(objectclass=sambaAccount))"</PRE
564 >20.6. Accounts and Groups management</H1
566 >As users accounts are managed thru the sambaAccount objectclass, you should
567 modify you existing administration tools to deal with sambaAccount attributes.</P
569 >Machines accounts are managed with the sambaAccount objectclass, just
570 like users accounts. However, it's up to you to stored thoses accounts
571 in a different tree of you LDAP namespace: you should use
572 "ou=Groups,dc=plainjoe,dc=org" to store groups and
573 "ou=People,dc=plainjoe,dc=org" to store users. Just configure your
574 NSS and PAM accordingly (usually, in the /etc/ldap.conf configuration
577 >In Samba release 2.2.3, the group management system is based on posix
578 groups. This meand that Samba make usage of the posixGroup objectclass.
579 For now, there is no NT-like group system management (global and local
589 >20.7. Security and sambaAccount</H1
591 >There are two important points to remember when discussing the security
592 of sambaAccount entries in the directory.</P
604 > retrieve the lmPassword or
605 ntPassword attribute values over an unencrypted LDAP session.</P
615 > allow non-admin users to
616 view the lmPassword or ntPassword attribute values.</P
620 >These password hashes are clear text equivalents and can be used to impersonate
621 the user without deriving the original clear text strings. For more information
622 on the details of LM/NT password hashes, refer to the <A
623 HREF="ENCRYPTION.html"
625 >ENCRYPTION chapter</A
626 > of the Samba-HOWTO-Collection.</P
628 >To remedy the first security issue, the "ldap ssl" smb.conf parameter defaults
629 to require an encrypted session (<B
633 the default port of 636
634 when contacting the directory server. When using an OpenLDAP 2.0 server, it
635 is possible to use the use the StartTLS LDAP extended operation in the place of
636 LDAPS. In either case, you are strongly discouraged to disable this security
642 >Note that the LDAPS protocol is deprecated in favor of the LDAPv3 StartTLS
643 extended operation. However, the OpenLDAP library still provides support for
644 the older method of securing communication between clients and servers.</P
646 >The second security precaution is to prevent non-administrative users from
647 harvesting password hashes from the directory. This can be done using the
654 CLASS="PROGRAMLISTING"
655 >## allow the "ldap admin dn" access, but deny everyone else
656 access to attrs=lmPassword,ntPassword
657 by dn="cn=Samba Admin,ou=people,dc=plainjoe,dc=org" write
668 >20.8. LDAP specials attributes for sambaAccounts</H1
670 >The sambaAccount objectclass is composed of the following attributes:</P
679 >: the LANMAN password 16-byte hash stored as a character
680 representation of a hexidecimal string.</P
687 >: the NT password hash 16-byte stored as a character
688 representation of a hexidecimal string.</P
695 >: The integer time in seconds since 1970 when the
702 > attributes were last set.
710 >: string of 11 characters surrounded by square brackets []
711 representing account flags such as U (user), W(workstation), X(no password expiration), and
719 >: Integer value currently unused</P
726 >: Integer value currently unused</P
733 >: Integer value currently unused</P
740 >: Integer value currently unused</P
747 >: Integer value currently unused</P
754 >: specifies the drive letter to which to map the
755 UNC path specified by homeDirectory. The drive letter must be specified in the form "X:"
756 where X is the letter of the drive to map. Refer to the "logon drive" parameter in the
757 smb.conf(5) man page for more information.</P
764 >: The scriptPath property specifies the path of
765 the user's logon script, .CMD, .EXE, or .BAT file. The string can be null. The path
766 is relative to the netlogon share. Refer to the "logon script" parameter in the
767 smb.conf(5) man page for more information.</P
774 >: specifies a path to the user's profile.
775 This value can be a null string, a local absolute path, or a UNC path. Refer to the
776 "logon path" parameter in the smb.conf(5) man page for more information.</P
783 >: The homeDirectory property specifies the path of
784 the home directory for the user. The string can be null. If homeDrive is set and specifies
785 a drive letter, homeDirectory should be a UNC path. The path must be a network
786 UNC path of the form \\server\share\directory. This value can be a null string.
787 Refer to the "logon home" parameter in the smb.conf(5) man page for more information.
795 >: character string value currently unused.
803 >: the integer representation of the user's relative identifier
811 >: the relative identifier (RID) of the primary group
816 >The majority of these parameters are only used when Samba is acting as a PDC of
817 a domain (refer to the <A
818 HREF="Samba-PDC-HOWTO.html"
822 how to configure Samba as a Primary Domain Controller). The following four attributes
823 are only stored with the sambaAccount entry if the values are non-default values:</P
845 >These attributes are only stored with the sambaAccount entry if
846 the values are non-default values. For example, assume TASHTEGO has now been
847 configured as a PDC and that <B
849 >logon home = \\%L\%u</B
854 > file. When a user named "becky" logons to the domain,
860 > string is expanded to \\TASHTEGO\becky.
861 If the smbHome attribute exists in the entry "uid=becky,ou=people,dc=samba,dc=org",
862 this value is used. However, if this attribute does not exist, then the value
868 > parameter is used in its place. Samba
869 will only write the attribute value to the directory entry is the value is
870 something other than the default (e.g. \\MOBY\becky).</P
879 >20.9. Example LDIF Entries for a sambaAccount</H1
881 >The following is a working LDIF with the inclusion of the posixAccount objectclass:</P
884 CLASS="PROGRAMLISTING"
885 >dn: uid=guest2, ou=people,dc=plainjoe,dc=org
886 ntPassword: 878D8014606CDA29677A44EFA1353FC7
887 pwdMustChange: 2147483647
889 lmPassword: 552902031BEDE9EFAAD3B435B51404EE
890 pwdLastSet: 1010179124
892 objectClass: sambaAccount
894 kickoffTime: 2147483647
896 logoffTime: 2147483647
901 >The following is an LDIF entry for using both the sambaAccount and
902 posixAccount objectclasses:</P
905 CLASS="PROGRAMLISTING"
906 >dn: uid=gcarter, ou=people,dc=plainjoe,dc=org
908 displayName: Gerald Carter
909 lmPassword: 552902031BEDE9EFAAD3B435B51404EE
911 objectClass: posixAccount
912 objectClass: sambaAccount
914 userPassword: {crypt}BpM2ej8Rkzogo
918 loginShell: /bin/bash
919 logoffTime: 2147483647
921 kickoffTime: 2147483647
922 pwdLastSet: 1010179230
924 homeDirectory: /home/tashtego/gcarter
926 pwdMustChange: 2147483647
927 ntPassword: 878D8014606CDA29677A44EFA1353FC7</PRE
939 >Please mail all comments regarding this HOWTO to <A
940 HREF="mailto:jerry@samba.org"
943 >. This documents was
944 last updated to reflect the Samba 2.2.3 release. </P
952 SUMMARY="Footer navigation table"
972 HREF="samba-howto-collection.html"
981 HREF="cvs-access.html"
991 >Stackable VFS modules</TD
1005 >HOWTO Access Samba source code via CVS</TD