# Ensure ldap server services are not in use

An LDAP (Lightweight Directory Access Protocol) server provides directory services, often for user authentication and information storage. Running an unnecessary LDAP server significantly increases the system's attack surface. If the system is not intended to function as a directory server, the service introduces risks such as information disclosure, unauthorized access, and denial-of-service, especially if misconfigured or unpatched. The principle of least functionality dictates that any software not essential for the system's mission should be removed to minimize potential vulnerabilities. The audit script verifies if the 'slapd' package, the standard OpenLDAP server on Ubuntu, is installed. The remediation script purges this package, ensuring the service and its configuration files are completely removed. For this control, the recommended state is consistently 'Not Installed' across Basic, Moderate, and Strict levels. There is no secure configuration for an unnecessary service; its presence is the vulnerability. Therefore, removal is the only appropriate recommendation to maintain a hardened security posture.

## Recommended State Configuration

| Security Level | Value |
|----------------|-------|
| **Basic** | `['Not Installed']` |
| **Moderate** | `['Not Installed']` |
| **Strict** | `['Not Installed']` |
| **Type** | `ENUM` |

## Audit Script Working

Bash script that checks if the 'slapd' package is installed. The script should output 'Installed' if the package is present, and 'Not Installed' if it is not. The output must not contain any other text or labels.

## Remediation Script Working

Bash script that accepts one positional argument representing the desired state ('Not Installed'). If the argument is 'Not Installed', the script must use 'apt-get purge -y slapd' to completely remove the LDAP server package and its configuration files. The script must output 'true' if the operation succeeds or if the package is already uninstalled, and 'false' if it fails.

