|
@@ -0,0 +1,35 @@
|
|
|
+#!/bin/bash -e
|
|
|
+
|
|
|
+USER="$1"
|
|
|
+
|
|
|
+if [ "$USER" = "" ]; then
|
|
|
+ echo "syntax: $0 login" >&2
|
|
|
+ exit 1
|
|
|
+fi
|
|
|
+
|
|
|
+USER="${USER//[\/]/}"
|
|
|
+
|
|
|
+TMPDIR="$(mktemp -d)"
|
|
|
+
|
|
|
+if [ "$TMPDIR" = "" ]; then
|
|
|
+ echo "error: cannot create temporary directory" >&2
|
|
|
+ exit 2
|
|
|
+fi
|
|
|
+
|
|
|
+LDAP_LOGINPASS=($(awk -F '"' '{if ($1 == "masterDN=") {LOGIN=$2} if ($1 == "masterPw=") {PASS=$2}} END {print LOGIN"\t"PASS}' < /etc/smbldap-tools/smbldap_bind.conf))
|
|
|
+LDAP_LOGIN="${LDAP_LOGINPASS[0]}"
|
|
|
+LDAP_PASS="${LDAP_LOGINPASS[1]}"
|
|
|
+
|
|
|
+
|
|
|
+if [ "$LDAP_LOGIN" = "" -o "$LDAP_PASS" = "" ]; then
|
|
|
+ echo "error: cannot parse ldap login/pass from /etc/smbldap-tools/smbldap_bind.conf" >&2
|
|
|
+ exit 3
|
|
|
+fi
|
|
|
+
|
|
|
+echo "uid=$USER,ou=users,dc=mephi,dc=ru" > "$TMPDIR"/todelete.dnlist
|
|
|
+ldapdelete -x -D "$LDAP_LOGIN" -w "$LDAP_PASS" -f "$TMPDIR"/todelete.dnlist -h ldap.ut.mephi.ru
|
|
|
+
|
|
|
+rm -f "$TMPDIR"/{,.}* 2>/dev/null
|
|
|
+rmdir "$TMPDIR"
|
|
|
+
|
|
|
+exit 0
|