diff -Nur -x '*.orig' -x '*.rej' smeserver-kronolith-2.2/root/etc/e-smith/events/actions/ldap-delete-fburl mezzanine_patched_smeserver-kronolith-2.2/root/etc/e-smith/events/actions/ldap-delete-fburl --- smeserver-kronolith-2.2/root/etc/e-smith/events/actions/ldap-delete-fburl 1969-12-31 18:00:00.000000000 -0600 +++ mezzanine_patched_smeserver-kronolith-2.2/root/etc/e-smith/events/actions/ldap-delete-fburl 2010-05-12 21:14:01.000000000 -0500 @@ -0,0 +1,114 @@ +#!/usr/bin/perl -w + +#---------------------------------------------------------------------- +# copyright (C) 1999, 2000 e-smith, inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Technical support for this program is available from e-smith, inc. +# For details, please visit our web site at www.e-smith.com or +# call us on 1 888 ESMITH 1 (US/Canada toll free) or +1 613 564 8000 +#---------------------------------------------------------------------- + +package esmith; + +use strict; +use Errno; +use esmith::ConfigDB; +use esmith::AccountsDB; +use esmith::util; +use Net::LDAP; + +my $c = esmith::ConfigDB->open_ro; +my $a = esmith::AccountsDB->open_ro; + +my $l = $c->get('ldap'); +my $status = $l->prop('status') || "disabled"; +unless ($status eq "enabled" ) +{ + warn "Not running action script $0, LDAP service not enabled!\n"; + exit(0); +} + +my $hostname = $c->get('SystemName') + || die("Couldn't determine system name"); + $hostname = $hostname->value; + +my $domain = $c->get('DomainName') + || die("Couldn't determine domain name"); + $domain = $domain->value; + +my @accounts; +my $account; +my $event = shift || die "Event name must be specified"; +if ($event eq 'ldap-update') +{ + @accounts = ($a->users); +} +else +{ + my $userName = shift; + die "Username argument missing." unless defined ($userName); + + $account = $a->get($userName); + die "Account $userName not found.\n" unless defined $account; + my $type = $account->prop('type') || "unknown"; + + die "Account $userName is not a user or group account; " . + "update LDAP entry failed.\n" + unless ($type eq 'user'); + @accounts = ($account); +} + +#------------------------------------------------------------ +# Update LDAP directory entry. First read LDAP password +#------------------------------------------------------------ +my $pw = esmith::util::LdapPassword(); + +#------------------------------------------------------------ +# Update LDAP database entry. +#------------------------------------------------------------ +my $base = esmith::util::ldapBase ($domain); + +my $ldap = Net::LDAP->new('localhost') + or die "$@"; + +$ldap->bind( + dn => "cn=root,$base", + password => $pw +); + +foreach my $acct (@accounts) +{ + my $key = $acct->key; + my $type = $acct->prop('type'); + next unless ($type eq 'user'); + my @attrs = (); + + + my $dn = "uid=$key,ou=Users,$base"; + my %attrs = @attrs; + + $ldap->modify ($dn, delete => ['calFBURL']); + my $result = $ldap->modify ($dn, delete => \%attrs); + + $result->code && + warn "failed to delete entry for $dn: ", $result->error ; + +} +$ldap->unbind; + +exit (0); +