Chapter 2. Using Samba as a server

Samba implements the Server Message Block (SMB) protocol in Red Hat Enterprise Linux. The SMB protocol is used to access resources on a server, such as file shares and shared printers. Additionally, Samba implements the Distributed Computing Environment Remote Procedure Call (DCE RPC) protocol used by Microsoft Windows.

You can run Samba as:

  • An Active Directory (AD) or NT4 domain member
  • A standalone server
  • An NT4 Primary Domain Controller (PDC) or Backup Domain Controller (BDC)

    Note

    Red Hat supports the PDC and BDC modes only in existing installations with Windows versions which support NT4 domains. Red Hat recommends not setting up a new Samba NT4 domain, because Microsoft operating systems later than Windows 7 and Windows Server 2008 R2 do not support NT4 domains.

    Red Hat does not support running Samba as an AD domain controller (DC).

Independently of the installation mode, you can optionally share directories and printers. This enables Samba to act as a file and print server.

Prerequisites

  • Red Hat Enterprise Linux 8 is installed on the server.

2.1. The Samba services

Samba provides the following services:

smbd

This service provides file sharing and printing services using the SMB protocol. Additionally, the service is responsible for resource locking and for authenticating connecting users. The smb systemd service starts and stops the smbd daemon.

To use the smbd service, install the samba package.

nmbd

This service provides host name and IP resolution using the NetBIOS over IPv4 protocol. Additionally to the name resolution, the nmbd service enables browsing the SMB network to locate domains, work groups, hosts, file shares, and printers. For this, the service either reports this information directly to the broadcasting client or forwards it to a local or master browser. The nmb systemd service starts and stops the nmbd daemon.

Note that modern SMB networks use DNS to resolve clients and IP addresses.

To use the nmbd service, install the samba package.

winbindd

This service provides an interface for the Name Service Switch (NSS) to use AD or NT4 domain users and groups on the local system. This enables, for example, domain users to authenticate to services hosted on a Samba server or to other local services. The winbind systemd service starts and stops the winbindd daemon.

If you set up Samba as a domain member, winbindd must be started before the smbd service. Otherwise, domain users and groups are not available to the local system..

To use the winbindd service, install the samba-winbind package.

Important

Red Hat only supports running Samba as a server with the winbindd service to provide domain users and groups to the local system. Due to certain limitations, such as missing Windows access control list (ACL) support and NT LAN Manager (NTLM) fallback, SSSD is not supported.

2.2. Verifying the smb.conf file by using the testparm utility

The testparm utility verifies that the Samba configuration in the /etc/samba/smb.conf file is correct. The utility detects invalid parameters and values, but also incorrect settings, such as for ID mapping. If testparm reports no problem, the Samba services will successfully load the /etc/samba/smb.conf file. Note that testparm cannot verify that the configured services will be available or work as expected.

Important

Red Hat recommends that you verify the /etc/samba/smb.conf file by using testparm after each modification of this file.

Procedure

  1. Run the testparm utility as the root user:

    # testparm
    Load smb config files from /etc/samba/smb.conf
    rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
    Unknown parameter encountered: "log levell"
    Processing section "[example_share]"
    Loaded services file OK.
    ERROR: The idmap range for the domain * (tdb) overlaps with the range of DOMAIN (ad)!
    
    Server role: ROLE_DOMAIN_MEMBER
    
    Press enter to see a dump of your service definitions
    
    # Global parameters
    [global]
    	...
    
    [example_share]
    	...

    The previous example output reports a non-existent parameter and an incorrect ID mapping configuration.

  2. If testparm reports incorrect parameters, values, or other errors in the configuration, fix the problem and run the utility again.

2.3. The Samba security services

The security parameter in the [global] section in the /etc/samba/smb.conf file manages how Samba authenticates users that are connecting to the service. Depending on the mode you install Samba in, the parameter must be set to different values:

On an AD domain member, set security = ads

In this mode, Samba uses Kerberos to authenticate AD users.

For details about setting up Samba as a domain member, see Section 2.5, “Setting up Samba as an AD domain member server”.

On a standalone server, set security = user

In this mode, Samba uses a local database to authenticate connecting users.

For details about setting up Samba as a standalone server, see Section 2.4, “Setting up Samba as a standalone server”.

On an NT4 PDC or BDC, set security = user
In this mode, Samba authenticates users to a local or LDAP database.
On an NT4 domain member, set security = domain

In this mode, Samba authenticates connecting users to an NT4 PDC or BDC. You cannot use this mode on AD domain members.

For details about setting up Samba as a domain member, see Section 2.5, “Setting up Samba as an AD domain member server”.

Additional resources

  • See the description of the security parameter in the smb.conf(5) man page.

2.4. Setting up Samba as a standalone server

You can set up Samba as a server that is not a member of a domain. In this installation mode, Samba authenticates users to a local database instead of to a central DC. Additionally, you can enable guest access to allow users to connect to one or multiple services without authentication.

2.4.1. Setting up the server configuration for the standalone server

This section describes how to set up the server configuration for a Samba standalone server.

Procedure

  1. Install the samba package:

    # yum install samba
  2. Edit the /etc/samba/smb.conf file and set the following parameters:

    [global]
    	workgroup = Example-WG
    	netbios name = Server
    	security = user
    
    	log file = /var/log/samba/%m.log
    	log level = 1

    This configuration defines a standalone server named Server within the Example-WG work group. Additionally, this configuration enables logging on a minimal level (1) and log files will be stored in the /var/log/samba/ directory. Samba will expand the %m macro in the log file parameter to the NetBIOS name of connecting clients. This enables individual log files for each client.

  3. Configure file or printer sharing. See:

  4. Verify the /etc/samba/smb.conf file:

    # testparm
  5. If you set up shares that require authentication, create the user accounts. See Section 2.4.2, “Creating and enabling local user accounts”.
  6. Open the required ports and reload the firewall configuration by using the firewall-cmd utility:

    # firewall-cmd --permanent --add-port={139/tcp,445/tcp}
    # firewall-cmd --reload
  7. Start the smb service:

    # systemctl start smb

    Optionally, enable the smb service to start automatically when the system boots:

    # systemctl enable smb

Additional resources

2.4.2. Creating and enabling local user accounts

To enable users to authenticate when they connect to a share, you must create the accounts on the Samba host both in the operating system and in the Samba database. Samba requires the operating system account to validate the Access Control Lists (ACL) on file system objects and the Samba account to authenticate connecting users.

If you use the passdb backend = tdbsam default setting, Samba stores user accounts in the /var/lib/samba/private/passdb.tdb database.

The procedure in this section describes how to create a local Samba user named example.

Prerequisites

  • Samba is installed configured as a standalone server.

Procedure

  1. Create the operating system account:

    # useradd -M -s /sbin/nologin example

    This command adds the example account without creating a home directory. If the account is only used to authenticate to Samba, assign the /sbin/nologin command as shell to prevent the account from logging in locally.

  2. Set a password to the operating system account to enable it:

    # passwd example
    Enter new UNIX password: password
    Retype new UNIX password: password
    passwd: password updated successfully

    Samba does not use the password set on the operating system account to authenticate. However, you need to set a password to enable the account. If an account is disabled, Samba denies access if this user connects.

  3. Add the user to the Samba database and set a password to the account:

    # smbpasswd -a example
    New SMB password: password
    Retype new SMB password: password
    Added user example.

    Use this password to authenticate when using this account to connect to a Samba share.

  4. Enable the Samba account:

    # smbpasswd -e example
    Enabled user example.

2.5. Setting up Samba as an AD domain member server

If you are running an AD or NT4 domain, use Samba to add your Red Hat Enterprise Linux server as a member to the domain to gain the following:

  • Access domain resources on other domain members
  • Authenticate domain users to local services, such as sshd
  • Share directories and printers hosted on the server to act as a file and print server

2.5.1. Joining Samba to a Domain

This section describes how to join a Red Hat Enterprise Linux system to a domain.

Procedure

  1. Install the following packages:

    # yum install realmd oddjob-mkhomedir oddjob samba-winbind-clients \
           samba-winbind samba-common-tools samba
  2. To share directories or printers on the domain member, install the samba package:

    # yum install samba
  3. If you are joining an AD, additionally install the Winbind Kerberos locator plug-in:

    # yum install samba-winbind-krb5-locator

    This plug-in enables Kerberos to locate the Key Distribution Center (KDC) based on AD sites using DNS service records.

  4. Optionally, for backup purposes, rename the existing /etc/samba/smb.conf Samba configuration file:

    # mv /etc/samba/smb.conf /etc/samba/smb.conf.old
  5. Join the domain. For example, to join a domain named ad.example.com:

    # realm join --client-software=winbind ad.example.com

    Using the previous command, the realm utility automatically:

    • Creates a /etc/samba/smb.conf file for a membership in the ad.example.com domain
    • Adds the winbind module for user and group lookups to the /etc/nsswitch.conf file
    • Updates the Pluggable Authentication Module (PAM) configuration files in the /etc/pam.d/ directory
    • Starts the winbind service and enables the service to start when the system boots
  6. Optionally, set an alternative ID mapping back end or customized ID mapping settings in the /etc/samba/smb.conf file. For details, see Section 2.5.4, “Samba ID mapping”.
  7. Optionally, verify the configuration. See Section 2.5.2, “Verifying that Samba was correctly joined as a domain member”.
  8. Verify that the winbind service is running:

    # systemctl status winbind
    ...
       Active: active (running) since Tue 2018-11-06 19:10:40 CET; 15s ago
    Important

    To enable Samba to query domain user and group information, the winbind service must be running before you start smb.

  9. If you installed the samba package to share directories and printers, start the smb service:

    # systemctl start smb
  10. Optionally, if you are authenticating local logins to Active Directory, enable the winbind_krb5_localauth plug-in. See Section 2.5.3, “Using the local authorization plug-in for MIT Kerberos”.

Additional resources

  • For further details about the realm utility, see

    • The realm(8) man page

2.5.2. Verifying that Samba was correctly joined as a domain member

To verify you added your Red Hat Enterprise Linux correctly to your domain perform the tests described in this section on the domain member.

2.5.2.1. Verifying that the operating system can retrieve domain user accounts and groups

Use the getent and chown utilities to verify that the operating system can retrieve domain users and groups

Procedure

  1. To query the administrator account in the AD domain:

    # getent passwd "AD\administrator"
    AD\administrator:*:10000:10000::/home/administrator@AD:/bin/bash
  2. To query the members of the Domain Users group in the AD domain:

    # getent group "AD\Domain Users"
    AD\domain users:x:10000:user1,user2
  3. Verify that you can use domain users and groups when you set permissions on files and directories. For example, to set the owner of the /srv/samba/example.txt file to AD\administrator and the group to AD\Domain Users:

    # chown "AD\administrator":"AD\Domain Users" /srv/samba/example.txt

2.5.2.2. Verifying if AD domain users can obtain a Kerberos ticket

In an AD environment, users can obtain a Kerberos ticket from the DC.

The procedure in this section describes how to verify if the administrator user can obtain a Kerberos ticket.

Prerequisites

  • Install the krb5-workstation package on the Samba domain member

Procedure

  1. On the AD domain member, obtain a ticket for the administrator@AD.EXAMPLE.COM principal:

    # kinit administrator@AD.EXAMPLE.COM
  2. Display the cached Kerberos ticket:

    # klist
    Ticket cache: KCM:0
    Default principal: administrator@AD.EXAMPLE.COM
    
    Valid starting       Expires              Service principal
    01.11.2018 10:00:00  01.11.2018 20:00:00  krbtgt/AD.EXAMPLE.COM@AD.EXAMPLE.COM
            renew until 08.11.2018 05:00:00

2.5.2.3. Listing the available domains

Use the wbinfo utility to list all domains available through the winbindd service.

Procedure

# wbinfo --all-domains

If Samba was successfully joined as a domain member, the command displays the built-in and local host name, as well as the domain Samba is a member of including trusted domains.

Example 2.1. Displaying the available domains

The following is an example of the wbinfo --all-domains command’s output:

# wbinfo --all-domains
BUILTIN
SAMBA-SERVER
AD

2.5.3. Using the local authorization plug-in for MIT Kerberos

The winbind service provides Active Directory users to the domain member. In certain situations, administrators want to enable domain users to authenticate to local services, such as an SSH server, which are running on the domain member. When using Kerberos to authenticate the domain users, enable the winbind_krb5_localauth plug-in to correctly map Kerberos principals to Active Directory accounts through the winbind service.

For example, if the sAMAccountName attribute of an Active Directory user is set to EXAMPLE and the user tries to log with the user name lowercase, Kerberos returns the user name in upper case. As a consequence, the entries do not match an authentication fails.

Using the winbind_krb5_localauth plug-in, the account names are mapped correctly. Note that this only applies to GSSAPI authentication and not for getting the initial ticket granting ticket (TGT).

Prerequisites

  • Samba is configured as a member of an Active Directory.
  • Red Hat Enterprise Linux authenticates log in attempts against Active Directory.
  • The winbind service is running.

Procedure

Edit the /etc/krb5.conf file and add the following section:

[plugins]
localauth = {
     module = winbind:/usr/lib64/samba/krb5/winbind_krb5_localauth.so
     enable_only = winbind
}

Additional resources

  • See the winbind_krb5_localauth(8) man page.

2.5.4. Samba ID mapping

Windows domains distinguish users and groups by unique Security Identifiers (SID). However, Linux requires unique UIDs and GIDs for each user and group. If you run Samba as a domain member, the winbindd service is responsible for providing information about domain users and groups to the operating system.

To enable the winbindd service to provide unique IDs for users and groups to Linux, you must configure ID mapping in the /etc/samba/smb.conf file for:

  • The local database (default domain)
  • The AD or NT4 domain the Samba server is a member of
  • Each trusted domain from which users must be able to access resources on this Samba server

2.5.4.1. Planning Samba ID ranges

Regardless of whether you store the Linux UIDs and GIDs in AD or if you configure Samba to generate them, each domain configuration requires a unique ID range that must not overlap with any of the other domains.

Warning

If you set overlapping ID ranges, Samba fails to work correctly.

Example 2.2. Unique ID Ranges

The following shows non-overlapping ID mapping ranges for the default (*), AD-DOM, and the TRUST-DOM domains.

[global]
...
idmap config * : backend = tdb
idmap config * : range = 10000-999999

idmap config AD-DOM:backend = rid
idmap config AD-DOM:range = 2000000-2999999

idmap config TRUST-DOM:backend = rid
idmap config TRUST-DOM:range = 4000000-4999999
Important

You can only assign one range per domain. Therefore, leave enough space between the domains ranges. This enables you to extend the range later if your domain grows.

If you later assign a different range to a domain, the ownership of files and directories previously created by these users and groups will be lost.

2.5.4.2. The * default domain

In a domain environment, you add one ID mapping configuration for each of the following:

  • The domain the Samba server is a member of
  • Each trusted domain that should be able to access the Samba server

However, for all other objects, Samba assigns IDs from the default domain. This includes:

  • Local Samba users and groups
  • Samba built-in accounts and groups, such as BUILTIN\Administrators
Important

You must configure the default domain as described in this section to enable Samba to operate correctly.

The default domain back end must be writable to permanently store the assigned IDs.

For the default domain, you can use one of the following back ends:

tdb

When you configure the default domain to use the tdb back end, set an ID range that is big enough to include objects that will be created in the future and that are not part of a defined domain ID mapping configuration.

For example, set the following in the [global] section in the /etc/samba/smb.conf file:

idmap config * : backend = tdb
idmap config * : range = 10000-999999

For further details, see Section 2.5.5.1, “Using the tdb ID mapping back end”.

autorid

When you configure the default domain to use the autorid back end, adding additional ID mapping configurations for domains is optional.

For example, set the following in the [global] section in the /etc/samba/smb.conf file:

idmap config * : backend = autorid
idmap config * : range = 10000-999999

For further details, see Section 2.5.5.4, “Using the autorid ID mapping back end”.

2.5.5. The different Samba ID mapping back ends

Samba provides different ID mapping back ends for specific configurations. The most frequently used back ends are:

Back endUse case

tdb

The * default domain only

ad

AD domains only

rid

AD and NT4 domains

autorid

AD, NT4, and the * default domain

The following sections describe the benefits, recommended scenarios where to use the back end, and how to configure it.

2.5.5.1. Using the tdb ID mapping back end

The winbindd service uses the writable tdb ID mapping back end by default to store Security Identifier (SID), UID, and GID mapping tables. This includes local users, groups, and built-in principals.

Use this back end only for the * default domain. For example:

idmap config * : backend = tdb
idmap config * : range = 10000-999999

2.5.5.2. Using the ad ID mapping back end

This section describes how to configure a Samba AD member to use the ad ID mapping back end.

The ad ID mapping back end implements a read-only API to read account and group information from AD. This provides the following benefits:

  • All user and group settings are stored centrally in AD.
  • User and group IDs are consistent on all Samba servers that use this back end.
  • The IDs are not stored in a local database which can corrupt, and therefore file ownerships cannot be lost.
Note

The ad ID mapping back end does not support Active Directory domains with one-way trusts. If you configure a domain member in an Active Directory with one-way trusts, use instead one of the following ID mapping back ends: tdb, rid, or autorid.

The ad back end reads the following attributes from AD:

AD attribute nameObject typeMapped to

sAMAccountName

User and group

User or group name, depending on the object

uidNumber

User

User ID (UID)

gidNumber

Group

Group ID (GID)

loginShell [a]

User

Path to the shell of the user

unixHomeDirectory [a]

User

Path to the home directory of the user

primaryGroupID [b]

User

Primary group ID

[a] Samba only reads this attribute if you set idmap config DOMAIN:unix_nss_info = yes.
[b] Samba only reads this attribute if you set idmap config DOMAIN:unix_primary_group = yes.

Prerequisites

To use the ad ID mapping back end:

  • Both users and groups must have unique IDs set in AD, and the IDs must be within the range configured in the /etc/samba/smb.conf file. Objects whose IDs are outside of the range will not be available on the Samba server.
  • Users and groups must have all required attributes set in AD. If required attributes are missing, the user or group will not be available on the Samba server. The required attributes depend on your configuration.

Procedure

  1. Edit the [global] section in the /etc/samba/smb.conf file:

    1. Add an ID mapping configuration for the default domain (*) if it does not exist. For example:

      idmap config * : backend = tdb
      idmap config * : range = 10000-999999
    2. Enable the ad ID mapping back end for the AD domain:

      idmap config DOMAIN : backend = ad
    3. Set the range of IDs that is assigned to users and groups in the AD domain. For example:

      idmap config DOMAIN : range = 2000000-2999999
      Important

      The range must not overlap with any other domain configuration on this server. Additionally, the range must be set big enough to include all IDs assigned in the future. For further details, see Section 2.5.4.1, “Planning Samba ID ranges”.

    4. Set that Samba uses the RFC 2307 schema when reading attributes from AD:

      idmap config DOMAIN : schema_mode = rfc2307
    5. To enable Samba to read the login shell and the path to the users home directory from the corresponding AD attribute, set:

      idmap config DOMAIN : unix_nss_info = yes

      Alternatively, you can set a uniform domain-wide home directory path and login shell that is applied to all users. For example:

      template shell = /bin/bash
      template homedir = /home/%U
    6. By default, Samba uses the primaryGroupID attribute of a user object as the user’s primary group on Linux. Alternatively, you can configure Samba to use the value set in the gidNumber attribute instead:

      idmap config DOMAIN : unix_primary_group = yes
  2. Verify the /etc/samba/smb.conf file:

    # testparm
  3. Reload the Samba configuration:

    # smbcontrol all reload-config
  4. Verify that the settings work as expected. See Section 2.5.2.1, “Verifying that the operating system can retrieve domain user accounts and groups”.

Additional resources

2.5.5.3. Using the rid ID mapping back end

This section describes how to configure a Samba domain member to use the rid ID mapping back end.

Samba can use the relative identifier (RID) of a Windows SID to generate an ID on Red Hat Enterprise Linux.

Note

The RID is the last part of a SID. For example, if the SID of a user is S-1-5-21-5421822485-1151247151-421485315-30014, then 30014 is the corresponding RID.

The rid ID mapping back end implements a read-only API to calculate account and group information based on an algorithmic mapping scheme for AD and NT4 domains. When you configure the back end, you must set the lowest and highest RID in the idmap config DOMAIN : range parameter. Samba will not map users or groups with a lower or higher RID than set in this parameter.

Important

As a read-only back end, rid cannot assign new IDs, such as for BUILTIN groups. Therefore, do not use this back end for the * default domain.

Benefits of using the rid back end
  • All domain users and groups that have an RID within the configured range are automatically available on the domain member.
  • You do not need to manually assign IDs, home directories, and login shells.
Drawbacks of using the rid back end
  • All domain users get the same login shell and home directory assigned. However, you can use variables.
  • User and group IDs are only the same across Samba domain members if all use the rid back end with the same ID range settings.
  • You cannot exclude individual users or groups from being available on the domain member. Only users and groups outside of the configured range are excluded.
  • Based on the formulas the winbindd service uses to calculate the IDs, duplicate IDs can occur in multi-domain environments if objects in different domains have the same RID.

Procedure

  1. Edit the [global] section in the /etc/samba/smb.conf file:

    1. Add an ID mapping configuration for the default domain (*) if it does not exist. For example:

      idmap config * : backend = tdb
      idmap config * : range = 10000-999999
    2. Enable the rid ID mapping back end for the domain:

      idmap config DOMAIN : backend = rid
    3. Set a range that is big enough to include all RIDs that will be assigned in the future. For example:

      idmap config DOMAIN : range = 2000000-2999999

      Samba ignores users and groups whose RIDs in this domain are not within the range.

      Important

      The range must not overlap with any other domain configuration on this server. For further details, see Section 2.5.4.1, “Planning Samba ID ranges”.

    4. Set a shell and home directory path that will be assigned to all mapped users. For example:

      template shell = /bin/bash
      template homedir = /home/%U
  2. Verify the /etc/samba/smb.conf file:

    # testparm
  3. Reload the Samba configuration:

    # smbcontrol all reload-config

    Verify that the settings work as expected. See Section 2.5.2.1, “Verifying that the operating system can retrieve domain user accounts and groups”.

Additional resources

2.5.5.4. Using the autorid ID mapping back end

This section describes how to configure a Samba domain member to use the autorid ID mapping back end.

The autorid back end works similar to the rid ID mapping back end, but can automatically assign IDs for different domains. This enables you to use the autorid back end in the following situations:

  • Only for the * default domain
  • For the * default domain and additional domains, without the need to create ID mapping configurations for each of the additional domains
  • Only for specific domains
Note

If you use autorid for the default domain, adding additional ID mapping configuration for domains is optional.

Parts of this section were adopted from the idmap config autorid documentation published in the Samba Wiki. License: CC BY 4.0. Authors and contributors: See the history tab on the Wiki page.

Benefits of using the autorid back end
  • All domain users and groups whose calculated UID and GID is within the configured range are automatically available on the domain member.
  • You do not need to manually assign IDs, home directories, and login shells.
  • No duplicate IDs, even if multiple objects in a multi-domain environment have the same RID.
Drawbacks
  • User and group IDs are not the same across Samba domain members.
  • All domain users get the same login shell and home directory assigned. However, you can use variables.
  • You cannot exclude individual users or groups from being available on the domain member. Only users and groups whose calculated UID or GID is outside of the configured range are excluded.

Procedure

  1. Edit the [global] section in the /etc/samba/smb.conf file:

    1. Enable the autorid ID mapping back end for the * default domain:

      idmap config * : backend = autorid
    2. Set a range that is big enough to assign IDs for all existing and future objects. For example:

      idmap config * : range = 10000-999999

      Samba ignores users and groups whose calculated IDs in this domain are not within the range.

      Warning

      After you set the range and Samba starts using it, you can only increase the upper limit of the range. Any other change to the range can result in new ID assignments, and thus in losing file ownerships.

    3. Optionally, set a range size. For example:

      idmap config * : rangesize = 200000

      Samba assigns this number of continuous IDs for each domain’s object until all IDs from the range set in the idmap config * : range parameter are taken.

    4. Set a shell and home directory path that will be assigned to all mapped users. For example:

      template shell = /bin/bash
      template homedir = /home/%U
    5. Optionally, add additional ID mapping configuration for domains. If no configuration for an individual domain is available, Samba calculates the ID using the autorid back end settings in the previously configured * default domain.

      Important

      If you configure additional back ends for individual domains, the ranges for all ID mapping configuration must not overlap. For further details, see Section 2.5.4.1, “Planning Samba ID ranges”.

  2. Verify the /etc/samba/smb.conf file:

    # testparm
  3. Reload the Samba configuration:

    # smbcontrol all reload-config
  4. Verify that the settings work as expected. See Section 2.5.2.1, “Verifying that the operating system can retrieve domain user accounts and groups”.

Additional resources

  • For details about how the back end calculated IDs, see the THE MAPPING FORMULAS section in the idmap_autorid(8) man page.
  • For details about using the idmap config rangesize parameter, see the rangesize parameter description in the idmap_autorid(8) man page.
  • For details about variable substitution, see the VARIABLE SUBSTITUTIONS section in the smb.conf(5) man page.
  • Section 2.2, “Verifying the smb.conf file by using the testparm utility”

2.6. Setting up Samba on an IdM domain member

This section describes how to set up Samba on a host that is joined to a Red Hat Identity Management (IdM) domain. Users from IdM and also, if available, from trusted Active Directory (AD) domains, can access shares and printer services provided by Samba.

Important

Using Samba on an IdM domain member is an unsupported Technology Preview feature.

Prerequisites

  • The host is joined as a client to the IdM domain.
  • Both the IdM servers and the client must run on RHEL 8.1 or later.

2.6.1. Preparing the IdM domain for installing Samba on domain members

Before you can establish a trust with AD and if you want to set up Samba on an IdM client, you must prepare the IdM domain using the ipa-adtrust-install utility on an IdM server. However, even if both situations apply, you must run ipa-adtrust-install only once on an IdM master.

Prerequisites

  • IdM is installed.

Procedure

  1. Install the required packages:

    [root@ipaserver ~]# yum install ipa-server ipa-server-trust-ad samba-client
  2. Authenticate as the IdM administrative user:

    [root@ipaserver ~]# kinit admin
  3. Run the ipa-adtrust-install utility:

    [root@ipaserver ~]# ipa-adtrust-install

    The DNS service records are created automatically if IdM was installed with an integrated DNS server.

    If IdM was installed without an integrated DNS server, ipa-adtrust-install prints a list of service records that must be manually added to DNS before you can continue.

  4. The script prompts you that the /etc/samba/smb.conf already exists and will be rewritten:

    WARNING: The smb.conf already exists. Running ipa-adtrust-install will break your existing Samba configuration.
    
    Do you wish to continue? [no]: yes
  5. The script prompts you to configure the slapi-nis plug-in, a compatibility plug-in that allows older Linux clients to work with trusted users:

    Do you want to enable support for trusted domains in Schema Compatibility plugin?
    This will allow clients older than SSSD 1.9 and non-Linux clients to work with trusted users.
    
    Enable trusted domains support in slapi-nis? [no]: yes
  6. When prompted, enter the NetBIOS name for the IdM domain or press Enter to accept the name suggested:

    Trust is configured but no NetBIOS domain name found, setting it now.
    Enter the NetBIOS name for the IPA domain.
    Only up to 15 uppercase ASCII letters, digits and dashes are allowed.
    Example: EXAMPLE.
    
    NetBIOS domain name [IDM]:
  7. You are prompted to run the SID generation task to create a SID for any existing users:

    Do you want to run the ipa-sidgen task? [no]: yes

    When the directory is first installed, at least one user (the IdM administrator) exists and as this is a resource-intensive task, if you have a high number of users, you can run this at another time.

  8. Restart the ipa service:

    [root@ipaserver ~]# systemctl restart ipa
  9. Use the smbclient utility to verify that Samba responds to Kerberos authentication from the IdM side:

    [root@ipaserver ~]# smbclient -L server.idm.example.com -k
    lp_load_ex: changing to config backend registry
        Sharename       Type      Comment
        ---------       ----      -------
        IPC$            IPC       IPC Service (Samba 4.10.4)
    ...

2.6.2. Enabling the AES encryption type in Active Directory using a GPO

This section describes how to enable the AES encryption type in Active Directory (AD) using a group policy object (GPO). Certain Identity Management (IdM) features, such as running a Samba server on an IdM client, require this encryption type.

Note that RHEL 8 does not support the weak DES and RC4 encryption types.

Prerequisites

  • You are logged into AD as a user who can edit group policies.
  • The Group Policy Management Console is installed on the computer.

Procedure

  1. Open the Group Policy Management Console.
  2. Right-click Default Domain Policy, and select Edit. The Group Policy Management Editor opens.
  3. Navigate to Computer ConfigurationPoliciesWindows SettingsSecurity SettingsLocal PoliciesSecurity Options.
  4. Double-click the Network security: Configure encryption types allowed for Kerberos policy.
  5. Select AES256_HMAC_SHA1 and, optionally, Future encryption types.
  6. Click OK.
  7. Close the Group Policy Management Editor.
  8. Repeat the steps for the Default Domain Controller Policy.
  9. Wait until the Windows domain controllers (DC) applied the group policy automatically. Alternatively, to apply the GPO manually on a DC, enter the following command using an account that has administrator permissions:

    C:\> gpupdate /force /target:computer

2.6.3. Installing and configuring a Samba server on an IdM client

This section describes how to install and configure Samba on a client enrolled in an IdM domain.

Prerequisites

Procedure

  1. Install the ipa-client-samba package:

    [root@idm_client]# yum install ipa-client-samba
  2. Use the ipa-client-samba utility to prepare the client and create an initial Samba configuration:

    [root@idm_client]# ipa-client-samba
    Searching for IPA server...
    IPA server: DNS discovery
    Chosen IPA master: idm_server.idm.example.com
    SMB principal to be created: cifs/idm_client.idm.example.com@IDM.EXAMPLE.COM
    NetBIOS name to be used: IDM_CLIENT
    Discovered domains to use:
    
     Domain name: idm.example.com
    NetBIOS name: IDM
             SID: S-1-5-21-525930803-952335037-206501584
        ID range: 212000000 - 212199999
    
     Domain name: ad.example.com
    NetBIOS name: AD
             SID: None
        ID range: 1918400000 - 1918599999
    
    Continue to configure the system with these values? [no]: yes
    Samba domain member is configured. Please check configuration at /etc/samba/smb.conf and start smb and winbind services
  3. By default, ipa-client-samba automatically adds the [homes] section to the /etc/samba.smb.conf file that dynamically shares a user’s home directory when the user connects. If users do not have home directories on this server, or if you do not want to share them, remove the following lines from /etc/samba.smb.conf:

    [homes]
        read only = no
  4. Share directories and printers. For details, see:

  5. Open the ports required for a Samba client in the local firewall:

    [root@idm_client]# firewall-cmd --permanent --add-service=samba-client
    [root@idm_client]# firewall-cmd --reload
  6. Enable and start the smb and winbind services:

    [root@idm_client]# systemctl enable --now smb winbind

Verification steps

Run the following verification steps on a different IdM domain member that has the samba-client package installed:

  1. Authenticate and obtain a Kerberos ticket-granting ticket:

    $ kinit example_user
  2. List the shares on the Samba server using Kerberos authentication:

    $ smbclient -L idm_client.idm.example.com -k
    lp_load_ex: changing to config backend registry
    
        Sharename       Type      Comment
        ---------       ----      -------
        example         Disk
        IPC$            IPC       IPC Service (Samba 4.10.4)
    ...

Additional resources

  • For details about which steps ipa-client-samba performs during the configuration, see the ipa-client-samba(1) man page.

2.6.4. Manually adding an ID mapping configuration if IdM trusts a new domain

Samba requires an ID mapping configuration for each domain from which users access resources. On an existing Samba server running on an IdM client, you must manually add an ID mapping configuration after the administrator added a new trust to an Active Directory (AD) domain.

Prerequisites

Procedure

  1. Authenticate using the host’s keytab:

    [root@idm_client]# kinit -k
  2. Use the ipa idrange-find command to display both the base ID and the ID range size of the new domain. For example, the following command displays the values for the ad.example.com domain:

    [root@idm_client]# ipa idrange-find --name="AD.EXAMPLE.COM_id_range" --raw
    ---------------
    1 range matched
    ---------------
      cn: AD.EXAMPLE.COM_id_range
      ipabaseid: 1918400000
      ipaidrangesize: 200000
      ipabaserid: 0
      ipanttrusteddomainsid: S-1-5-21-968346183-862388825-1738313271
      iparangetype: ipa-ad-trust
    ----------------------------
    Number of entries returned 1
    ----------------------------

    You need the values from the ipabaseid and ipaidrangesize attributes in the next steps.

  3. To calculate the highest usable ID, use the following formula:

    maximum_range = ipabaseid + ipaidrangesize - 1

    With the values from the previous step, the highest usable ID for the ad.example.com domain is 1918599999 (1918400000 + 200000 - 1).

  4. Edit the /etc/samba/smb.conf file, and add the ID mapping configuration for the domain to the [global] section:

    idmap config AD : range = 1918400000 - 1918599999
    idmap config AD : backend = sss

    Specify the value from ipabaseid attribute as the lowest and the computed value from the previous step as the highest value of the range.

  5. Restart the smb and winbind services:

    [root@idm_client]# systemctl restart smb winbind

Verification steps

  1. Authenticate as a user from the new domain and obtain a Kerberos ticket-granting ticket:

    $ kinit example_user
  2. List the shares on the Samba server using Kerberos authentication:

    $ smbclient -L idm_client.idm.example.com -k
    lp_load_ex: changing to config backend registry
    
        Sharename       Type      Comment
        ---------       ----      -------
        example         Disk
        IPC$            IPC       IPC Service (Samba 4.10.4)
    ...

2.6.5. Additional resources

2.7. Configuring file shares on a Samba server

To use Samba as a file server, add shares to the /etc/samba/smb.conf file of your standalone server or domain member configuration.

You can add shares that uses either:

Prerequisites

Samba has been set up in one of the following modes:

2.7.1. Setting up a share that uses POSIX ACLs

As a Linux service, Samba supports shares with POSIX ACLs. They enable you to manage permissions locally on the Samba server using utilities, such as chmod. If the share is stored on a file system that supports extended attributes, you can define ACLs with multiple users and groups.

Note

If you need to use fine-granular Windows ACLs instead, see Section 2.7.2, “Setting up a share that uses Windows ACLs”.

Parts of this section were adopted from the Setting up a Share Using POSIX ACLs documentation published in the Samba Wiki. License: CC BY 4.0. Authors and contributors: See the history tab on the Wiki page.

2.7.1.1. Adding a share that uses POSIX ACLs

This section describes how to create a share named example that provides the content of the /srv/samba/example/ directory, and uses POSIX ACLs.

Procedure

  1. Create the folder if it does not exist. For example:

    # mkdir -p /srv/samba/example/
  2. If you run SELinux in enforcing mode, set the samba_share_t context on the directory:

    # semanage fcontext -a -t samba_share_t "/srv/samba/example(/.*)?"
    # restorecon -Rv /srv/samba/example/
  3. Set file system ACLs on the directory. See Section 2.7.1, “Setting up a share that uses POSIX ACLs”.
  4. Add the example share to the /etc/samba/smb.conf file. For example, to add the share write-enabled:

    [example]
    	path = /srv/samba/example/
    	read only = no
    Note

    Regardless of the file system ACLs; if you do not set read only = no, Samba shares the directory in read-only mode.

  5. Verify the /etc/samba/smb.conf file:

    # testparm
  6. Open the required ports and reload the firewall configuration using the firewall-cmd utility:

    # firewall-cmd --permanent --add-service=samba
    # firewall-cmd --reload
  7. Restart the smb service:

    # systemctl restart smb
  8. Optionally, enable the smb service to start automatically at boot time:

    # systemctl enable smb

2.7.1.2. Setting ACLs on a share that uses POSIX ACLs

This section describes how to set ACLs on a share that uses POSIX ACLs.

Shares that use POSIX ACLs support:

Prerequisites

2.7.1.2.1. Setting standard Linux ACLs

The standard ACLs on Linux support setting permissions for one owner, one group, and for all other undefined users. You can use the chown, chgrp, and chmod utility to update the ACLs. If you require precise control, then you use the more complex POSIX ACLs, see Section 2.7.1.2.2, “Setting extended ACLs”.

The following procedure sets the owner of the /srv/samba/example/ directory to the root user, grant read and write permissions to the Domain Users group, and deny access to all other users.

Procedure

# chown root:"Domain Users" /srv/samba/example/
# chmod 2770 /srv/samba/example/

Note

Enabling the set-group-ID (SGID) bit on a directory automatically sets the default group for all new files and subdirectories to that of the directory group, instead of the usual behavior of setting it to the primary group of the user who created the new directory entry.

Additional resources

  • For further details about permissions, see the chown(1) and chmod(1) man pages.
2.7.1.2.2. Setting extended ACLs

If the file system the shared directory is stored on supports extended ACLs, you can use them to set complex permissions. Extended ACLs can contain permissions for multiple users and groups.

Extended POSIX ACLs enable you to configure complex ACLs with multiple users and groups. However, you can only set the following permissions:

  • No access
  • Read access
  • Write access
  • Full control

If you require the fine-granular Windows permissions, such as Create folder / append data, configure the share to use Windows ACLs. See Section 2.7.2, “Setting up a share that uses Windows ACLs”.

The following procedure shows how to enable extended ACLs on a share. Additionally, it contains an example about setting extended ACLs.

Procedure

  1. Enable the following parameter in the share’s section in the /etc/samba/smb.conf file to enable ACL inheritance of extended ACLs:

    inherit acls = yes

    For details, see the parameter description in the smb.conf(5) man page.

  2. Restart the smb service:

    # systemctl restart smb
  3. Set the ACLs on the directory. For example:

    Example 2.3. Setting Extended ACLs

    The following procedure sets read, write, and execute permissions for the Domain Admins group, read, and execute permissions for the Domain Users group, and deny access to everyone else on the /srv/samba/example/ directory:

    1. Disable auto-granting permissions to the primary group of user accounts:

      # setfacl -m group::--- /srv/samba/example/
      # setfacl -m default:group::--- /srv/samba/example/

      The primary group of the directory is additionally mapped to the dynamic CREATOR GROUP principal. When you use extended POSIX ACLs on a Samba share, this principal is automatically added and you cannot remove it.

    2. Set the permissions on the directory:

      1. Grant read, write, and execute permissions to the Domain Admins group:

        # setfacl -m group:"DOMAIN\Domain Admins":rwx /srv/samba/example/
      2. Grant read and execute permissions to the Domain Users group:

        # setfacl -m group:"DOMAIN\Domain Users":r-x /srv/samba/example/
      3. Set permissions for the other ACL entry to deny access to users that do not match the other ACL entries:

        # setfacl -R -m other::--- /srv/samba/example/

      These settings apply only to this directory. In Windows, these ACLs are mapped to the This folder only mode.

    3. To enable the permissions set in the previous step to be inherited by new file system objects created in this directory:

      # setfacl -m default:group:"DOMAIN\Domain Admins":rwx /srv/samba/example/
      # setfacl -m default:group:"DOMAIN\Domain Users":r-x /srv/samba/example/
      # setfacl -m default:other::--- /srv/samba/example/

      With these settings, the This folder only mode for the principals is now set to This folder, subfolders, and files.

    Samba maps the permissions set in the procedure to the following Windows ACLs:

    PrincipalAccessApplies to

    Domain\Domain Admins

    Full control

    This folder, subfolders, and files

    Domain\Domain Users

    Read & execute

    This folder, subfolders, and files

    Everyone [a]

    None

    This folder, subfolders, and files

    owner (Unix User\owner) [b]

    Full control

    This folder only

    primary_group (Unix User\primary_group) [c]

    None

    This folder only

    CREATOR OWNER [d] [e]

    Full control

    Subfolders and files only

    CREATOR GROUP [e] [f]

    None

    Subfolders and files only

    [a] Samba maps the permissions for this principal from the other ACL entry.
    [b] Samba maps the owner of the directory to this entry.
    [c] Samba maps the primary group of the directory to this entry.
    [d] On new file system objects, the creator inherits automatically the permissions of this principal.
    [e] Configuring or removing these principals from the ACLs not supported on shares that use POSIX ACLs.
    [f] On new file system objects, the creator’s primary group inherits automatically the permissions of this principal.

2.7.1.3. Setting permissions on a share that uses POSIX ACLs

Optionally, to limit or grant access to a Samba share, you can set certain parameters in the share’s section in the /etc/samba/smb.conf file.

Note

Share-based permissions manage if a user, group, or host is able to access a share. These settings do not affect file system ACLs.

Use share-based settings to restrict access to shares, for example, to deny access from specific hosts.

Prerequisites

2.7.1.3.1. Configuring user and group-based share access

User and group-based access control enables you to grant or deny access to a share for certain users and groups.

Procedure

  1. For example, to enable all members of the Domain Users group to access a share while access is denied for the user account, add the following parameters to the share’s configuration:

    valid users = +DOMAIN\"Domain Users"
    invalid users = DOMAIN\user

    The invalid users parameter has a higher priority than the valid users parameter. For example, if the user account is a member of the Domain Users group, access is denied to this account when you use the previous example.

  2. Reload the Samba configuration:

    # smbcontrol all reload-config

Additional resources

  • For further details, see the parameter descriptions in the smb.conf(5) man page.
2.7.1.3.2. Configuring host-based share access

Host-based access control enables you to grant or deny access to a share based on client’s host names, IP addresses, or IP range.

The following procedure explains how to enable the 127.0.0.1 IP address, the 192.0.2.0/24 IP range, and the client1.example.com host to access a share, and additionally deny access for the client2.example.com host:

Procedure

  1. Add the following parameters to the configuration of the share in the /etc/samba/smb.conf file:

    hosts allow = 127.0.0.1 192.0.2.0/24 client1.example.com
    hosts deny = client2.example.com

    The hosts deny parameter has a higher priority than hosts allow. For example, if client1.example.com resolves to an IP address that is listed in the hosts allow parameter, access for this host is denied.

  2. Reload the Samba configuration:

    # smbcontrol all reload-config

Additional resources

  • For further details, see the parameter descriptions in the smb.conf(5) man page.

2.7.2. Setting up a share that uses Windows ACLs

Samba supports setting Windows ACLs on shares and file system object. This enables you to:

  • Use the fine-granular Windows ACLs
  • Manage share permissions and file system ACLs using Windows

Alternatively, you can configure a share to use POSIX ACLs. For details, see Section 2.7.1, “Setting up a share that uses POSIX ACLs”.

Parts of this section were adopted from the Setting up a Share Using Windows ACLs documentation published in the Samba Wiki. License: CC BY 4.0. Authors and contributors: See the history tab on the Wiki page.

2.7.2.1. Granting the SeDiskOperatorPrivilege privilege

Only users and groups having the SeDiskOperatorPrivilege privilege granted can configure permissions on shares that use Windows ACLs.

Procedure

  1. For example, to grant the SeDiskOperatorPrivilege privilege to the DOMAIN\Domain Admins group:

    # net rpc rights grant "DOMAIN\Domain Admins" SeDiskOperatorPrivilege \
           -U "DOMAIN\administrator"
    Enter DOMAIN\administrator's password:
    Successfully granted rights.
    Note

    In a domain environment, grant SeDiskOperatorPrivilege to a domain group. This enables you to centrally manage the privilege by updating a user’s group membership.

  2. To list all users and groups having SeDiskOperatorPrivilege granted:

    # net rpc rights list privileges SeDiskOperatorPrivilege \
           -U "DOMAIN\administrator"
    Enter administrator's password:
    SeDiskOperatorPrivilege:
      BUILTIN\Administrators
      DOMAIN\Domain Admins

2.7.2.2. Enabling Windows ACL support

To configure shares that support Windows ACLs, you must enable this feature in Samba.

Prerequisites

  • A user share is configured on the Samba server.

Procedure

  1. To enable it globally for all shares, add the following settings to the [global] section of the /etc/samba/smb.conf file:

    vfs objects = acl_xattr
    map acl inherit = yes
    store dos attributes = yes

    Alternatively, you can enable Windows ACL support for individual shares, by adding the same parameters to a share’s section instead.

  2. Restart the smb service:

    # systemctl restart smb

2.7.2.3. Adding a share that uses Windows ACLs

This section describes how to create a share named example, that shares the content of the /srv/samba/example/ directory, and uses Windows ACLs.

Procedure

  1. Create the folder if it does not exists. For example:

    # mkdir -p /srv/samba/example/
  2. If you run SELinux in enforcing mode, set the samba_share_t context on the directory:

    # semanage fcontext -a -t samba_share_t "/srv/samba/example(/.*)?"
    # restorecon -Rv /srv/samba/example/
  3. Add the example share to the /etc/samba/smb.conf file. For example, to add the share write-enabled:

    [example]
    	path = /srv/samba/example/
    	read only = no
    Note

    Regardless of the file system ACLs; if you do not set read only = no, Samba shares the directory in read-only mode.

  4. If you have not enabled Windows ACL support in the [global] section for all shares, add the following parameters to the [example] section to enable this feature for this share:

    vfs objects = acl_xattr
    map acl inherit = yes
    store dos attributes = yes
  5. Verify the /etc/samba/smb.conf file:

    # testparm
  6. Open the required ports and reload the firewall configuration using the firewall-cmd utility:

    # firewall-cmd --permanent --add-service=samba
    # firewall-cmd --reload
  7. Restart the smb service:

    # systemctl restart smb

2.7.2.4. Managing share permissions and file system ACLs of a share that uses Windows ACLs

To manage share permissions and file system ACLs on a Samba share that uses Windows ACLs, use a Windows applications, such as Computer Management. For details, see the Windows documentation. Alternatively, use the smbcacls utility to manage ACLs.

Note

To modify the file system permissions from Windows, you must use an account that has the SeDiskOperatorPrivilege privilege granted.

2.7.3. Managing ACLs on an SMB share using smbcacls

The smbcacls utility can list, set, and delete ACLs of files and directories stored on an SMB share. You can use smbcacls to manage file system ACLs:

  • On a local or remote Samba server that uses advanced Windows ACLs or POSIX ACLs
  • On Red Hat Enterprise Linux to remotely manage ACLs on a share hosted on Windows

2.7.3.1. Access control entries

Each ACL entry of a file system object contains Access Control Entries (ACE) in the following format:

security_principal:access_right/inheritance_information/permissions

Example 2.4. Access control entries

If the AD\Domain Users group has Modify permissions that apply to This folder, subfolders, and files on Windows, the ACL contains the following ACE:

AD\Domain Users:ALLOWED/OI|CI/CHANGE

An ACE contains the following parts:

Security principal
The security principal is the user, group, or SID the permissions in the ACL are applied to.
Access right
Defines if access to an object is granted or denied. The value can be ALLOWED or DENIED.
Inheritance information

The following values exist:

Table 2.1. Inheritance settings

ValueDescriptionMaps to

OI

Object Inherit

This folder and files

CI

Container Inherit

This folder and subfolders

IO

Inherit Only

The ACE does not apply to the current file or directory

ID

Inherited

The ACE was inherited from the parent directory

Additionally, the values can be combined as follows:

Table 2.2. Inheritance settings combinations

Value combinationsMaps to the Windows Applies to setting

OI|CI

This folder, subfolders, and files

OI|CI|IO

Subfolders and files only

CI|IO

Subfolders only

OI|IO

Files only

Permissions

This value can be either a hex value that represents one or more Windows permissions or an smbcacls alias:

  • A hex value that represents one or more Windows permissions.

    The following table displays the advanced Windows permissions and their corresponding value in hex format:

    Table 2.3. Windows permissions and their corresponding smbcacls value in hex format

    Windows permissionsHex values

    Full control

    0x001F01FF

    Traverse folder / execute file

    0x00100020

    List folder / read data

    0x00100001

    Read attributes

    0x00100080

    Read extended attributes

    0x00100008

    Create files / write data

    0x00100002

    Create folders / append data

    0x00100004

    Write attributes

    0x00100100

    Write extended attributes

    0x00100010

    Delete subfolders and files

    0x00100040

    Delete

    0x00110000

    Read permissions

    0x00120000

    Change permissions

    0x00140000

    Take ownership

    0x00180000

    Multiple permissions can be combined as a single hex value using the bit-wise OR operation. For details, see Section 2.7.3.3, “ACE mask calculation”.

  • An smbcacls alias. The following table displays the available aliases:

    Table 2.4. Existing smbcacls aliases and their corresponding Windows permission

    smbcacls aliasMaps to Windows permission

    R

    Read

    READ

    Read & execute

    W

    Special:

    • Create files / write data
    • Create folders / append data
    • Write attributes
    • Write extended attributes
    • Read permissions

    D

    Delete

    P

    Change permissions

    O

    Take ownership

    X

    Traverse / execute

    CHANGE

    Modify

    FULL

    Full control

    Note

    You can combine single-letter aliases when you set permissions. For example, you can set RD to apply the Windows permission Read and Delete. However, you can neither combine multiple non-single-letter aliases nor combine aliases and hex values.

2.7.3.2. Displaying ACLs using smbcacls

To display ACLs on an SMB share, use the smbcacls utility. If you run smbcacls without any operation parameter, such as --add, the utility displays the ACLs of a file system object.

Procedure

For example, to list the ACLs of the root directory of the //server/example share:

# smbcacls //server/example / -U "DOMAIN\administrator"
Enter DOMAIN\administrator's password:
REVISION:1
CONTROL:SR|PD|DI|DP
OWNER:AD\Administrators
GROUP:AD\Domain Users
ACL:AD\Administrator:ALLOWED/OI|CI/FULL
ACL:AD\Domain Users:ALLOWED/OI|CI/CHANGE
ACL:AD\Domain Guests:ALLOWED/OI|CI/0x00100021

The output of the command displays:

  • REVISION: The internal Windows NT ACL revision of the security descriptor
  • CONTROL: Security descriptor control
  • OWNER: Name or SID of the security descriptor’s owner
  • GROUP: Name or SID of the security descriptor’s group
  • ACL entries. For details, see Section 2.7.3.1, “Access control entries”.

2.7.3.3. ACE mask calculation

In most situations, when you add or update an ACE, you use the smbcacls aliases listed in Table 2.4, “Existing smbcacls aliases and their corresponding Windows permission”.

However, if you want to set advanced Windows permissions as listed in Table 2.3, “Windows permissions and their corresponding smbcacls value in hex format”, you must use the bit-wise OR operation to calculate the correct value. You can use the following shell command to calculate the value:

# echo $(printf '0x%X' $(( hex_value_1 | hex_value_2 | ... )))

Example 2.5. Calculating an ACE Mask

You want to set the following permissions:

  • Traverse folder / execute file (0x00100020)
  • List folder / read data (0x00100001)
  • Read attributes (0x00100080)

To calculate the hex value for the previous permissions, enter:

# echo $(printf '0x%X' $(( 0x00100020 | 0x00100001 | 0x00100080 )))
0x1000A1

Use the returned value when you set or update an ACE.

2.7.3.4. Adding, updating, and removing an ACL using smbcacls

Depending on the parameter you pass to the smbcacls utility, you can add, update, and remove ACLs from a file or directory.

Adding an ACL

To add an ACL to the root of the //server/example share that grants CHANGE permissions for This folder, subfolders, and files to the AD\Domain Users group:

# smbcacls //server/example / -U "DOMAIN\administrator \
       --add ACL:"AD\Domain Users":ALLOWED/OI|CI/CHANGE
Updating an ACL

Updating an ACL is similar to adding a new ACL. You update an ACL by overriding the ACL using the --modify parameter with an existing security principal. If smbcacls finds the security principal in the ACL list, the utility updates the permissions. Otherwise the command fails with an error:

ACL for SID principal_name not found

For example, to update the permissions of the AD\Domain Users group and set them to READ for This folder, subfolders, and files:

# smbcacls //server/example / -U "DOMAIN\administrator \
       --modify ACL:"AD\Domain Users":ALLOWED/OI|CI/READ
Deleting an ACL

To delete an ACL, pass the --delete parameter with the exact ACL to the smbcacls utility. For example:

# smbcacls //server/example / -U "DOMAIN\administrator \
       --delete ACL:"AD\Domain Users":ALLOWED/OI|CI/READ

2.7.4. Enabling users to share directories on a Samba server

On a Samba server, you can configure that users can share directories without root permissions.

2.7.4.1. Enabling the user shares feature

Before users can share directories, the administrator must enable user shares in Samba.

For example, to enable only members of the local example group to create user shares.

Procedure

  1. Create the local example group, if it does not exist:

    # groupadd example
  2. Prepare the directory for Samba to store the user share definitions and set its permissions properly. For example:

    1. Create the directory:

      # mkdir -p /var/lib/samba/usershares/
    2. Set write permissions for the example group:

      # chgrp example /var/lib/samba/usershares/
      # chmod 1770 /var/lib/samba/usershares/
    3. Set the sticky bit to prevent users to rename or delete files stored by other users in this directory.
  3. Edit the /etc/samba/smb.conf file and add the following to the [global] section:

    1. Set the path to the directory you configured to store the user share definitions. For example:

      usershare path = /var/lib/samba/usershares/
    2. Set how many user shares Samba allows to be created on this server. For example:

      usershare max shares = 100

      If you use the default of 0 for the usershare max shares parameter, user shares are disabled.

    3. Optionally, set a list of absolute directory paths. For example, to configure that Samba only allows to share subdirectories of the /data and /srv directory to be shared, set:

      usershare prefix allow list = /data /srv

    For a list of further user share-related parameters you can set, see the USERSHARES section in the smb.conf(5) man page.

  4. Verify the /etc/samba/smb.conf file:

    # testparm
  5. Reload the Samba configuration:

    # smbcontrol all reload-config

Users are now able to create user shares. For details, see Section 2.7.4.2, “Adding a user share”.

2.7.4.2. Adding a user share

After you configured Samba according to Section 2.7.4.1, “Enabling the user shares feature”, users can share directories on the Samba server without root permissions by running the net usershare add command.

Synopsis of the net usershare add command:

net usershare add share_name path [[ comment ] | [ ACLs ]] [ guest_ok=y|n ]

Important

If you set ACLs when you create a user share, you must specify the comment parameter prior to the ACLs. To set an empty comment, use an empty string in double quotes.

Note that users can only enable guest access on a user share, if the administrator set usershare allow guests = yes in the [global] section in the /etc/samba/smb.conf file.

Example 2.6. Adding a user share

A user wants to share the /srv/samba/ directory on a Samba server. The share should be named example, have no comment set, and should be accessible by guest users. Additionally, the share permissions should be set to full access for the AD\Domain Users group and read permissions for other users. To add this share, run as the user:

$ net usershare add example /srv/samba/ "" \
       "AD\Domain Users":F,Everyone:R guest_ok=yes

2.7.4.3. Updating settings of a user share

To update settings of a user share, override the share by using the net usershare add command with the same share name and the new settings. See Section 2.7.4.2, “Adding a user share”.

2.7.4.4. Displaying information about existing user shares

Users can enter the net usershare info command on a Samba server to display user shares and their settings.

Prerequisites

  • A user share is configured on the Samba server.

Procedure

  1. To display all user shares created by any user:

    $ net usershare info -l
    [share_1]
    path=/srv/samba/
    comment=
    usershare_acl=Everyone:R,host_name\user:F,
    guest_ok=y
    ...

    To list only shares created by the user who runs the command, omit the -l parameter.

  2. To display only the information about specific shares, pass the share name or wild cards to the command. For example, to display the information about shares whose name starts with share_:

    $ net usershare info -l share_*

2.7.4.5. Listing user shares

If you want to list only the available user shares without their settings on a Samba server, use the net usershare list command.

Prerequisites

  • A user share is configured on the Samba server.

Procedure

  1. To list the shares created by any user:

    $ net usershare list -l
    share_1
    share_2
    ...

    To list only shares created by the user who runs the command, omit the -l parameter.

  2. To list only specific shares, pass the share name or wild cards to the command. For example, to list only shares whose name starts with share_:

    $ net usershare list -l share_*

2.7.4.6. Deleting a user share

To delete a user share, use the command net usershare delete command as the user who created the share or as the root user.

Prerequisites

  • A user share is configured on the Samba server.

Procedure

$ net usershare delete share_name

2.7.5. Enabling guest access to a share

In certain situations, you want to share a directory to which users can connect without authentication. To configure this, enable guest access on a share.

Warning

Shares that do not require authentication can be a security risk.

If guest access is enabled on a share, Samba maps guest connections to the operating system account set in the guest account parameter. Guest users can access files on this share if at least one of the following conditions is satisfied:

  • The account is listed in file system ACLs
  • The POSIX permissions for other users allow it

Example 2.7. Guest share permissions

If you configured Samba to map the guest account to nobody, which is the default, the ACLs in the following example:

  • Allow guest users to read file1.txt
  • Allow guest users to read and modify file2.txt
  • Prevent guest users to read or modify file3.txt
-rw-r--r--. 1 root       root      1024 1. Sep 10:00 file1.txt
-rw-r-----. 1 nobody     root      1024 1. Sep 10:00 file2.txt
-rw-r-----. 1 root       root      1024 1. Sep 10:00 file3.txt

Procedure

  1. Edit the /etc/samba/smb.conf file:

    1. If this is the first guest share you set up on this server:

      1. Set map to guest = Bad User in the [global] section:

        [global]
                ...
                map to guest = Bad User

        With this setting, Samba rejects login attempts that use an incorrect password unless the user name does not exist. If the specified user name does not exist and guest access is enabled on a share, Samba treats the connection as a guest log in.

      2. By default, Samba maps the guest account to the nobody account on Red Hat Enterprise Linux. Alternatively, you can set a different account. For example:

        [global]
                ...
                guest account = user_name

        The account set in this parameter must exist locally on the Samba server. For security reasons, Red Hat recommends using an account that does not have a valid shell assigned.

    2. Add the guest ok = yes setting to the [example] share section:

      [example]
              ...
              guest ok = yes
  2. Verify the /etc/samba/smb.conf file:

    # testparm
  3. Reload the Samba configuration:

    # smbcontrol all reload-config

2.7.6. Optimizing the Samba configuration for providing file shares for macOS clients

The fruit virtual file system (VFS) Samba module provides enhanced compatibility with Apple server message block (SMB) clients. This section describes how to configure the fruit module for all Samba shares hosted on the server.

Note

Red Hat recommends enabling the fruit module globally. Clients using macOS negotiate the server SMB2 Apple (AAPL) protocol extensions when the client establishes the first connection to the server. If the client first connects to a share without AAPL extensions enabled, the client does not use the extensions for any share of the server.

Prerequisites

  • Samba is configured as a file server.

Procedure

  1. Edit the /etc/samba/smb.conf file, and enable the fruit and streams_xattr VFS modules in the [global] section:

    vfs objects = fruit streams_xattr
    Important

    You must enable the fruit module before enabling streams_xattr. The fruit module uses alternate data streams (ADS). For this reason, you must also enable the streams_xattr module.

  2. Optionally, to provide macOS Time Machine support on a share, add the following setting to the share configuration in the /etc/samba/smb.conf file:

    fruit:time machine = yes
  3. Verify the /etc/samba/smb.conf file:

    # testparm
  4. Reload the Samba configuration:

    # smbcontrol all reload-config

Additional resources

2.8. Setting up Samba as a print server

If you set up Samba as a print server, clients in your network can use Samba to print. Additionally, Windows clients can, if configured, download the driver from the Samba server.

Parts of this section were adopted from the Setting up Samba as a Print Server documentation published in the Samba Wiki. License: CC BY 4.0. Authors and contributors: See the history tab on the Wiki page.

Prerequisites

Samba has been set up in one of the following modes:

2.8.1. The Samba spoolssd service

The Samba spoolssd is a service that is integrated into the smbd service. Enable spoolssd in the Samba configuration to significantly increase the performance on print servers with a high number of jobs or printers.

Without spoolssd, Samba forks the smbd process and initializes the printcap cache for each print job. In case of a large number of printers, the smbd service can become unresponsive for multiple seconds while the cache is initialized. The spoolssd service enables you to start pre-forked smbd processes that are processing print jobs without any delays. The main spoolssd smbd process uses a low amount of memory, and forks and terminates child processes.

The following procedure explains how to enable the spoolssd service.

Procedure

  1. Edit the [global] section in the /etc/samba/smb.conf file:

    1. Add the following parameters:

      rpc_server:spoolss = external
      rpc_daemon:spoolssd = fork
    2. Optionally, you can set the following parameters:

      ParameterDefaultDescription

      spoolssd:prefork_min_children

      5

      Minimum number of child processes

      spoolssd:prefork_max_children

      25

      Maximum number of child processes

      spoolssd:prefork_spawn_rate

      5

      Samba forks the number of new child processes set in this parameter, up to the value set in spoolssd:prefork_max_children, if a new connection is established

      spoolssd:prefork_max_allowed_clients

      100

      Number of clients, a child process serves

      spoolssd:prefork_child_min_life

      60

      Minimum lifetime of a child process in seconds. 60 seconds is the minimum.

  2. Verify the /etc/samba/smb.conf file:

    # testparm
  3. Restart the smb service:

    # systemctl restart smb

    After you restarted the service, Samba automatically starts smbd child processes:

    # ps axf
    ...
    30903 smbd
    30912  \_ smbd
    30913      \_ smbd
    30914      \_ smbd
    30915      \_ smbd
    ...

2.8.2. Enabling print server support in Samba

This section explains how to enable the print server support in Samba.

Procedure

  1. On the Samba server, set up CUPS and add the printer to the CUPS back end. For details about configuring printers in CUPS; see the documentation provided in the CUPS web console (https://print_server_host_name:631/help) on the print server.

    Note

    Samba can only forward the print jobs to CUPS if CUPS is installed locally on the Samba print server.

  2. Edit the /etc/samba/smb.conf file:

    1. If you want to enable the spoolssd service, add the following parameters to the [global] section:

      rpc_server:spoolss = external
      rpc_daemon:spoolssd = fork
    2. To configure the printing back end, add the [printers] section:

      [printers]
              comment = All Printers
              path = /var/tmp/
              printable = yes
              create mask = 0600
      Important

      The [printers] share name is hard-coded and cannot be changed.

  3. Verify the /etc/samba/smb.conf file:

    # testparm
  4. Open the required ports and reload the firewall configuration using the firewall-cmd utility:

    # firewall-cmd --permanent --add-service=samba
    # firewall-cmd --reload
  5. Restart the smb service:

    # systemctl restart smb

After restarting the service, Samba automatically shares all printers that are configured in the CUPS back end. If you want to manually share only specific printers, see Section 2.8.3, “Manually sharing specific printers”.

Additional resources

2.8.3. Manually sharing specific printers

If you configured Samba as a print server, by default, Samba shares all printers that are configured in the CUPS back end. The following procedure explains how to share only specific printers.

Prerequisites

  • Samba is set up as a print server

Procedure

  1. Edit the /etc/samba/smb.conf file:

    1. In the [global] section, disable automatic printer sharing by setting:

      load printers = no
    2. Add a section for each printer you want to share. For example, to share the printer named example in the CUPS back end as Example-Printer in Samba, add the following section:

      [Example-Printer]
              path = /var/tmp/
              printable = yes
              printer name = example

      You do not need individual spool directories for each printer. You can set the same spool directory in the path parameter for the printer as you set in the [printers] section.

  2. Verify the /etc/samba/smb.conf file:

    # testparm
  3. Reload the Samba configuration:

    # smbcontrol all reload-config

2.8.4. Setting up automatic printer driver downloads for Windows clients

If you are running a Samba print server for Windows clients, you can upload drivers and preconfigure printers. If a user connects to a printer, Windows automatically downloads and installs the driver locally on the client. The user does not require local administrator permissions for the installation. Additionally, Windows applies preconfigured driver settings, such as the number of trays.

Parts of this section were adopted from the Setting up Automatic Printer Driver Downloads for Windows Clients documentation published in the Samba Wiki. License: CC BY 4.0. Authors and contributors: See the history tab on the Wiki page.

Prerequisites

  • Samba is set up as a print server

2.8.4.1. Basic information about printer drivers

This section provides general information about printer drivers.

Supported driver model version

Samba only supports the printer driver model version 3 which is supported in Windows 2000 and later, and Windows Server 2000 and later. Samba does not support the driver model version 4, introduced in Windows 8 and Windows Server 2012. However, these and later Windows versions also support version 3 drivers.

Package-aware drivers

Samba does not support package-aware drivers.

Preparing a printer driver for being uploaded

Before you can upload a driver to a Samba print server:

  • Unpack the driver if it is provided in a compressed format.
  • Some drivers require to start a setup application that installs the driver locally on a Windows host. In certain situations, the installer extracts the individual files into the operating system’s temporary folder during the setup runs. To use the driver files for uploading:

    1. Start the installer.
    2. Copy the files from the temporary folder to a new location.
    3. Cancel the installation.

Ask your printer manufacturer for drivers that support uploading to a print server.

Providing 32-bit and 64-bit drivers for a printer to a client

To provide the driver for a printer for both 32-bit and 64-bit Windows clients, you must upload a driver with exactly the same name for both architectures. For example, if you are uploading the 32-bit driver named Example PostScript and the 64-bit driver named Example PostScript (v1.0), the names do not match. Consequently, you can only assign one of the drivers to a printer and the driver will not be available for both architectures.

2.8.4.2. Enabling users to upload and preconfigure drivers

To be able to upload and preconfigure printer drivers, a user or a group needs to have the SePrintOperatorPrivilege privilege granted. A user must be added into the printadmin group. Red Hat Enterprise Linux automatically creates this group when you install the samba package. The printadmin group gets assigned the lowest available dynamic system GID that is lower than 1000.

Procedure

  1. For example, to grant the SePrintOperatorPrivilege privilege to the printadmin group:

    # net rpc rights grant "printadmin" SePrintOperatorPrivilege \
           -U "DOMAIN\administrator"
    Enter DOMAIN\administrator's password:
    Successfully granted rights.
    Note

    In a domain environment, grant SePrintOperatorPrivilege to a domain group. This enables you to centrally manage the privilege by updating a user’s group membership.

  2. To list all users and groups having SePrintOperatorPrivilege granted:

    # net rpc rights list privileges SePrintOperatorPrivilege \
           -U "DOMAIN\administrator"
    Enter administrator's password:
    SePrintOperatorPrivilege:
      BUILTIN\Administrators
      DOMAIN\printadmin

2.8.4.3. Setting up the print$ share

Windows operating systems download printer drivers from a share named print$ from a print server. This share name is hard-coded in Windows and cannot be changed.

The following procedure explains how to share the /var/lib/samba/drivers/ directory as print$, and enable members of the local printadmin group to upload printer drivers.

Procedure

  1. Add the [print$] section to the /etc/samba/smb.conf file:

    [print$]
            path = /var/lib/samba/drivers/
            read only = no
            write list = @printadmin
            force group = @printadmin
            create mask = 0664
            directory mask = 2775

    Using these settings:

    Only members of the printadmin group can upload printer drivers to the share.

    • The group of new created files and directories will be set to printadmin.
    • The permissions of new files will be set to 664.
    • The permissions of new directories will be set to 2775.
  2. To upload only 64-bit drivers for a printer, include this setting in the [global] section in the /etc/samba/smb.conf file:

    spoolss: architecture = Windows x64

    Without this setting, Windows only displays drivers for which you have uploaded at least the 32-bit version.

  3. Verify the /etc/samba/smb.conf file:

    # testparm
  4. Reload the Samba configuration

    # smbcontrol all reload-config
  5. Create the printadmin group if it does not exists:

    # groupadd printadmin
  6. Grant the SePrintOperatorPrivilege privilege to the printadmin group.

    # net rpc rights grant "printadmin" SePrintOperatorPrivilege \
           -U "DOMAIN\administrator"
    Enter DOMAIN\administrator's password:
    Successfully granted rights.
  7. If you run SELinux in enforcing mode, set the samba_share_t context on the directory:

    # semanage fcontext -a -t samba_share_t "/var/lib/samba/drivers(/.*)?"
    # restorecon -Rv /var/lib/samba/drivers/
  8. Set the permissions on the /var/lib/samba/drivers/ directory:

    • If you use POSIX ACLs, set:

      # chgrp -R "printadmin" /var/lib/samba/drivers/
      # chmod -R 2775 /var/lib/samba/drivers/
    • If you use Windows ACLs, set:

      PrincipalAccessApply to

      CREATOR OWNER

      Full control

      Subfolders and files only

      Authenticated Users

      Read & execute, List folder contents, Read

      This folder, subfolders, and files

      printadmin

      Full control

      This folder, subfolders, and files

      For details about setting ACLs on Windows, see the Windows documentation.

2.8.4.4. Creating a GPO to enable clients to trust the Samba print server

For security reasons, recent Windows operating systems prevent clients from downloading non-package-aware printer drivers from an untrusted server. If your print server is a member in an AD, you can create a Group Policy Object (GPO) in your domain to trust the Samba server.

Prerequisites

  • The Samba print server is a member of an AD domain.
  • The Windows computer you are using to create the GPO must have the Windows Remote Server Administration Tools (RSAT) installed. For details, see the Windows documentation.

Procedure

  1. Log into a Windows computer using an account that is allowed to edit group policies, such as the AD domain Administrator user.
  2. Open the Group Policy Management Console.
  3. Right-click to your AD domain and select Create a GPO in this domain, and Link it here.

    samba create new GPO
  4. Enter a name for the GPO, such as Legacy Printer Driver Policy and click OK. The new GPO will be displayed under the domain entry.
  5. Right-click to the newly-created GPO and select Edit to open the Group Policy Management Editor.
  6. Navigate to Computer ConfigurationPoliciesAdministrative TemplatesPrinters.

    samba select printer GPO group
  7. On the right side of the window, double-click Point and Print Restriction to edit the policy:

    1. Enable the policy and set the following options:

      1. Select Users can only point and print to these servers and enter the fully-qualified domain name (FQDN) of the Samba print server to the field next to this option.
      2. In both check boxes under Security Prompts, select Do not show warning or elevation prompt.

        samba GPO point and print
    2. Click OK.
  8. Double-click Package Point and Print - Approved servers to edit the policy:

    1. Enable the policy and click the Show button.
    2. Enter the FQDN of the Samba print server.

      samba GPO approved servers
    3. Close both the Show Contents and the policy’s properties window by clicking OK.
  9. Close the Group Policy Management Editor.
  10. Close the Group Policy Management Console.

After the Windows domain members applied the group policy, printer drivers are automatically downloaded from the Samba server when a user connects to a printer.

Additional resources

  • For further details about using group policies, see the Windows documentation.

2.8.4.5. Uploading drivers and preconfiguring printers

Use the Print Management application on a Windows client to upload drivers and preconfigure printers hosted on the Samba print server. For further details, see the Windows documentation.

2.9. Tuning the performance of a Samba server

This chapter describes what settings can improve the performance of Samba in certain situations, and which settings can have a negative performance impact.

Parts of this section were adopted from the Performance Tuning documentation published in the Samba Wiki. License: CC BY 4.0. Authors and contributors: See the history tab on the Wiki page.

Prerequisites

  • Samba is set up as a file or print server

2.9.1. Setting the SMB protocol version

Each new SMB version adds features and improves the performance of the protocol. The recent Windows and Windows Server operating systems always supports the latest protocol version. If Samba also uses the latest protocol version, Windows clients connecting to Samba benefit from the performance improvements. In Samba, the default value of the server max protocol is set to the latest supported stable SMB protocol version.

Note

To always have the latest stable SMB protocol version enabled, do not set the server max protocol parameter. If you set the parameter manually, you will need to modify the setting with each new version of the SMB protocol, to have the latest protocol version enabled.

The following procedure explains how to use the default value in the server max protocol parameter.

Procedure

  1. Remove the server max protocol parameter from the [global] section in the /etc/samba/smb.conf file.
  2. Reload the Samba configuration

    # smbcontrol all reload-config

2.9.2. Tuning shares with directories that contain a large number of files

Linux supports case-sensitive file names. For this reason, Samba needs to scan directories for uppercase and lowercase file names when searching or accessing a file. You can configure a share to create new files only in lowercase or uppercase, which improves the performance.

Prerequisites

  • Samba is configured as a file server

Procedure

  1. Rename all files on the share to lowercase.

    Note

    Using the settings in this procedure, files with names other than in lowercase will no longer be displayed.

  2. Set the following parameters in the share’s section:

    case sensitive = true
    default case = lower
    preserve case = no
    short preserve case = no

    For details about the parameters, see their descriptions in the smb.conf(5) man page.

  3. Verify the /etc/samba/smb.conf file:

    # testparm
  4. Reload the Samba configuration:

    # smbcontrol all reload-config

After you applied these settings, the names of all newly created files on this share use lowercase. Because of these settings, Samba no longer needs to scan the directory for uppercase and lowercase, which improves the performance.

Additional resources

samba docs

2.9.3. Settings that can have a negative performance impact

By default, the kernel in Red Hat Enterprise Linux is tuned for high network performance. For example, the kernel uses an auto-tuning mechanism for buffer sizes. Setting the socket options parameter in the /etc/samba/smb.conf file overrides these kernel settings. As a result, setting this parameter decreases the Samba network performance in most cases.

To use the optimized settings from the Kernel, remove the socket options parameter from the [global] section in the /etc/samba/smb.conf.

2.10. Frequently used Samba command-line utilities

This chapter describes frequently used commands when working with a Samba server.

2.10.1. Using the net utility

The net utility enables you to perform several administration tasks on a Samba server. This section describes the most frequently used subcommands of the net utility.

Prerequisites

  • The samba-common-tools package is installed.

2.10.1.1. Using the net ads join and net rpc join commands

Using the join subcommand of the net utility, you can join Samba to an AD or NT4 domain. To join the domain, you must create the /etc/samba/smb.conf file manually, and optionally update additional configurations, such as PAM.

Important

Red Hat recommends using the realm utility to join a domain. The realm utility automatically updates all involved configuration files. For details, see Section 2.5.1, “Joining Samba to a Domain”.

Procedure

  1. Manually create the /etc/samba/smb.conf file with the following settings:

    • For an AD domain member:

      [global]
      workgroup = domain_name
      security = ads
      passdb backend = tdbsam
      realm = AD_REALM
    • For an NT4 domain member:

      [global]
      workgroup = domain_name
      security = user
      passdb backend = tdbsam
  2. Add an ID mapping configuration for the * default domain and for the domain you want to join to the [global] section in the /etc/samba/smb.conf file. For details, see Section 2.5.4, “Samba ID mapping”.
  3. Verify the /etc/samba/smb.conf file:

    # testparm
  4. Join the domain as the domain administrator:

    • To join an AD domain:

      # net ads join -U "DOMAIN\administrator"
    • To join an NT4 domain:

      # net rpc join -U "DOMAIN\administrator"
  5. Append the winbind source to the passwd and group database entry in the /etc/nsswitch.conf file:

    passwd:     files winbind
    group:      files winbind
  6. Enable and start the winbind service:

    # systemctl enable winbind
    # systemctl start winbind
  7. Optionally, configure PAM using the authselect utility.

    For details, see the authselect(8) man page.

  8. Optionally for AD environments, configure the Kerberos client.

    For details, see the documentation of your Kerberos client.

2.10.1.2. Using the net rpc rights command

In Windows, you can assign privileges to accounts and groups to perform special operations, such as setting ACLs on a share or upload printer drivers. On a Samba server, you can use the net rpc rights command to manage privileges.

Listing privileges you can set

To list all available privileges and their owners, use the net rpc rights list command. For example:

net rpc rights list -U "DOMAIN\administrator"
Enter DOMAIN\administrator's password:
     SeMachineAccountPrivilege  Add machines to domain
      SeTakeOwnershipPrivilege  Take ownership of files or other objects
             SeBackupPrivilege  Back up files and directories
            SeRestorePrivilege  Restore files and directories
     SeRemoteShutdownPrivilege  Force shutdown from a remote system
      SePrintOperatorPrivilege  Manage printers
           SeAddUsersPrivilege  Add users and groups to the domain
       SeDiskOperatorPrivilege  Manage disk shares
           SeSecurityPrivilege  System security
Granting privileges

To grant a privilege to an account or group, use the net rpc rights grant command.

For example, grant the SePrintOperatorPrivilege privilege to the DOMAIN\printadmin group:

# net rpc rights grant "DOMAIN\printadmin" SePrintOperatorPrivilege \
       -U "DOMAIN\administrator"
Enter DOMAIN\administrator's password:
Successfully granted rights.
Revoking privileges

To revoke a privilege from an account or group, use the net rpc rights revoke command.

For example, to revoke the SePrintOperatorPrivilege privilege from the DOMAIN\printadmin group:

# net rpc rights remoke "DOMAIN\printadmin" SePrintOperatorPrivilege \
       -U "DOMAIN\administrator"
Enter DOMAIN\administrator's password:
Successfully revoked rights.

2.10.1.3. Using the net rpc share command

The net rpc share command provides the capability to list, add, and remove shares on a local or remote Samba or Windows server.

Listing shares

To list the shares on an SMB server, use the net rpc share list command. Optionally, pass the -S server_name parameter to the command to list the shares of a remote server. For example:

# net rpc share list -U "DOMAIN\administrator" -S server_name
Enter DOMAIN\administrator's password:
IPC$
share_1
share_2
...
Note

Shares hosted on a Samba server that have browseable = no set in their section in the /etc/samba/smb.conf file are not displayed in the output.

Adding a share

The net rpc share add command enables you to add a share to an SMB server.

For example, to add a share named example on a remote Windows server that shares the C:\example\ directory:

# net rpc share add example="C:\example" -U "DOMAIN\administrator" -S server_name
Note

You must omit the trailing backslash in the path when specifying a Windows directory name.

To use the command to add a share to a Samba server:

  • The user specified in the -U parameter must have the SeDiskOperatorPrivilege privilege granted on the destination server.
  • You must write a script that adds a share section to the /etc/samba/smb.conf file and reloads Samba. The script must be set in the add share command parameter in the [global] section in /etc/samba/smb.conf. For further details, see the add share command description in the smb.conf(5) man page.
Removing a share

The net rpc share delete command enables you to remove a share from an SMB server.

For example, to remove the share named example from a remote Windows server:

# net rpc share delete example -U "DOMAIN\administrator" -S server_name

To use the command to remove a share from a Samba server:

  • The user specified in the -U parameter must have the SeDiskOperatorPrivilege privilege granted.
  • You must write a script that removes the share’s section from the /etc/samba/smb.conf file and reloads Samba. The script must be set in the delete share command parameter in the [global] section in /etc/samba/smb.conf. For further details, see the delete share command description in the smb.conf(5) man page.

2.10.1.4. Using the net user command

The net user command enables you to perform the following actions on an AD DC or NT4 PDC:

  • List all user accounts
  • Add users
  • Remove Users
Note

Specifying a connection method, such as ads for AD domains or rpc for NT4 domains, is only required when you list domain user accounts. Other user-related subcommands can auto-detect the connection method.

Pass the -U user_name parameter to the command to specify a user that is allowed to perform the requested action.

Listing domain user accounts

To list all users in an AD domain:

# net ads user -U "DOMAIN\administrator"

To list all users in an NT4 domain:

# net rpc user -U "DOMAIN\administrator"
Adding a user account to the domain

On a Samba domain member, you can use the net user add command to add a user account to the domain.

For example, add the user account to the domain:

  1. Add the account:

    # net user add user password -U "DOMAIN\administrator"
    User user added
  2. Optionally, use the remote procedure call (RPC) shell to enable the account on the AD DC or NT4 PDC. For example:

    # net rpc shell -U DOMAIN\administrator -S DC_or_PDC_name
    Talking to domain DOMAIN (S-1-5-21-1424831554-512457234-5642315751)
    
    net rpc> user edit disabled user: no
    Set user's disabled flag from [yes] to [no]
    
    net rpc> exit
Deleting a user account from the domain

On a Samba domain member, you can use the net user delete command to remove a user account from the domain.

For example, to remove the user account from the domain:

# net user delete user -U "DOMAIN\administrator"
User user deleted

2.10.1.5. Using the net usershare command

On a Samba server, you can configure that users can share directories without root permissions.

2.10.1.5.1. Enabling the user shares feature

Before users can share directories, the administrator must enable user shares in Samba.

For example, to enable only members of the local example group to create user shares.

Procedure

  1. Create the local example group, if it does not exist:

    # groupadd example
  2. Prepare the directory for Samba to store the user share definitions and set its permissions properly. For example:

    1. Create the directory:

      # mkdir -p /var/lib/samba/usershares/
    2. Set write permissions for the example group:

      # chgrp example /var/lib/samba/usershares/
      # chmod 1770 /var/lib/samba/usershares/
    3. Set the sticky bit to prevent users to rename or delete files stored by other users in this directory.
  3. Edit the /etc/samba/smb.conf file and add the following to the [global] section:

    1. Set the path to the directory you configured to store the user share definitions. For example:

      usershare path = /var/lib/samba/usershares/
    2. Set how many user shares Samba allows to be created on this server. For example:

      usershare max shares = 100

      If you use the default of 0 for the usershare max shares parameter, user shares are disabled.

    3. Optionally, set a list of absolute directory paths. For example, to configure that Samba only allows to share subdirectories of the /data and /srv directory to be shared, set:

      usershare prefix allow list = /data /srv

    For a list of further user share-related parameters you can set, see the USERSHARES section in the smb.conf(5) man page.

  4. Verify the /etc/samba/smb.conf file:

    # testparm
  5. Reload the Samba configuration:

    # smbcontrol all reload-config

Users are now able to create user shares. For details, see Section 2.7.4.2, “Adding a user share”.

2.10.1.5.2. Adding a user share

After you configured Samba according to Section 2.7.4.1, “Enabling the user shares feature”, users can share directories on the Samba server without root permissions by running the net usershare add command.

Synopsis of the net usershare add command:

net usershare add share_name path [[ comment ] | [ ACLs ]] [ guest_ok=y|n ]

Important

If you set ACLs when you create a user share, you must specify the comment parameter prior to the ACLs. To set an empty comment, use an empty string in double quotes.

Note that users can only enable guest access on a user share, if the administrator set usershare allow guests = yes in the [global] section in the /etc/samba/smb.conf file.

Example 2.8. Adding a user share

A user wants to share the /srv/samba/ directory on a Samba server. The share should be named example, have no comment set, and should be accessible by guest users. Additionally, the share permissions should be set to full access for the AD\Domain Users group and read permissions for other users. To add this share, run as the user:

$ net usershare add example /srv/samba/ "" \
       "AD\Domain Users":F,Everyone:R guest_ok=yes
2.10.1.5.3. Updating settings of a user share

To update settings of a user share, override the share by using the net usershare add command with the same share name and the new settings. See Section 2.7.4.2, “Adding a user share”.

2.10.1.5.4. Displaying information about existing user shares

Users can enter the net usershare info command on a Samba server to display user shares and their settings.

Prerequisites

  • A user share is configured on the Samba server.

Procedure

  1. To display all user shares created by any user:

    $ net usershare info -l
    [share_1]
    path=/srv/samba/
    comment=
    usershare_acl=Everyone:R,host_name\user:F,
    guest_ok=y
    ...

    To list only shares created by the user who runs the command, omit the -l parameter.

  2. To display only the information about specific shares, pass the share name or wild cards to the command. For example, to display the information about shares whose name starts with share_:

    $ net usershare info -l share_*
2.10.1.5.5. Listing user shares

If you want to list only the available user shares without their settings on a Samba server, use the net usershare list command.

Prerequisites

  • A user share is configured on the Samba server.

Procedure

  1. To list the shares created by any user:

    $ net usershare list -l
    share_1
    share_2
    ...

    To list only shares created by the user who runs the command, omit the -l parameter.

  2. To list only specific shares, pass the share name or wild cards to the command. For example, to list only shares whose name starts with share_:

    $ net usershare list -l share_*
2.10.1.5.6. Deleting a user share

To delete a user share, use the command net usershare delete command as the user who created the share or as the root user.

Prerequisites

  • A user share is configured on the Samba server.

Procedure

$ net usershare delete share_name

2.10.2. Using the rpcclient utility

The rpcclient utility enables you to manually execute client-side Microsoft Remote Procedure Call (MS-RPC) functions on a local or remote SMB server. However, most of the features are integrated into separate utilities provided by Samba. Use rpcclient only for testing MS-PRC functions.

Prerequisites

  • The samba-client package is installed.
Examples

For example, you can use the rpcclient utility to:

  • Manage the printer Spool Subsystem (SPOOLSS).

    Example 2.9. Assigning a Driver to a Printer

    # rpcclient server_name -U "DOMAIN\administrator" \
           -c 'setdriver "printer_name" "driver_name"'
    Enter DOMAIN\administrators password:
    Successfully set printer_name to driver driver_name.
  • Retrieve information about an SMB server.

    Example 2.10. Listing all File Shares and Shared Printers

    # rpcclient server_name -U "DOMAIN\administrator" -c 'netshareenum'
    Enter DOMAIN\administrators password:
    netname: Example_Share
    	remark:
    	path:   C:\srv\samba\example_share\
    	password:
    netname: Example_Printer
    	remark:
    	path:   C:\var\spool\samba\
    	password:
  • Perform actions using the Security Account Manager Remote (SAMR) protocol.

    Example 2.11. Listing Users on an SMB Server

    # rpcclient server_name -U "DOMAIN\administrator" -c 'enumdomusers'
    Enter DOMAIN\administrators password:
    user:[user1] rid:[0x3e8]
    user:[user2] rid:[0x3e9]

    If you run the command against a standalone server or a domain member, it lists the users in the local database. Running the command against an AD DC or NT4 PDC lists the domain users.

Additional resources

For a complete list of supported subcommands, see the COMMANDS section in the rpcclient(1) man page.

2.10.3. Using the samba-regedit application

Certain settings, such as printer configurations, are stored in the registry on the Samba server. You can use the ncurses-based samba-regedit application to edit the registry of a Samba server.

samba regedit

Prerequisites

  • The samba-client package is installed.

Procedure

To start the application, enter:

# samba-regedit

Use the following keys:

  • Cursor up and cursor down: Navigate through the registry tree and the values.
  • Enter: Opens a key or edits a value.
  • Tab: Switches between the Key and Value pane.
  • Ctrl+C: Closes the application.

2.10.4. Using the smbcacls utility

The smbcacls utility can list, set, and delete ACLs of files and directories stored on an SMB share. You can use smbcacls to manage file system ACLs:

  • On a local or remote Samba server that uses advanced Windows ACLs or POSIX ACLs
  • On Red Hat Enterprise Linux to remotely manage ACLs on a share hosted on Windows

2.10.4.1. Access control entries

Each ACL entry of a file system object contains Access Control Entries (ACE) in the following format:

security_principal:access_right/inheritance_information/permissions

Example 2.12. Access control entries

If the AD\Domain Users group has Modify permissions that apply to This folder, subfolders, and files on Windows, the ACL contains the following ACE:

AD\Domain Users:ALLOWED/OI|CI/CHANGE

An ACE contains the following parts:

Security principal
The security principal is the user, group, or SID the permissions in the ACL are applied to.
Access right
Defines if access to an object is granted or denied. The value can be ALLOWED or DENIED.
Inheritance information

The following values exist:

Table 2.5. Inheritance settings

ValueDescriptionMaps to

OI

Object Inherit

This folder and files

CI

Container Inherit

This folder and subfolders

IO

Inherit Only

The ACE does not apply to the current file or directory

ID

Inherited

The ACE was inherited from the parent directory

Additionally, the values can be combined as follows:

Table 2.6. Inheritance settings combinations

Value combinationsMaps to the Windows Applies to setting

OI|CI

This folder, subfolders, and files

OI|CI|IO

Subfolders and files only

CI|IO

Subfolders only

OI|IO

Files only

Permissions

This value can be either a hex value that represents one or more Windows permissions or an smbcacls alias:

  • A hex value that represents one or more Windows permissions.

    The following table displays the advanced Windows permissions and their corresponding value in hex format:

    Table 2.7. Windows permissions and their corresponding smbcacls value in hex format

    Windows permissionsHex values

    Full control

    0x001F01FF

    Traverse folder / execute file

    0x00100020

    List folder / read data

    0x00100001

    Read attributes

    0x00100080

    Read extended attributes

    0x00100008

    Create files / write data

    0x00100002

    Create folders / append data

    0x00100004

    Write attributes

    0x00100100

    Write extended attributes

    0x00100010

    Delete subfolders and files

    0x00100040

    Delete

    0x00110000

    Read permissions

    0x00120000

    Change permissions

    0x00140000

    Take ownership

    0x00180000

    Multiple permissions can be combined as a single hex value using the bit-wise OR operation. For details, see Section 2.7.3.3, “ACE mask calculation”.

  • An smbcacls alias. The following table displays the available aliases:

    Table 2.8. Existing smbcacls aliases and their corresponding Windows permission

    smbcacls aliasMaps to Windows permission

    R

    Read

    READ

    Read & execute

    W

    Special:

    • Create files / write data
    • Create folders / append data
    • Write attributes
    • Write extended attributes
    • Read permissions

    D

    Delete

    P

    Change permissions

    O

    Take ownership

    X

    Traverse / execute

    CHANGE

    Modify

    FULL

    Full control

    Note

    You can combine single-letter aliases when you set permissions. For example, you can set RD to apply the Windows permission Read and Delete. However, you can neither combine multiple non-single-letter aliases nor combine aliases and hex values.

2.10.4.2. Displaying ACLs using smbcacls

To display ACLs on an SMB share, use the smbcacls utility. If you run smbcacls without any operation parameter, such as --add, the utility displays the ACLs of a file system object.

Procedure

For example, to list the ACLs of the root directory of the //server/example share:

# smbcacls //server/example / -U "DOMAIN\administrator"
Enter DOMAIN\administrator's password:
REVISION:1
CONTROL:SR|PD|DI|DP
OWNER:AD\Administrators
GROUP:AD\Domain Users
ACL:AD\Administrator:ALLOWED/OI|CI/FULL
ACL:AD\Domain Users:ALLOWED/OI|CI/CHANGE
ACL:AD\Domain Guests:ALLOWED/OI|CI/0x00100021

The output of the command displays:

  • REVISION: The internal Windows NT ACL revision of the security descriptor
  • CONTROL: Security descriptor control
  • OWNER: Name or SID of the security descriptor’s owner
  • GROUP: Name or SID of the security descriptor’s group
  • ACL entries. For details, see Section 2.7.3.1, “Access control entries”.

2.10.4.3. ACE mask calculation

In most situations, when you add or update an ACE, you use the smbcacls aliases listed in Table 2.4, “Existing smbcacls aliases and their corresponding Windows permission”.

However, if you want to set advanced Windows permissions as listed in Table 2.3, “Windows permissions and their corresponding smbcacls value in hex format”, you must use the bit-wise OR operation to calculate the correct value. You can use the following shell command to calculate the value:

# echo $(printf '0x%X' $(( hex_value_1 | hex_value_2 | ... )))

Example 2.13. Calculating an ACE Mask

You want to set the following permissions:

  • Traverse folder / execute file (0x00100020)
  • List folder / read data (0x00100001)
  • Read attributes (0x00100080)

To calculate the hex value for the previous permissions, enter:

# echo $(printf '0x%X' $(( 0x00100020 | 0x00100001 | 0x00100080 )))
0x1000A1

Use the returned value when you set or update an ACE.

2.10.4.4. Adding, updating, and removing an ACL using smbcacls

Depending on the parameter you pass to the smbcacls utility, you can add, update, and remove ACLs from a file or directory.

Adding an ACL

To add an ACL to the root of the //server/example share that grants CHANGE permissions for This folder, subfolders, and files to the AD\Domain Users group:

# smbcacls //server/example / -U "DOMAIN\administrator \
       --add ACL:"AD\Domain Users":ALLOWED/OI|CI/CHANGE
Updating an ACL

Updating an ACL is similar to adding a new ACL. You update an ACL by overriding the ACL using the --modify parameter with an existing security principal. If smbcacls finds the security principal in the ACL list, the utility updates the permissions. Otherwise the command fails with an error:

ACL for SID principal_name not found

For example, to update the permissions of the AD\Domain Users group and set them to READ for This folder, subfolders, and files:

# smbcacls //server/example / -U "DOMAIN\administrator \
       --modify ACL:"AD\Domain Users":ALLOWED/OI|CI/READ
Deleting an ACL

To delete an ACL, pass the --delete parameter with the exact ACL to the smbcacls utility. For example:

# smbcacls //server/example / -U "DOMAIN\administrator \
       --delete ACL:"AD\Domain Users":ALLOWED/OI|CI/READ

2.10.5. Using the smbclient utility

The smbclient utility enables you to access file shares on an SMB server, similarly to a command-line FTP client. You can use it, for example, to upload and download files to and from a share.

Prerequisites

  • The samba-client package is installed.

2.10.5.1. How the smbclient interactive mode works

For example, to authenticate to the example share hosted on server using the DOMAIN\user account:

# smbclient -U "DOMAIN\user" //server/example
Enter domain\user's password:
Try "help" to get a list of possible commands.
smb: \>

After smbclient connected successfully to the share, the utility enters the interactive mode and shows the following prompt:

smb: \>

To display all available commands in the interactive shell, enter:

smb: \> help

To display the help for a specific command, enter:

smb: \> help command_name

Additional resources

  • For further details and descriptions of the commands available in the interactive shell, see the smbclient(1) man page.

2.10.5.2. Using smbclient in interactive mode

If you use smbclient without the -c parameter, the utility enters the interactive mode. The following procedure shows how to connect to an SMB share and download a file from a subdirectory.

Procedure

  1. Connect to the share:

    # smbclient -U "DOMAIN\user_name" //server_name/share_name
  2. Change into the /example/ directory:

    smb: \> cd /example/
  3. List the files in the directory:

    smb: \example\> ls
      .                    D         0  Thu Nov 1 10:00:00 2018
      ..                   D         0  Thu Nov 1 10:00:00 2018
      example.txt          N   1048576  Thu Nov 1 10:00:00 2018
    
             9950208 blocks of size 1024. 8247144 blocks available
  4. Download the example.txt file:

    smb: \example\> get example.txt
    getting file \directory\subdirectory\example.txt of size 1048576 as example.txt (511975,0 KiloBytes/sec) (average 170666,7 KiloBytes/sec)
  5. Disconnect from the share:

    smb: \example\> exit

2.10.5.3. Using smbclient in scripting mode

If you pass the -c parameter to smbclient, you can automatically execute the commands on the remote SMB share. This enables you to use smbclient in scripts.

The following procedure shows how to connect to an SMB share and download a file from a subdirectory.

Procedure

# smbclient -U DOMAIN\user_name //server_name/share_name \
       -c "cd /example/ ; get example.txt ; exit"

2.10.6. Using the smbcontrol utility

The smbcontrol utility enables you to send command messages to the smbd, nmbd, winbindd, or all of these services. These control messages instruct the service, for example, to reload its configuration.

The procedure in this section shows how to to reload the configuration of the smbd, nmbd, winbindd services by sending the reload-config message type to the all destination.

Prerequisites

  • The samba-common-tools package is installed.

Procedure

# smbcontrol all reload-config

Additional resources

For further details and a list of available command message types, see the smbcontrol(1) man page.

2.10.7. Using the smbpasswd utility

The smbpasswd utility manages user accounts and passwords in the local Samba database.

Prerequisites

  • The samba-common-tools package is installed.

Procedure

  1. If you run the command as a user, smbpasswd changes the Samba password of the user who run the command. For example:

    [user@server ~]$ smbpasswd
    New SMB password: password
    Retype new SMB password: password
  2. If you run smbpasswd as the root user, you can use the utility, for example, to:

    • Create a new user:

      [root@server ~]# smbpasswd -a user_name
      New SMB password: password
      Retype new SMB password: password
      Added user user_name.
      Note

      Before you can add a user to the Samba database, you must create the account in the local operating system. See the Adding a new user section in the Configuring and managing system administration guide.

    • Enable a Samba user:

      [root@server ~]# smbpasswd -e user_name
      Enabled user user_name.
    • Disable a Samba user:

      [root@server ~]# smbpasswd -x user_name
      Disabled user ser_name
    • Delete a user:

      [root@server ~]# smbpasswd -x user_name
      Deleted user user_name.

Additional resources

For further details, see the smbpasswd(8) man page.

2.10.8. Using the smbstatus utility

The smbstatus utility reports on:

  • Connections per PID of each smbd daemon to the Samba server. This report includes the user name, primary group, SMB protocol version, encryption, and signing information.
  • Connections per Samba share. This report includes the PID of the smbd daemon, the IP of the connecting machine, the time stamp when the connection was established, encryption, and signing information.
  • A list of locked files. The report entries include further details, such as opportunistic lock (oplock) types

Prerequisites

  • The samba package is installed.
  • The smbd service is running.

Procedure

# smbstatus

Samba version 4.7.1
PID  Username              Group                Machine                            Protocol Version  Encryption  Signing
-----------------------------------------------------------------------------------------------------------------------------
963  DOMAIN\administrator  DOMAIN\domain users  client-pc  (ipv4:192.0.2.1:57786)  SMB3_02           -           AES-128-CMAC

Service  pid  Machine    Connected at                  Encryption  Signing:
-------------------------------------------------------------------------------
example  969  192.0.2.1  Thu Nov  1 10:00:00 2018 CEST  -           AES-128-CMAC

Locked files:
Pid  Uid    DenyMode   Access    R/W     Oplock      SharePath           Name      Time
------------------------------------------------------------------------------------------------------------
969  10000  DENY_WRITE 0x120089  RDONLY  LEASE(RWH)  /srv/samba/example  file.txt  Thu Nov  1 10:00:00 2018

Additional resources

For further details, see the smbstatus(1) man page.

2.10.9. Using the smbtar utility

The smbtar utility backs up the content of an SMB share or a subdirectory of it and stores the content in a tar archive. Alternatively, you can write the content to a tape device.

The procedure in this section describes how to back up the content of the demo directory on the //server/example/ share and store the content in the /root/example.tar archive.

Prerequisites

  • The samba-client package is installed.

Procedure

# smbtar -s server -x example -u user_name -p password -t /root/example.tar

Additional resources

For further details, see the smbtar(1) man page.

2.10.10. Using the testparm utility

The testparm utility verifies that the Samba configuration in the /etc/samba/smb.conf file is correct. The utility detects invalid parameters and values, but also incorrect settings, such as for ID mapping. If testparm reports no problem, the Samba services will successfully load the /etc/samba/smb.conf file. Note that testparm cannot verify that the configured services will be available or work as expected.

Important

Red Hat recommends that you verify the /etc/samba/smb.conf file by using testparm after each modification of this file.

Procedure

  1. Run the testparm utility as the root user:

    # testparm
    Load smb config files from /etc/samba/smb.conf
    rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
    Unknown parameter encountered: "log levell"
    Processing section "[example_share]"
    Loaded services file OK.
    ERROR: The idmap range for the domain * (tdb) overlaps with the range of DOMAIN (ad)!
    
    Server role: ROLE_DOMAIN_MEMBER
    
    Press enter to see a dump of your service definitions
    
    # Global parameters
    [global]
    	...
    
    [example_share]
    	...

    The previous example output reports a non-existent parameter and an incorrect ID mapping configuration.

  2. If testparm reports incorrect parameters, values, or other errors in the configuration, fix the problem and run the utility again.

2.10.11. Using the wbinfo utility

The wbinfo utility queries and returns information created and used by the winbindd service.

Prerequisites

  • The samba-winbind-clients package is installed.

Procedure

You can use wbinfo, for example, to:

  • List domain users:

    # wbinfo -u
    AD\administrator
    AD\guest
    ...
  • List domain groups:

    # wbinfo -g
    AD\domain computers
    AD\domain admins
    AD\domain users
    ...
  • Display the SID of a user:

    # wbinfo --name-to-sid="AD\administrator"
    S-1-5-21-1762709870-351891212-3141221786-500 SID_USER (1)
  • Display information about domains and trusts:

    # wbinfo --trusted-domains --verbose
    Domain Name   DNS Domain            Trust Type  Transitive  In   Out
    BUILTIN                             None        Yes         Yes  Yes
    server                              None        Yes         Yes  Yes
    DOMAIN1       domain1.example.com   None        Yes         Yes  Yes
    DOMAIN2       domain2.example.com   External    No          Yes  Yes

Additional resources

For further details, see the wbinfo(1) man page.