#!/bin/bash export RANCHER_DOMAIN="rancher.yourdomain.com" export RANCHER_TOKEN="token-xxxxx:xxxx" export ACCESS_MODE="unrestricted" export CONNECTION_TIMEOUT="5000" export LDAP_HOST="ldap.yourdomain.com" export LDAP_PORT="636" export TLS="true" export SA_DN="uid=x,ou=x,o=x,dc=yourdomain,dc=com" export SA_PW="sa_password" export USER_SEARCHBASE="ou=x,o=x,dc=yourdomain,dc=com" export USERNAME="username" export PASSWORD="password"
curl -u $RANCHER_TOKEN "https://${RANCHER_DOMAIN}/v3/openLdapConfigs/openldap?action=testAndApply" \ -H 'content-type: application/json' \ -H 'accept: application/json' \ --data-binary '{"ldapConfig":{"accessMode":"'"${ACCESS_MODE}"'","baseType":"authConfig","connectionTimeout":"'"${CONNECTION_TIMEOUT}"'","enabled":true,"groupDNAttribute":"entryDN","groupMemberMappingAttribute":"member","groupMemberUserAttribute":"entryDN","groupNameAttribute":"cn","groupObjectClass":"groupOfNames","groupSearchAttribute":"cn","id":"openldap","labels":{"cattle.io/creator":"norman"},"name":"openldap","nestedGroupMembershipEnabled":false,"port":"'"${LDAP_PORT}"'","servers":["'"${LDAP_HOST}"'"],"serviceAccountDistinguishedName":"'"${SA_DN}"'","tls":"'"${TLS}"'","type":"openLdapConfig","userDisabledBitMask":0,"userLoginAttribute":"uid","userMemberAttribute":"memberOf","userNameAttribute":"cn","userObjectClass":"inetOrgPerson","userSearchAttribute":"uid|sn|givenName","userSearchBase":"'"${USER_SEARCHBASE}"'","serviceAccountPassword":"'"${SA_PW}"'","groupSearchBase":null},"enabled":true,"username":"'"${USERNAME}"'","password":"'"${PASSWORD}"'"}' --compressed --insecure
|