forked from ConsortiumGARR/idem-tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdomain2dn.sh
More file actions
32 lines (25 loc) · 717 Bytes
/
domain2dn.sh
File metadata and controls
32 lines (25 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
################################################
# #
# Bash Script useful to convert #
# a domain name into a LDAP distinguished name #
# #
################################################
#!/usr/bin/env bash
LDAP_DC_ARRAY=()
LDAP_DC=""
echo "Enter your domain name (e.g.: example.org):"
read DOMAIN
DCS=$(echo $DOMAIN | tr "." "\n")
for dc in $DCS
do
LDAP_DC_ARRAY+=("dc=$dc")
done
# Iterate the loop to read and print each array element
for value in "${LDAP_DC_ARRAY[@]}"
do
LDAP_DC+="$value"
if [[ "$value" != ${LDAP_DC_ARRAY[-1]} ]]; then
LDAP_DC+=","
fi
done
echo $LDAP_DC