# passdb-backend

`passdb-backend` is a Samba configuration parameter that specifies the storage mechanism used for Samba's password database. This setting determines where and how Samba stores user account information and password hashes. The choice of backend affects performance, scalability, and integration with other directory services.

## Common Backends

* **tdbsam**:
  * **Description**: A file-based backend that stores user information in a TDB (Trivial Database) file.
  * **Use Case**: It is the default and most common backend for small to medium-sized deployments.
  * **Example Configuration**:

    ```ini
    [global]
       passdb backend = tdbsam
    ```
* **smbpasswd**:
  * **Description**: A traditional backend that uses the `/etc/samba/smbpasswd` file to store password hashes.
  * **Use Case**: Typically used in legacy setups; less common in modern environments due to security and scalability limitations.
  * **Example Configuration**:

    ```ini
    [global]
       passdb backend = smbpasswd
    ```
* **ldapsam**:
  * **Description**: Uses an LDAP directory to store Samba account information. This backend is often used in environments that already use LDAP or Active Directory for centralized user management.
  * **Use Case**: Ideal for larger organizations or when integrating with a centralized directory service.
  * **Example Configuration**:

    ```ini
    [global]
       passdb backend = ldapsam:ldap://ldap.example.com
    ```

## Configuration Details

The `passdb-backend` setting is defined in the `[global]` section of the Samba configuration file (`smb.conf`). When selecting a backend, you should consider factors such as:

* **Integration Needs**:\
  For environments already using LDAP or Active Directory, `ldapsam` might be the best choice. For standalone servers, `tdbsam` is generally preferred.
* **Performance and Scalability**:\
  File-based backends like `tdbsam` work well for small-to-medium environments, while LDAP-based solutions are more scalable for large deployments.
* **Security**:\
  Ensure that the chosen backend and its associated storage (files or LDAP directory) are secured appropriately to protect sensitive user credentials.

## Example smb.conf Snippet

Below is an example configuration using the default `tdbsam` backend for local authentication:

```ini
[global]
   workgroup = MYGROUP
   server string = Samba Server
   security = user

   # Use tdbsam for storing user credentials and password hashes
   passdb backend = tdbsam
```

And an example configuration using `ldapsam`:

```ini
[global]
   workgroup = MYGROUP
   server string = Samba Server
   security = ADS
   realm = MYGROUP.COM
   encrypt passwords = yes

   # Use ldapsam for centralized user management via LDAP
   passdb backend = ldapsam:ldap://ldap.myorg.com
```

## Conclusion

The `passdb-backend` parameter is critical in determining how Samba handles user account data and password authentication. By choosing the appropriate backend (such as `tdbsam`, `smbpasswd`, or `ldapsam`), administrators can tailor Samba to meet the security, performance, and integration needs of their environment. Proper configuration and security practices ensure that user credentials are stored reliably and protected against unauthorized access.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://linux-tutorial-cli.gitbook.io/linux-cli-tutorial/txt-files/file-systems-cocepts/lpic3-300/passdb-backend.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
