-
Notifications
You must be signed in to change notification settings - Fork 31
/
42search.t
40 lines (24 loc) · 936 Bytes
/
42search.t
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
#!perl
use Test::More;
BEGIN { require "t/common.pl" }
start_server()
? plan tests => 15
: plan skip_all => 'no server';
$ldap = client();
ok($ldap, "client");
$mesg = $ldap->bind($MANAGERDN, password => $PASSWD);
ok(!$mesg->code, "bind: " . $mesg->code . ": " . $mesg->error);
ok(ldif_populate($ldap, "data/41-in.ldif"), "data/41-in.ldif");
# now search the database
# Exact searching
$mesg = $ldap->search(base => $BASEDN, filter => 'sn=jensen');
compare_ldif("41a",$mesg,$mesg->sorted);
# Or searching
$mesg = $ldap->search(base => $BASEDN, filter => '(|(objectclass=groupofnames)(sn=jones))');
compare_ldif("41b",$mesg,$mesg->sorted);
# And searching
$mesg = $ldap->search(base => $BASEDN, filter => '(&(objectclass=groupofnames)(cn=A*))');
compare_ldif("41c",$mesg,$mesg->sorted);
# Not searching
$mesg = $ldap->search(base => $BASEDN, filter => '(!(objectclass=person))');
compare_ldif("41d",$mesg,$mesg->sorted);