-
Notifications
You must be signed in to change notification settings - Fork 27
/
bug158342-nl.pl
95 lines (82 loc) · 2.5 KB
/
bug158342-nl.pl
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
use NDSAdminNL qw(my_ldap_url_parse createInstance check_mesg createAndSetupReplica);
my $sroot = $ENV{SERVER_ROOT};
my $host1 = "localhost.localdomain";
my $host2 = $host1;
my $cfgport = 7100;
my ($m1, $m2, $h1, $h2, $c1, $c2);
#$ENV{USE_DBX} = 1;
$m1 = createInstance({
cfgdshost => $host1,
cfgdsport => $cfgport,
cfgdsuser => 'admin',
cfgdspwd => 'admin',
newrootpw => 'password',
newhost => $host1,
newport => $cfgport+10,
newinst => 'm1',
newsuffix => 'dc=example,dc=com',
verbose => 1
});
$h1 = createInstance({
cfgdshost => $host1,
cfgdsport => $cfgport,
cfgdsuser => 'admin',
cfgdspwd => 'admin',
newrootpw => 'password',
newhost => $host1,
newport => $cfgport+20,
newinst => 'h1',
newsuffix => 'dc=example,dc=com',
verbose => 1
});
delete $ENV{USE_DBX};
#$ENV{USE_DBX} = 1;
$h2 = createInstance({
cfgdshost => $host1,
cfgdsport => $cfgport,
cfgdsuser => 'admin',
cfgdspwd => 'admin',
newrootpw => 'password',
newhost => $host2,
newport => $cfgport+30,
newinst => 'h2',
newsuffix => 'dc=example,dc=com',
verbose => 1
});
delete $ENV{USE_DBX};
my $suffix = "o=my_suffix.com";
print "Create suffixes on the mux\n";
createOrgEntry($h1, $suffix);
createOrgEntry($h2, $suffix);
print "Set up chaining . . .\n";
$m1->setupChaining($h1, $suffix);
$m1->setupChaining($h2, $suffix);
print "Add the acis on the farms . . .\n";
my $binddn = "cn=chaining user,cn=config";
my $aci1 = "(targetattr = \"*\") (version 3.0;acl \"bind_user\";allow (all)(userdn = \"ldap:///$binddn\");)";
my $aci2 = "(targetattr = \"*\") (version 3.0;acl \"All\";allow (all)(userdn = \"ldap:///*,$suffix\");)";
my $mesg = $h1->modify($suffix, add => {aci => [ $aci1, $aci2 ]});
check_mesg($mesg, "Could not add acis to h1");
$mesg = $h2->modify($suffix, add => {aci => [ $aci1, $aci2 ]});
check_mesg($mesg, "Could not add acis to h2");
print "Try a search\n";
$mesg = $m1->search(base => $suffix,
scope => 'base',
filter => '(objectclass=*)');
check_mesg($mesg, "Could not search for $suffix");
my $ent = $mesg->shift_entry;
$ent->dump;
# creates the backend, suffix, and entry for o= style suffixes
sub createOrgEntry {
my ($conn, $suffix) = @_;
my $rc = $conn->addSuffix($suffix);
if ($rc) {
print "Couldn't add chaining suffix $suffix: $rc: " . $conn->getErrorString(), "\n";
} else {
my $entry = new Net::LDAP::Entry();
$entry->dn($suffix);
$entry->add('objectclass' => ['top', 'organization']);
my $mesg = $conn->add($entry);
check_mesg($mesg, "Error adding new suffix entry $suffix");
}
}