Automatic configuration of LDAP credentials

I have successfully gotten LDAP authentication to work in GSA 8.0.1. First I configured the LDAP server, then I added a couple of users who were configured with “LDAP Authentication Only”.

Now I would like to automate this, but I’m unclear how. The recommended way of scripting GVM in general seems to be python-gvm. There are plenty of examples floating around on how to add users, but there’s no CredentialType for LDAP authentication.

As for initially configuring LDAP, I have no clue. There’s definitely nothing in python-gvm. I’d gladly use gvm-cli as a fallback, but I can’t find any hints on how to properly compose an XML command to configure LDAP.

My escape hatch is simply replaying the POST requests the GSA UI makes as curl commands, but that seems like a cop-out.

Pointers are greatly appreciated!



Figured it out by reverse-engineering GSAD.

Configuring the LDAP connection using gvm-cli:


gvm-cli tls --hostname --xml "<commands> \
<modify_auth><group name=\"method:ldap_connect\"> \
    <auth_conf_setting><key>enable</key><value>true</value></auth_conf_setting> \
    <auth_conf_setting><key>ldaphost</key><value></value></auth_conf_setting> \
    <auth_conf_setting><key>authdn</key><value>uid=%s,o=org,dc=div</value></auth_conf_setting> \
    <auth_conf_setting><key>cacert</key><value>$(</path/to/ldap/cert)</value></auth_conf_setting> \
</group></modify_auth> \

Hope this helps anyone.


modify_auth is also supported by python-gvm