Skip to content

Commit 1756b96

Browse files
feat(contrib): Add a helper script for ldapsearch debugging
We've needed to figure out what famedly-sync is seeing a few times while debugging in customer environments now; this is a quick solution that helps get this more easily. Short of a full command to do various searches in famedly-sync (which would basically just reimplement `ldapsearch`) I think this is a pretty good way to patch up that use case a bit.
1 parent c3493c3 commit 1756b96

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/sh
2+
#
3+
# A small script to convert famedly-sync configuration into its
4+
# equivalent `ldapsearch` command; this can help find out what
5+
# `famedly-sync` sees in practice when performing a sync.
6+
#
7+
# Usage:
8+
#
9+
# ./extract-ldapsearch-command.sh CONFIG
10+
11+
config="$1"
12+
13+
if ! [ -e "$config" ]; then
14+
echo "Please give the famedly-sync configuration file as the first argument"
15+
exit 1
16+
fi
17+
18+
grep_from_yaml() {
19+
grep "$1" "$config" | cut -f 2 -d ':' | tr -d '" '
20+
}
21+
22+
base_dn="$(grep_from_yaml base_dn)"
23+
bind_dn="$(grep_from_yaml bind_dn)"
24+
user_filter="$(grep_from_yaml user_filter)"
25+
start_tls=""
26+
if [ "$(grep_from_yaml danger_use_start_tls)" = "true" ]; then
27+
start_tls="-Z "
28+
fi
29+
if [ "$(grep_from_yaml use_attribute_filter)" = "true" ]; then
30+
echo "This command will not include the attribute filter"
31+
echo "To reproduce the search exactly, add every attribute name space-separated to the end of the command"
32+
echo
33+
fi
34+
35+
echo "Please read the password from the config file yourself :)"
36+
echo "ldapsearch $start_tls-W -b '$base_dn' -D '$bind_dn' '$user_filter'"

0 commit comments

Comments
 (0)