Administration
  Home arrow Administration arrow Handling User Accounts in Samba
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
ADMINISTRATION

Handling User Accounts in Samba
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2008-02-21


    Table of Contents:
  • Handling User Accounts in Samba
  • Username Maps
  • Account Utilities
  • Synchronizing Passwords

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Handling User Accounts in Samba
    ( Page 1 of 4 )

    In this third part to a four-part series on handling authentication and authorization in Samba, you will learn about username maps, account utilities, and more. It is excerpted from chapter five of Using Samba, Third Edition, written by Gerald Carter, Jay Ts and Robert Eckstein (O'Reilly, 2007; ISBN: 0596007698). Copyright © 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

     passdb backend = ldapsam

    The third officially supported passdb module is the ldapsam backend. A complete discussion of LDAP is beyond the scope of this book. If you are interested in LDAP and directory services, a recommended resource is LDAP System Administration, by Gerald Carter (O’Reilly). The remainder of this section assumes a basic level of comfort with LDAP directories and the OpenLDAP software in particular. If you are using a directory server from a different vendor, the examples should prove easy to adapt.

    When you consider the ldapsam backend, the first thing to do is to become familiar with the schema. There are two auxiliary classes and one structural object class that will be encountered in relation to users and groups:

    sambaDomain

    This structural object class is used to store information that is intended to be shared between Samba domain controllers in the same domain. We examine this more in Chapter 9.

    sambaSamAccount

    This auxiliary object class represents normal user and computer accounts and is commonly used to extend a user’s posixAccount entry in the directory. If a user (or computer) does not have a preexisting entry in the directory service, Samba attempts to use the account object as the structural class to instantiate a user. We haven’t discussed how machine and domain trust accounts are implemented yet, but we return to this subject in Chapter 9.

    sambaGroupMapping

    This auxiliary object class contains the attributes necessary for Samba’s group mapping functionality and is designed to use the posixGroup class as its structural basis.* Group mapping is covered later in this chapter.

    All the necessary attributes and object classes are defined in an OpenLDAP 2.x compatible schema file named samba.schema located in the examples/LDAP directory of the Samba source distribution. In this same location are schema files for other directory services as well, although these may not be up to date. Make sure that you include or import the appropriate schema file into your LDAP server’s configuration. Be aware that Samba’s OpenLDAP schema file requires you include the nis.schema, inetorgperson.schema, and cosine.schema files first.

    Remember that the LanMan ( sambaLMPassword ) and NT ( sambaNTPassword ) password hashes stored in the sambaSamAccount object are plain-text equivalents and should never be made readable to users. Access control rules should restrict these attributes to administrative users only, such as Samba’s ldap admin dn distinguished name (discussed a few paragraphs ahead). The following ACLs in OpenLDAP’s slapd.conf file protect the passwords from normal users but allow them to be read and modified by Samba:

      ## protect the samba password hashes
      access to attr=sambaNTPassword,sambaLMPasswor d
        by cn=smbadmin,ou=people,dc=example,dc=com write
        by * none

    For performance reasons, the directory service should support fast equality searches on the uid , cn , sambaSID , gidNumber , uidNumber , and displayName attributes. Newer Samba releases (beginning with 3.0.23) also use a substring matching rule on the sambaSID attribute. To effect this performance enhancement, add the following indexes (or their equivalents) to the server’s database section, if any are missing.

      ## Samba's index settings for OpenLDAP's slapd.conf
     
    index   uid,cn,displayName,memberUid   eq
      index   uidNumber,gidNumber            eq
      index   sambaSID                       eq,
    sub

    Finally, it may be necessary to restart your directory server and/or rerun indexing tools to get it to recognize the changes.

    Begin configuring smb.conf by setting up the connection parameters, starting with the LDAP server’s URI in the passdb backend value.

      [global]
          passdb backend = ldapsam:ldap://localhost/

    By default, all LDAP requests are sent to the directory in an unencrypted form. Unless the master LDAP server and Samba are running on the same machine, it is highly recommended that you take steps to secure the LDAP traffic from eavesdrop ping. Even when an LDAP replica is running locally on the Samba host, any referrals going back to the master LDAP server must still be encrypted.

    Use the ldaps:// URI in the passdb backend option if you wish to connect using LDAP over SSL. However, using StartTLS is the recommended method for configuring data privacy when communicating with an LDAP directory. In this case, the ldap:// URI suffices. To enable StartTLS support, add the following setting to the [global] section:

      ldap ssl = start_tls

    It is possible to include multiple LDAP URIs in a single-quoted string for purposes of fault tolerance or load balancing. If there are two servers, ldap1 and ldap2, which are replicas of the directory, we can configure Samba to use one in case the other is unavailable. The list of servers is passed on to the underlying LDAP client libraries, which handle the actual network connection details and any failover behavior. The ldap ssl parameter is included here to reiterate the need to secure all communication with the directory service; its value, however, specifies the use of StartTLS instead of SSL:

      passdb backend = ldapsam:"ldap://ldap1/ ldap://ldap2/ "
      ldap_ssl = start_tls

    Samba treats LDAP as another storage facility for users and groups. Thus all of the user’s attributes are retrieved from the directory when a SMB/CIFS connection request must be authenticated. When configuring the directory service access con trol settings, we restricted the password hashes to be readable only by Samba itself when using its ldap admin dn distinguished name to bind to the server:

      ldap admin dn = cn=smbadmin,ou=people,dc=example,dc=com

    The password associated with this privileged DN is stored in clear text separately in secrets.tdb. The smbpasswd command can store these credentials interactively ( -W option) or on a command line ( -w option). Here we have chosen to enter it interactively so that the password will not be displayed in the output of ps:

      root# smbpasswd -W
     
    Setting stored password for "cn=smbadmin,ou=people,dc=example,dc=com"
    in secrets.tdb
      New SMB password: <enter password>
      Retype new SMB password:
    <re-enter password>

    The final bit of information that Samba requires for ldapsam is the set of base suffixes used to query and store users and groups. The top-level suffix is specified by the ldap suffix option. This DN should be the parent of the other smb.conf search suffixes, which are specified by the following options:

    ldap user suffix
       The search base for locating and storing user
       accounts

    ldap machine suffix
       The search base for locating and storing computer
       and domain trust accounts

    ldap group suffix
       The search base for locating and storing group
       mapping entries

    ldap idmap suffix
       The search base for mapping winbindd’s SIDs to the
       Samba host’s uid/gid entries; additional information
       on winbindd is provided in Chapter 10

    The ldap suffix should be specified first in smb.conf and should be a full DN. The remaining search suffixes should be defined relative to the ldap suffix value. In order to support a directory name space such as the directory information tree (DIT) shown in Figure 5-2, we would add the following parameters to Samba’s configuration:

      [global]
         
    ldap suffix         = dc=example,dc=com
         
    ldap user suffix    = ou=people
         
    ldap machine suffix = ou=people
         
    ldap group suffix   = ou=group
         
    ldap idmap suffix   = ou=idmap

    It is possible to define different machine and user suffixes. If you do so, the server’s LDAP NSS module must search both bases when querying for a posixAccount . As one of the Samba developers has said, “Machines are people too.” The nss_ldap library from PADL software (http://www.padl.com) supports this by enabling the


    Figure 5-2.  Samba's DIT

    library’s RFC2307bis extensions (pass the --enable-rfc2307bis option to the nss_ldap configure script when compiling) and then defining multiple nss_base_passwd directives in its configuration file (usually /etc/ldap.conf). The complete details of PADL’s nss_ldap configuration is beyond the scope of this discussion. For more information, please refer to PADL’s web site and the documentation included with its software.

    To finish off the section, Table 5-10 lists the LDAP-related parameters supported in smb.conf. Samba and LDAP integration are revisited in Chapters 9 and 10.

    Table 5-10. LDAP-related parameters

    Parameter Value Description Default Scope
    ldap admin dn DN The user DN entry with administrative access to read and modify all Samba attributes and entries in the directory. "" Global
    ldap replication sleep integer (in milliseconds) The period to delay queries to an LDAP replica after updating the master directory server. 1000 Global
    ldap ssl off Transport layer encryption settings when not using LDAPS in the ldapsam server URI. off Global
      start_tls    
    ldap suffix DN The parent search suffix that establishes the base suffix for LDAP queries. "" Global
    ldap group suffix DN The suffix relative to the ldap suffix that stores group mapping information. "" Global
    ldap idmap suffix DN The suffix relative to the ldap suffix that stores winbindd’s identity mapping information. "" Global
    ldap machine DN The suffix relative to the ldap suffix that stores computer and domain trust account suffix information "" Global
    ldap user suffix DN The suffix relative to the ldap suffix that stores user account information. "" Global
    ldap timeout integer (in seconds) The maximum time in seconds to wait for a response to an LDAP query. 15 Global



     
     
    >>> More Administration Articles          >>> More By O'Reilly Media
     

       

    ADMINISTRATION ARTICLES

    - Network Booting via PXE: the Basics
    - Scalix: Linux Administrator`s Guide
    - Network Administration with FreeBSD 7
    - Components of an Information Architecture
    - The Anatomy of an Information Architecture
    - Configuring Load-Balanced Clusters
    - Load-Balanced Clusters
    - UNIX Time Format Demystified
    - Making Changes in the CVS
    - Building Your First CVS Repository
    - CVS Quickstart Guide
    - Authorizing Users in Samba
    - Handling User Accounts in Samba
    - Authentication in Samba
    - Accounts, Authentication, and Authorization





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek