Skip to content

Instantly share code, notes, and snippets.

@superseb
Created November 14, 2018 10:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save superseb/2a60e9c287f46abf54416239e5fc51d8 to your computer and use it in GitHub Desktop.
Save superseb/2a60e9c287f46abf54416239e5fc51d8 to your computer and use it in GitHub Desktop.
rancher2-ldap.sh
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment