/[smeserver]/rpms/e-smith-ldap/sme8/e-smith-ldap-5.2.0-users_groups_ous.patch3
ViewVC logotype

Contents of /rpms/e-smith-ldap/sme8/e-smith-ldap-5.2.0-users_groups_ous.patch3

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Wed Feb 3 09:54:11 2010 UTC (14 years, 4 months ago) by dungog
Branch: MAIN
CVS Tags: e-smith-ldap-5_2_0-14_el5_sme
* Sun Jan 31 2010 Stephen Noble <support@dungog.net> 5.2.0-13.sme
- Fix Groups entries [SME: 5743]

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

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed