1 |
--- e-smith-ldap-5.2.0/root/etc/e-smith/events/actions/ldap-delete.users_groups_ous 2005-07-27 23:26:55.000000000 +0200 |
2 |
+++ e-smith-ldap-5.2.0/root/etc/e-smith/events/actions/ldap-delete 2010-01-30 21:28:26.000000000 +0100 |
3 |
@@ -36,9 +36,9 @@ |
4 |
} |
5 |
|
6 |
my $event = $ARGV [0]; |
7 |
-my $userName = $ARGV [1]; |
8 |
+my $name = $ARGV [1]; |
9 |
|
10 |
-die "Username argument missing." unless defined ($userName); |
11 |
+die "Username argument missing." unless defined ($name); |
12 |
|
13 |
#------------------------------------------------------------ |
14 |
# Delete user from LDAP directory. First read LDAP password |
15 |
@@ -57,17 +57,30 @@ |
16 |
password => $pw |
17 |
); |
18 |
|
19 |
-my @search_args = ( base => $base, filter => "uid=$userName" ); |
20 |
+my @search_args = ( base => "ou=Users,$base", filter => "uid=$name" ); |
21 |
my $mesg = $ldap->search(@search_args); |
22 |
|
23 |
$mesg->code && die "Failed ldap search: ", $mesg->error; |
24 |
|
25 |
if ($mesg->count > 1) |
26 |
{ |
27 |
- die("LDAP search for $userName returned $mesg->count - 1 expected\n"); |
28 |
+ die("LDAP search for $name returned $mesg->count - 1 expected\n"); |
29 |
} |
30 |
|
31 |
$ldap->delete($mesg->entry(0)); |
32 |
+ |
33 |
+if ($event eq 'group-delete'){ |
34 |
+ @search_args = ( base => "ou=Groups,$base", filter => "cn=$name" ); |
35 |
+ $mesg = $ldap->search(@search_args); |
36 |
+ $mesg->code && die "Failed ldap search: ", $mesg->error; |
37 |
+ if ($mesg->count > 1) |
38 |
+ { |
39 |
+ die("LDAP search for $name returned $mesg->count - 1 expected\n"); |
40 |
+ } |
41 |
+ |
42 |
+ $ldap->delete($mesg->entry(0)); |
43 |
+} |
44 |
+ |
45 |
$ldap->unbind; |
46 |
|
47 |
exit (0); |
48 |
--- e-smith-ldap-5.2.0/root/etc/e-smith/events/actions/ldap-update.users_groups_ous 2010-01-30 21:32:54.000000000 +0100 |
49 |
+++ e-smith-ldap-5.2.0/root/etc/e-smith/events/actions/ldap-update 2010-01-30 21:28:08.000000000 +0100 |
50 |
@@ -106,6 +106,7 @@ |
51 |
my $type = $acct->prop('type'); |
52 |
next unless ($type eq 'user' || $type eq 'group'); |
53 |
my @attrs = (); |
54 |
+ my @groupAttrs = (); |
55 |
if (($type eq 'user') || ($key eq 'admin')) |
56 |
{ |
57 |
my $name = $acct->prop('FirstName') . " " . $acct->prop('LastName'); |
58 |
@@ -147,6 +148,9 @@ |
59 |
|
60 |
my $key = $acct->key; |
61 |
my $desc = $acct->prop('Description') || ''; |
62 |
+ my @members = split(/,/,($acct->prop('Members') || '')); |
63 |
+ my $gid = $acct->prop('Gid'); |
64 |
+ |
65 |
utf8::upgrade($desc); |
66 |
push @attrs, (cn => $desc) unless $desc =~ /^\s*$/; |
67 |
push @attrs, (mail => "$key\@$domain"); |
68 |
@@ -155,22 +159,40 @@ |
69 |
push @attrs, (ou => $dept) unless $dept =~ /^\s*$/; |
70 |
push @attrs, (l => $city) unless $city =~ /^\s*$/; |
71 |
push @attrs, (street => $street) unless $street =~ /^\s*$/; |
72 |
+ |
73 |
+ push @groupAttrs, (objectClass => 'posixGroup'); |
74 |
+ push @groupAttrs, (cn => $key); |
75 |
+ push @groupAttrs, (gidNumber => $gid); |
76 |
+ push @groupAttrs, (description => $desc) unless $desc =~ /^\s*$/; |
77 |
+ push @groupAttrs, (memberUid => \@members); |
78 |
} |
79 |
- my $dn = "uid=$key,$base"; |
80 |
+ my $dn = "uid=$key,ou=Users,$base"; |
81 |
+ my $groupDn = "cn=$key,ou=Groups,$base"; |
82 |
if (($event eq 'user-create') || ($event eq 'group-create')) |
83 |
{ |
84 |
my $result = $ldap->add ($dn, attr => \@attrs); |
85 |
|
86 |
$result->code && |
87 |
warn "failed to add entry for $dn: ", $result->error ; |
88 |
+ |
89 |
+ $result = $ldap->add ($groupDn, attr => \@groupAttrs); |
90 |
+ |
91 |
+ $result->code && |
92 |
+ warn "failed to add entry for $groupDn: ", $result->error ; |
93 |
} |
94 |
else |
95 |
{ |
96 |
my %attrs = @attrs; |
97 |
+ my %groupAttrs = @groupAttrs; |
98 |
my $result = $ldap->modify ($dn, replace => \%attrs); |
99 |
|
100 |
$result->code && |
101 |
warn "failed to modify entry for $dn: ", $result->error ; |
102 |
+ |
103 |
+ $result = $ldap->modify ($groupDn, replace => \%groupAttrs); |
104 |
+ |
105 |
+ $result->code && |
106 |
+ warn "failed to modify entry for $groupDn: ", $result->error ; |
107 |
} |
108 |
} |
109 |
$ldap->unbind; |
110 |
--- e-smith-ldap-5.2.0/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50users.users_groups_ous 2010-01-30 21:32:54.000000000 +0100 |
111 |
+++ e-smith-ldap-5.2.0/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50users 2010-01-30 21:25:43.000000000 +0100 |
112 |
@@ -15,7 +15,7 @@ |
113 |
my $password = $passwd{$key}; |
114 |
|
115 |
$OUT .= "\n"; |
116 |
- $OUT .= utf8("dn: uid=$key,$ldapBase\n"); |
117 |
+ $OUT .= utf8("dn: uid=$key,ou=Users,$ldapBase\n"); |
118 |
$OUT .= utf8("objectClass: inetOrgPerson\n"); |
119 |
$OUT .= utf8("uid: $key\n"); |
120 |
$OUT .= utf8("cn: $name\n") if $name; |
121 |
--- e-smith-ldap-5.2.0/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/10organisation.users_groups_ous 2010-01-30 21:32:54.000000000 +0100 |
122 |
+++ e-smith-ldap-5.2.0/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/10organisation 2010-01-30 21:24:27.000000000 +0100 |
123 |
@@ -4,7 +4,19 @@ |
124 |
|
125 |
$OUT .= "dn: $ldapBase\n"; |
126 |
$OUT .= "objectClass: organization\n"; |
127 |
+ $OUT .= "objectClass: top\n"; |
128 |
$OUT .= "dc: $dc\n"; |
129 |
$OUT .= "o: $o\n"; |
130 |
$OUT .= "objectClass: dcObject\n"; |
131 |
+ |
132 |
+ $OUT .= "\n"; |
133 |
+ $OUT .= "dn: ou=Users,$ldapBase\n"; |
134 |
+ $OUT .= "objectClass: top\n"; |
135 |
+ $OUT .= "objectClass: organizationalUnit\n"; |
136 |
+ $OUT .= "ou: Users\n\n"; |
137 |
+ $OUT .= "dn: ou=Groups,$ldapBase\n"; |
138 |
+ $OUT .= "objectClass: top\n"; |
139 |
+ $OUT .= "objectClass: organizationalUnit\n"; |
140 |
+ $OUT .= "ou: Groups\n\n"; |
141 |
} |
142 |
+ |
143 |
--- e-smith-ldap-5.2.0/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50groups.users_groups_ous 2010-01-30 21:32:54.000000000 +0100 |
144 |
+++ e-smith-ldap-5.2.0/root/etc/e-smith/templates/home/e-smith/db/ldap/ldif/50groups 2010-01-30 21:25:57.000000000 +0100 |
145 |
@@ -1,15 +1,28 @@ |
146 |
{ |
147 |
foreach ($a->groups) |
148 |
- { |
149 |
- my $key = $_->key; |
150 |
- my $desc = $_->prop('Description'); |
151 |
+ { |
152 |
+ my $key = $_->key; |
153 |
+ my $desc = $_->prop('Description') || ''; |
154 |
+ my $gid = $_->prop('Gid'); |
155 |
+ my @members = split( /,/, ($_->prop('Members') || '') ); |
156 |
|
157 |
- $OUT .= "\n"; |
158 |
- $OUT .= "dn: uid=$key,$ldapBase\n"; |
159 |
- $OUT .= "objectClass: inetOrgPerson\n"; |
160 |
- $OUT .= "mail: $key\@$DomainName\n"; |
161 |
- $OUT .= utf8("cn: $desc\n") if $desc; |
162 |
- $OUT .= "uid: $key\n"; |
163 |
- $OUT .= "sn: $key\n"; |
164 |
+ $OUT .= "\n"; |
165 |
+ $OUT .= "dn: uid=$key,ou=Users,$ldapBase\n"; |
166 |
+ $OUT .= "objectClass: inetOrgPerson\n"; |
167 |
+ $OUT .= "mail: $key\@$DomainName\n"; |
168 |
+ $OUT .= utf8("cn: $desc\n") if $desc; |
169 |
+ $OUT .= "uid: $key\n"; |
170 |
+ $OUT .= "sn: $key\n"; |
171 |
+ |
172 |
+ $OUT .= "\n"; |
173 |
+ $OUT .= "dn: cn=$key,ou=Groups,$ldapBase\n"; |
174 |
+ $OUT .= "objectClass: posixGroup\n"; |
175 |
+ $OUT .= "gidNumber: $gid\n"; |
176 |
+ $OUT .= "cn: $key\n"; |
177 |
+ $OUT .= "description: $desc"; |
178 |
+ foreach my $member (@members){ |
179 |
+ $OUT .= "memberUid: $member\n"; |
180 |
+ } |
181 |
} |
182 |
} |
183 |
+ |
184 |
|