Skip to content

Commit f7c533f

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 f7c533f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
config="$1"
4+
5+
if ! [ -e "$config" ]; then
6+
echo "Please give the famedly-sync configuration file as the first argument"
7+
exit 1
8+
fi
9+
10+
grep_from_yaml() {
11+
grep "$1" "$config" | cut -f 2 -d ':' | tr -d '" '
12+
}
13+
14+
base_dn="$(grep_from_yaml base_dn)"
15+
bind_dn="$(grep_from_yaml bind_dn)"
16+
user_filter="$(grep_from_yaml user_filter)"
17+
start_tls=""
18+
if [ "$(grep_from_yaml danger_use_start_tls)" = "true" ]; then
19+
start_tls="-Z "
20+
fi
21+
if [ "$(grep_from_yaml use_attribute_filter)" = "true" ]; then
22+
echo "This command will not include the attribute filter"
23+
echo "To reproduce the search exactly, add every attribute name space-separated to the end of the command"
24+
fi
25+
26+
echo "Please read the password from the config file yourself :)"
27+
echo "ldapsearch $start_tls-W -b '$base_dn' -D '$bind_dn' '$user_filter'"

0 commit comments

Comments
 (0)