-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnew-user-ldap.sh
24 lines (19 loc) · 1.28 KB
/
new-user-ldap.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash
# New users insert in LDAP
LDAPIP=172.168.1.1
# Checking current number of records in LDAP
echo "Checking current number of records in LDAP"
ldapsearch -x -H ldap://$LDAPIP -D "cn=admin,dc=cloudcafe,dc=org" -b "dc=cloudcafe,dc=org" -w "StrongAdminPassw0rd" | grep num
# Download LDAP new user ldif file & insert in LDAP
echo "Adding new user in LDAP .."
wget -q https://raw.githubusercontent.com/cloudcafetech/k8s-ad-integration/main/new-add-user.ldif
wget -q https://raw.githubusercontent.com/cloudcafetech/k8s-ad-integration/main/add-user-in-grp.ldif
ldapadd -x -H ldap://$LDAPIP -D "cn=admin,dc=cloudcafe,dc=org" -w StrongAdminPassw0rd -f new-add-user.ldif
ldapadd -x -H ldap://$LDAPIP -D "cn=admin,dc=cloudcafe,dc=org" -w StrongAdminPassw0rd -f add-user-in-grp.ldif
# After adding number of records in LDAP
echo "After adding number of records in LDAP"
ldapsearch -x -H ldap://$LDAPIP -D "cn=admin,dc=cloudcafe,dc=org" -b "dc=cloudcafe,dc=org" -w "StrongAdminPassw0rd" | grep num
# Create the role binding for new users
echo "Creating roles for new user in K8s .."
kubectl create rolebinding titli-view-default --clusterrole=view [email protected] -n default
kubectl create rolebinding rajat-admin-default --clusterrole=admin [email protected] -n default