|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +title: proxmox_realm_ldap |
| 4 | +parent: Resources |
| 5 | +subcategory: Virtual Environment |
| 6 | +description: |- |
| 7 | + Manages an LDAP authentication realm in Proxmox VE. |
| 8 | + LDAP realms allow Proxmox to authenticate users against an LDAP directory service. |
| 9 | +--- |
| 10 | + |
| 11 | +# Resource: proxmox_realm_ldap |
| 12 | + |
| 13 | +Manages an LDAP authentication realm in Proxmox VE. |
| 14 | + |
| 15 | +LDAP realms allow Proxmox to authenticate users against an LDAP directory service. |
| 16 | + |
| 17 | +## Privileges Required |
| 18 | + |
| 19 | +| Path | Attribute | |
| 20 | +|-----------------|----------------| |
| 21 | +| /access/domains | Realm.Allocate | |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +<!-- schema generated by tfplugindocs --> |
| 26 | +## Schema |
| 27 | + |
| 28 | +### Required |
| 29 | + |
| 30 | +- `base_dn` (String) LDAP base DN for user searches (e.g., 'ou=users,dc=example,dc=com'). |
| 31 | +- `realm` (String) Realm identifier (e.g., 'example.com'). |
| 32 | +- `server1` (String) Primary LDAP server hostname or IP address. |
| 33 | + |
| 34 | +### Optional |
| 35 | + |
| 36 | +- `bind_dn` (String) LDAP bind DN for authentication (e.g., 'cn=admin,dc=example,dc=com'). |
| 37 | +- `bind_password` (String, Sensitive) Password for the bind DN. Note: stored in Proxmox but not returned by API. |
| 38 | +- `ca_path` (String) Path to CA certificate file for SSL verification. |
| 39 | +- `case_sensitive` (Boolean) Enable case-sensitive username matching. |
| 40 | +- `cert_key_path` (String) Path to client certificate key. |
| 41 | +- `cert_path` (String) Path to client certificate for SSL authentication. |
| 42 | +- `comment` (String) Description of the realm. |
| 43 | +- `default` (Boolean) Use this realm as the default for login. |
| 44 | +- `filter` (String) LDAP filter for user searches. |
| 45 | +- `group_classes` (String) LDAP objectClasses for groups (comma-separated). |
| 46 | +- `group_dn` (String) LDAP base DN for group searches. |
| 47 | +- `group_filter` (String) LDAP filter for group searches. |
| 48 | +- `group_name_attr` (String) LDAP attribute representing the group name. |
| 49 | +- `mode` (String) LDAP connection mode (ldap, ldaps, ldap+starttls). |
| 50 | +- `port` (Number) LDAP server port. Default: 389 (LDAP) or 636 (LDAPS). |
| 51 | +- `secure` (Boolean, Deprecated) Use LDAPS (LDAP over SSL/TLS) instead of plain LDAP. |
| 52 | +- `server2` (String) Fallback LDAP server hostname or IP address. |
| 53 | +- `ssl_version` (String) SSL/TLS version (tlsv1, tlsv1_1, tlsv1_2, tlsv1_3). |
| 54 | +- `sync_attributes` (String) Comma-separated list of attributes to sync (e.g., 'email=mail,firstname=givenName'). |
| 55 | +- `sync_defaults_options` (String) Default synchronization options. Format: comma-separated 'key=value' pairs. Valid keys: 'scope' (users/groups/both), 'enable-new' (1/0), 'remove-vanished' (semicolon-separated: entry/acl/properties), 'full' (deprecated), 'purge' (deprecated). Example: 'scope=users,enable-new=1,remove-vanished=entry;acl'. |
| 56 | +- `user_attr` (String) LDAP attribute representing the username. |
| 57 | +- `user_classes` (String) LDAP objectClasses for users (comma-separated). |
| 58 | +- `verify` (Boolean) Verify LDAP server SSL certificate. |
| 59 | + |
| 60 | +### Read-Only |
| 61 | + |
| 62 | +- `id` (String) Realm identifier (same as realm) |
| 63 | + |
| 64 | +## Notes |
| 65 | + |
| 66 | +### Password Security |
| 67 | + |
| 68 | +The `bind_password` is sent to Proxmox and stored securely, but it's never returned by the API. This means: |
| 69 | +- Terraform cannot detect if the password was changed outside of Terraform |
| 70 | +- You must maintain the password in your Terraform configuration or use a variable |
| 71 | +- The password will be marked as sensitive in Terraform state |
| 72 | + |
| 73 | +### LDAP vs LDAPS |
| 74 | + |
| 75 | +- **LDAP (port 389)**: Unencrypted connection. Not recommended for production. |
| 76 | +- **LDAPS (port 636)**: Encrypted connection using SSL/TLS. Recommended for production. |
| 77 | +- **LDAP+StartTLS**: Upgrades plain LDAP connection to TLS. Alternative to LDAPS. |
| 78 | + |
| 79 | +### User Synchronization |
| 80 | + |
| 81 | +To trigger synchronization, use the `proxmox_realm_sync` resource. |
| 82 | + |
| 83 | +### Common Configuration Scenarios |
| 84 | + |
| 85 | +#### Anonymous Binding |
| 86 | +For testing or public LDAP servers, omit `bind_dn` and `bind_password` to use anonymous binding: |
| 87 | +```hcl |
| 88 | +resource "proxmox_realm_ldap" "anonymous" { |
| 89 | + realm = "public-ldap" |
| 90 | + server1 = "ldap.example.com" |
| 91 | + base_dn = "ou=users,dc=example,dc=com" |
| 92 | + user_attr = "uid" |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +#### Secure LDAPS with Failover |
| 97 | +```hcl |
| 98 | +resource "proxmox_realm_ldap" "secure" { |
| 99 | + realm = "secure-ldap" |
| 100 | + server1 = "ldap1.example.com" |
| 101 | + server2 = "ldap2.example.com" # Failover server |
| 102 | + port = 636 |
| 103 | + base_dn = "ou=users,dc=example,dc=com" |
| 104 | + bind_dn = "cn=readonly,dc=example,dc=com" |
| 105 | + bind_password = var.ldap_password |
| 106 | + mode = "ldaps" |
| 107 | + verify = true |
| 108 | + ca_path = "/etc/pve/priv/ca.crt" |
| 109 | +} |
| 110 | +``` |
| 111 | + |
| 112 | +#### With Group Synchronization |
| 113 | +```hcl |
| 114 | +resource "proxmox_realm_ldap" "with_groups" { |
| 115 | + realm = "corporate-ldap" |
| 116 | + server1 = "ldap.corp.example.com" |
| 117 | + base_dn = "ou=users,dc=corp,dc=example,dc=com" |
| 118 | + bind_dn = "cn=svc_ldap,ou=services,dc=corp,dc=example,dc=com" |
| 119 | + bind_password = var.ldap_password |
| 120 | + mode = "ldap+starttls" |
| 121 | + |
| 122 | + # Group settings |
| 123 | + group_dn = "ou=groups,dc=corp,dc=example,dc=com" |
| 124 | + group_filter = "(objectClass=groupOfNames)" |
| 125 | + group_name_attr = "cn" |
| 126 | + |
| 127 | + # Sync configuration |
| 128 | + sync_attributes = "email=mail,firstname=givenName,lastname=sn" |
| 129 | + sync_defaults_options = "scope=both,enable-new=1" |
| 130 | +} |
| 131 | +``` |
| 132 | + |
| 133 | +## See Also |
| 134 | + |
| 135 | +- [Proxmox VE User Management](https://pve.proxmox.com/wiki/User_Management) |
| 136 | +- [Proxmox VE LDAP Authentication](https://pve.proxmox.com/wiki/User_Management#pveum_ldap) |
| 137 | +- [Proxmox API: /access/domains](https://pve.proxmox.com/pve-docs/api-viewer/index.html#/access/domains) |
| 138 | + |
0 commit comments