osixia / docker-phpLDAPadmin

phpLDAPadmin container image 🐳🌴
MIT License
844 stars 197 forks source link

Doc: Mention possibility of \" for inline PHPLDAPADMIN_LDAP_HOSTS #28

Open j-maas opened 7 years ago

j-maas commented 7 years ago

The docs (main README) could mention how to customize the phpLDAPAdmin-Config using arrays.

Current state

The YAML-example uses an array for force_may:

- ldap.example.org:
  - server:
    - tls: true
    - port: 636
    - force_may: array('uidNumber','gidNumber','sambaSID')
  - login:
    - bind_id: cn=admin,dc=example,dc=org
    - bind_pass: p0p!
  - auto_number:
    - min: 1000
- ldap2.example.org
- ldap3.example.org

However the inline example does not use any array:

docker run --env PHPLDAPADMIN_LDAP_HOSTS="#PYTHON2BASH:[{'ldap.example.org': [{'server': [{'tls': True}]},{'login': [{'bind_id': 'cn=admin,dc=example,dc=org'}]}]}, 'ldap2.example.org', 'ldap3.example.org']" --detach osixia/phpldapadmin:0.6.12

Proposed solution

For example, the complete YAML-example could be translated into inline. (This might be too verbose, though). The need for escaping might be spelled out explicitely.

docker run --env PHPLDAPADMIN_LDAP_HOSTS="#PYTHON2BASH:[{'ldap.example.org': [{'server': [{'tls': True}, {'port': 636}, {'force_may': \"array('uidNumber','gidNumber','sambaSID')\"}]}, {'login': [{'bind_id': 'cn=admin,dc=example,dc=org'}, {'bind_pass': 'p0p!'}]}, {'auto_number': [{'min': 1000}]}]}, 'ldap2.example.org', 'ldap3.example.org']" --detach osixia/phpldapadmin:0.6.12

Motivation

I spent a few hours trying to define multiple base DNs for my server to be able to access the cn=config. I finally realized that it is possible to escape the inner " that are put around the array.

If there is an alternative way of customizing the phpLDAPAdmin-Config, then maybe it could be clarified. The docs suggest there is, but I do not understand what it is (apart from maybe mounting a volume to image/environment/default.yaml thus overriding the default.yml?).

agrrh commented 5 years ago

Faced same problem with auto_number, would be excellent to add some docs about using array() with env vars configuration.

Archweii commented 5 years ago

The documentation seems wrong, I tried setting PHPLDAPADMIN_LDAP_HOSTS with your Python code and it worked, it overrides the default config with my server's config!

ChrisSamo632 commented 5 years ago

Possibly worth adding some documentation/comments about setting this in a docker-compose.yml as a multiline string (I found this much easier to read and ultimately helped me find what was wrong with the syntax in my entries), e.g.

version: '3.7'

services:
  phpldapadmin:
    image: osixia/phpldapadmin:0.7.2
    environment:
      PHPLDAPADMIN_LDAP_HOSTS: "#PYTHON2BASH:[
{'ldap.example.com':[
  {'server': [
    {'tls': True},
    {'port': 389},
    {'force_may': \"array('uidNumber','gidNumber','sambaSID')\"},
    {'base': \"array('dc=example,dc=com')\"}
   ]
  },
  {'login': [
    {'bind_id': 'cn=admin,dc=example,dc=com'},
    {'bind_pass': '${LDAP_ADMIN_PASSWORD:-default_password}'}
   ]
  },
  {'auto_number': [
    {'min': \"array('uidNumber'=>1000,'gidNumber'=>1000)\"}
   ]
  }
 ]
}
]"
...

(N.B. I didn't specify force_may, base, login or auto_number entries in the end to get my initial START_TLS connections working to the osixia/openldap service also running on my Swarm, but thought I'd include them here as working out the syntax to get them working with PYTHON2BASH was tricky and time consuming).