File: ldap.sh

package info (click to toggle)
usbguard 1.1.2%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,528 kB
  • sloc: cpp: 18,119; sh: 1,836; makefile: 642; ansic: 122; xml: 76; perl: 39
file content (39 lines) | stat: -rwxr-xr-x 652 bytes parent folder | download
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
33
34
35
36
37
38
39
#!/bin/bash

set -e

BASE="dc=example,dc=com"
USER="cn=Manager,$BASE"

HOST="192.168.122.83"
PASS="passme"

ping -q -c 1 $HOST 2>&1 >/dev/null

if [ "$1" = "delete" ]; then
  ldapdelete -h $HOST -D $USER -w $PASS -r $BASE
  exit
fi

if [ "$1" = "setup" ]; then
  ldapadd -v -h $HOST -D $USER -w $PASS -f ./setup.ldif
  exit
fi

if [ "$1" = "policy" ]; then
  POLICY='./usbguard-policy.ldif'
  if [ "$2" ]; then
    POLICY=$2
  fi
  ldapadd -v -h $HOST -D $USER -w $PASS -f $POLICY
  exit
fi

if [ "$1" = "search" ]; then
  FILTER='objectclass=*'
  if [ "$2" ]; then
    FILTER=$2
  fi
  ldapsearch -h $HOST -D $USER -b $BASE -w $PASS $FILTER
  exit
fi