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.76b+
11 TITLE="SAMBA Project Documentation"
12 HREF="Samba-HOWTO.html"><LINK
14 TITLE="How to Act as a Backup Domain Controller in a Purely Samba Controlled Domain"
15 HREF="samba-bdc.html"><LINK
17 TITLE="Improved browsing in samba"
18 HREF="improved-browsing.html"></HEAD
29 SUMMARY="Header navigation table"
38 >SAMBA Project Documentation</TH
60 HREF="improved-browsing.html"
73 NAME="SAMBA-LDAP-HOWTO">Chapter 14. Storing Samba's User/Machine Account information in an LDAP Directory</H1
79 NAME="AEN2350">14.1. Purpose</H1
81 >This document describes how to use an LDAP directory for storing Samba user
82 account information traditionally stored in the smbpasswd(5) file. It is
83 assumed that the reader already has a basic understanding of LDAP concepts
84 and has a working directory server already installed. For more information
85 on LDAP architectures and Directories, please refer to the following sites.</P
92 HREF="http://www.openldap.org/"
94 >http://www.openldap.org/</A
99 >iPlanet Directory Server - <A
100 HREF="http://iplanet.netscape.com/directory"
102 >http://iplanet.netscape.com/directory</A
108 HREF="http://www.ora.com/"
110 >O'Reilly Publishing</A
112 a guide to LDAP for System Administrators which has a planned release date of
113 early summer, 2002.</P
115 >Two additional Samba resources which may prove to be helpful are</P
122 HREF="http://www.unav.es/cti/ldap-smb/ldap-smb-2_2-howto.html"
124 >Samba-PDC-LDAP-HOWTO</A
126 maintained by Ignacio Coupeau.</P
130 >The NT migration scripts from <A
131 HREF="http://samba.idealx.org/"
135 geared to manage users and group in such a Samba-LDAP Domain Controller configuration.
145 NAME="AEN2370">14.2. Introduction</H1
147 >Traditionally, when configuring <A
148 HREF="smb.conf.5.html#ENCRYPTPASSWORDS"
156 information such as username, LM/NT password hashes, password change times, and account
157 flags have been stored in the <TT
160 > file. There are several
161 disadvantages to this approach for sites with very large numbers of users (counted
162 in the thousands).</P
168 >The first is that all lookups must be performed sequentially. Given that
169 there are approximately two lookups per domain logon (one for a normal
170 session connection such as when mapping a network drive or printer), this
171 is a performance bottleneck for lareg sites. What is needed is an indexed approach
172 such as is used in databases.</P
176 >The second problem is that administrators who desired to replicate a
177 smbpasswd file to more than one Samba server were left to use external
185 and wrote custom, in-house scripts.</P
189 >And finally, the amount of information which is stored in an
190 smbpasswd entry leaves no room for additional attributes such as
191 a home directory, password expiration time, or even a Relative
196 >As a result of these defeciencies, a more robust means of storing user attributes
197 used by smbd was developed. The API which defines access to user accounts
198 is commonly referred to as the samdb interface (previously this was called the passdb
199 API, and is still so named in the CVS trees). In Samba 2.2.3, enabling support
200 for a samdb backend (e.g. <TT
211 >) requires compile time support.</P
213 >When compiling Samba to include the <TT
219 option, smbd (and associated tools) will store and lookup user accounts in
220 an LDAP directory. In reality, this is very easy to understand. If you are
221 comfortable with using an smbpasswd file, simply replace "smbpasswd" with
222 "LDAP directory" in all the documentation.</P
224 >There are a few points to stress about what the <TT
230 does not provide. The LDAP support referred to in the this documentation does not
237 >A means of retrieving user account information from
238 an Windows 2000 Active Directory server.</P
242 >A means of replacing /etc/passwd.</P
246 >The second item can be accomplished by using LDAP NSS and PAM modules. LGPL
247 versions of these libraries can be obtained from PADL Software
249 HREF="http://www.padl.com/"
251 >http://www.padl.com/</A
253 the details of configuring these packages are beyond the scope of this document.</P
260 NAME="AEN2399">14.3. Supported LDAP Servers</H1
262 >The LDAP samdb code in 2.2.3 has been developed and tested using the OpenLDAP
263 2.0 server and client libraries. The same code should be able to work with
264 Netscape's Directory Server and client SDK. However, due to lack of testing
265 so far, there are bound to be compile errors and bugs. These should not be
266 hard to fix. If you are so inclined, please be sure to forward all patches to
268 HREF="samba-patches@samba.org"
270 >samba-patches@samba.org</A
273 HREF="jerry@samba.org"
283 NAME="AEN2404">14.4. Schema and Relationship to the RFC 2307 posixAccount</H1
285 >Samba 2.2.3 includes the necessary schema file for OpenLDAP 2.0 in
288 >examples/LDAP/samba.schema</TT
289 >. (Note that this schema
290 file has been modified since the experimental support initially included
291 in 2.2.2). The sambaAccount objectclass is given here:</P
294 CLASS="PROGRAMLISTING"
295 >objectclass ( 1.3.1.5.1.4.1.7165.2.2.2 NAME 'sambaAccount' SUP top STRUCTURAL
298 MAY ( cn $ lmPassword $ ntPassword $ pwdLastSet $ logonTime $
299 logoffTime $ kickoffTime $ pwdCanChange $ pwdMustChange $ acctFlags $
300 displayName $ smbHome $ homeDrive $ scriptPath $ profilePath $
301 description $ userWorkstations $ primaryGroupID $ domain ))</PRE
304 >The samba.schema file has been formatted for OpenLDAP 2.0. The OID's are
305 owned by the Samba Team and as such is legal to be openly published.
306 If you translate the schema to be used with Netscape DS, please
307 submit the modified schema file as a patch to <A
308 HREF="jerry@samba.org"
313 >Just as the smbpasswd file is mean to store information which supplements a
317 > entry, so is the sambaAccount object
318 meant to supplement the UNIX user account information. A sambaAccount is a
322 > objectclass so it can be stored individually
323 in the directory. However, there are several fields (e.g. uid) which overlap
324 with the posixAccount objectclass outlined in RFC2307. This is by design.</P
326 >In order to store all user account information (UNIX and Samba) in the directory,
327 it is necessary to use the sambaAccount and posixAccount objectclasses in
328 combination. However, smbd will still obtain the user's UNIX account
329 information via the standard C library calls (e.g. getpwnam(), et. al.).
330 This means that the Samba server must also have the LDAP NSS library installed
331 and functioning correctly. This division of information makes it possible to
332 store all Samba account information in LDAP, but still maintain UNIX account
333 information in NIS while the network is transitioning to a full LDAP infrastructure.</P
340 NAME="AEN2416">14.5. Configuring Samba with LDAP</H1
346 NAME="AEN2418">14.5.1. OpenLDAP configuration</H2
348 >To include support for the sambaAccount object in an OpenLDAP directory
349 server, first copy the samba.schema file to slapd's configuration directory.</P
356 >cp samba.schema /etc/openldap/schema/</B
359 >Next, include the <TT
366 The sambaAccount object contains two attributes which depend upon other schema
367 files. The 'uid' attribute is defined in <TT
371 the 'displayName' attribute is defined in the <TT
373 >inetorgperson.schema</TT
375 file. Both of these must be included before the <TT
381 CLASS="PROGRAMLISTING"
382 >## /etc/openldap/slapd.conf
384 ## schema files (core.schema is required by default)
385 include /etc/openldap/schema/core.schema
387 ## needed for sambaAccount
388 include /etc/openldap/schema/cosine.schema
389 include /etc/openldap/schema/inetorgperson.schema
390 include /etc/openldap/schema/samba.schema
392 ## uncomment this line if you want to support the RFC2307 (NIS) schema
393 ## include /etc/openldap/schema/nis.schema
398 >It is recommended that you maintain some indices on some of the most usefull attributes,
399 like in the following example, to speed up searches made on sambaAccount objectclasses
400 (and possibly posixAccount and posixGroup as well).</P
403 CLASS="PROGRAMLISTING"
404 ># Indices to maintain
405 ## required by OpenLDAP 2.0
408 ## support pb_getsampwnam()
410 ## support pdb_getsambapwrid()
413 ## uncomment these if you are storing posixAccount and
414 ## posixGroup entries in the directory as well
418 ##index memberUid eq</PRE
426 NAME="AEN2435">14.5.2. Configuring Samba</H2
428 >The following parameters are available in smb.conf only with <TT
434 was included with compiling Samba.</P
441 HREF="smb.conf.5.html#LDAPSSL"
449 HREF="smb.conf.5.html#LDAPSERVER"
457 HREF="smb.conf.5.html#LDAPADMINDN"
465 HREF="smb.conf.5.html#LDAPSUFFIX"
473 HREF="smb.conf.5.html#LDAPFILTER"
481 HREF="smb.conf.5.html#LDAPPORT"
488 >These are described in the <A
489 HREF="smb.conf.5.html"
493 page and so will not be repeated here. However, a sample smb.conf file for
494 use with an LDAP directory could appear as</P
497 CLASS="PROGRAMLISTING"
498 >## /usr/local/samba/lib/smb.conf
501 encrypt passwords = yes
503 netbios name = TASHTEGO
506 # ldap related parameters
508 # define the DN to use when binding to the directory servers
509 # The password for this DN is not stored in smb.conf. Rather it
510 # must be set by using 'smbpasswd -w <TT
516 # passphrase in the secrets.tdb file. If the "ldap admin dn" values
517 # changes, this password will need to be reset.
518 ldap admin dn = "cn=Samba Manager,ou=people,dc=samba,dc=org"
520 # specify the LDAP server's hostname (defaults to locahost)
521 ldap server = ahab.samba.org
523 # Define the SSL option when connecting to the directory
524 # ('off', 'start tls', or 'on' (default))
527 # define the port to use in the LDAP session (defaults to 636 when
531 # specify the base DN to use when searching the directory
532 ldap suffix = "ou=people,dc=samba,dc=org"
534 # generally the default ldap search filter is ok
535 # ldap filter = "(&(uid=%u)(objectclass=sambaAccount))"</PRE
544 NAME="AEN2463">14.6. Accounts and Groups management</H1
546 >As users accounts are managed thru the sambaAccount objectclass, you should
547 modify you existing administration tools to deal with sambaAccount attributes.</P
549 >Machines accounts are managed with the sambaAccount objectclass, just
550 like users accounts. However, it's up to you to stored thoses accounts
551 in a different tree of you LDAP namespace: you should use
552 "ou=Groups,dc=plainjoe,dc=org" to store groups and
553 "ou=People,dc=plainjoe,dc=org" to store users. Just configure your
554 NSS and PAM accordingly (usually, in the /etc/ldap.conf configuration
557 >In Samba release 2.2.3, the group management system is based on posix
558 groups. This meand that Samba make usage of the posixGroup objectclass.
559 For now, there is no NT-like group system management (global and local
567 NAME="AEN2468">14.7. Security and sambaAccount</H1
569 >There are two important points to remember when discussing the security
570 of sambaAccount entries in the directory.</P
582 > retrieve the lmPassword or
583 ntPassword attribute values over an unencrypted LDAP session.</P
593 > allow non-admin users to
594 view the lmPassword or ntPassword attribute values.</P
598 >These password hashes are clear text equivalents and can be used to impersonate
599 the user without deriving the original clear text strings. For more information
600 on the details of LM/NT password hashes, refer to the <A
601 HREF="ENCRYPTION.html"
603 >ENCRYPTION chapter</A
604 > of the Samba-HOWTO-Collection.</P
606 >To remedy the first security issue, the "ldap ssl" smb.conf parameter defaults
607 to require an encrypted session (<B
611 the default port of 636
612 when contacting the directory server. When using an OpenLDAP 2.0 server, it
613 is possible to use the use the StartTLS LDAP extended operation in the place of
614 LDAPS. In either case, you are strongly discouraged to disable this security
620 >Note that the LDAPS protocol is deprecated in favor of the LDAPv3 StartTLS
621 extended operation. However, the OpenLDAP library still provides support for
622 the older method of securing communication between clients and servers.</P
624 >The second security precaution is to prevent non-administrative users from
625 harvesting password hashes from the directory. This can be done using the
632 CLASS="PROGRAMLISTING"
633 >## allow the "ldap admin dn" access, but deny everyone else
634 access to attrs=lmPassword,ntPassword
635 by dn="cn=Samba Admin,ou=people,dc=plainjoe,dc=org" write
644 NAME="AEN2488">14.8. LDAP specials attributes for sambaAccounts</H1
646 >The sambaAccount objectclass is composed of the following attributes:</P
655 >: the LANMAN password 16-byte hash stored as a character
656 representation of a hexidecimal string.</P
663 >: the NT password hash 16-byte stored as a character
664 representation of a hexidecimal string.</P
671 >: The integer time in seconds since 1970 when the
678 > attributes were last set.
686 >: string of 11 characters surrounded by square brackets []
687 representing account flags such as U (user), W(workstation), X(no password expiration), and
695 >: Integer value currently unused</P
702 >: Integer value currently unused</P
709 >: Integer value currently unused</P
716 >: Integer value currently unused</P
723 >: Integer value currently unused</P
730 >: specifies the drive letter to which to map the
731 UNC path specified by homeDirectory. The drive letter must be specified in the form "X:"
732 where X is the letter of the drive to map. Refer to the "logon drive" parameter in the
733 smb.conf(5) man page for more information.</P
740 >: The scriptPath property specifies the path of
741 the user's logon script, .CMD, .EXE, or .BAT file. The string can be null. The path
742 is relative to the netlogon share. Refer to the "logon script" parameter in the
743 smb.conf(5) man page for more information.</P
750 >: specifies a path to the user's profile.
751 This value can be a null string, a local absolute path, or a UNC path. Refer to the
752 "logon path" parameter in the smb.conf(5) man page for more information.</P
759 >: The homeDirectory property specifies the path of
760 the home directory for the user. The string can be null. If homeDrive is set and specifies
761 a drive letter, homeDirectory should be a UNC path. The path must be a network
762 UNC path of the form \\server\share\directory. This value can be a null string.
763 Refer to the "logon home" parameter in the smb.conf(5) man page for more information.
771 >: character string value currently unused.
779 >: the integer representation of the user's relative identifier
787 >: the relative identifier (RID) of the primary group
792 >The majority of these parameters are only used when Samba is acting as a PDC of
793 a domain (refer to the <A
794 HREF="Samba-PDC-HOWTO.html"
798 how to configure Samba as a Primary Domain Controller). The following four attributes
799 are only stored with the sambaAccount entry if the values are non-default values:</P
821 >These attributes are only stored with the sambaAccount entry if
822 the values are non-default values. For example, assume TASHTEGO has now been
823 configured as a PDC and that <B
825 >logon home = \\%L\%u</B
830 > file. When a user named "becky" logons to the domain,
836 > string is expanded to \\TASHTEGO\becky.
837 If the smbHome attribute exists in the entry "uid=becky,ou=people,dc=samba,dc=org",
838 this value is used. However, if this attribute does not exist, then the value
844 > parameter is used in its place. Samba
845 will only write the attribute value to the directory entry is the value is
846 something other than the default (e.g. \\MOBY\becky).</P
853 NAME="AEN2558">14.9. Example LDIF Entries for a sambaAccount</H1
855 >The following is a working LDIF with the inclusion of the posixAccount objectclass:</P
858 CLASS="PROGRAMLISTING"
859 >dn: uid=guest2, ou=people,dc=plainjoe,dc=org
860 ntPassword: 878D8014606CDA29677A44EFA1353FC7
861 pwdMustChange: 2147483647
863 lmPassword: 552902031BEDE9EFAAD3B435B51404EE
864 pwdLastSet: 1010179124
866 objectClass: sambaAccount
868 kickoffTime: 2147483647
870 logoffTime: 2147483647
875 >The following is an LDIF entry for using both the sambaAccount and
876 posixAccount objectclasses:</P
879 CLASS="PROGRAMLISTING"
880 >dn: uid=gcarter, ou=people,dc=plainjoe,dc=org
882 displayName: Gerald Carter
883 lmPassword: 552902031BEDE9EFAAD3B435B51404EE
885 objectClass: posixAccount
886 objectClass: sambaAccount
888 userPassword: {crypt}BpM2ej8Rkzogo
892 loginShell: /bin/bash
893 logoffTime: 2147483647
895 kickoffTime: 2147483647
896 pwdLastSet: 1010179230
898 homeDirectory: /home/tashtego/gcarter
900 pwdMustChange: 2147483647
901 ntPassword: 878D8014606CDA29677A44EFA1353FC7</PRE
909 NAME="AEN2566">14.10. Comments</H1
911 >Please mail all comments regarding this HOWTO to <A
912 HREF="mailto:jerry@samba.org"
915 >. This documents was
916 last updated to reflect the Samba 2.2.3 release. </P
924 SUMMARY="Footer navigation table"
935 HREF="samba-bdc.html"
944 HREF="Samba-HOWTO.html"
953 HREF="improved-browsing.html"
963 >How to Act as a Backup Domain Controller in a Purely Samba Controlled Domain</TD
973 >Improved browsing in samba</TD