diff --git a/docs/upgrades/upgrade_6.8.7-6.99.0.pl b/docs/upgrades/upgrade_6.8.7-6.99.0.pl index 2f5ada97d..6d7f92ee0 100644 --- a/docs/upgrades/upgrade_6.8.7-6.99.0.pl +++ b/docs/upgrades/upgrade_6.8.7-6.99.0.pl @@ -133,7 +133,7 @@ sub addWorkflow { "WebGUI::Workflow::Activity::ExpireGroupings", "WebGUI::Workflow::Activity::PurgeOldAssetRevisions", "WebGUI::Workflow::Activity::ExpireSubscriptionCodes", "WebGUI::Workflow::Activity::PurgeOldTrash", "WebGUI::Workflow::Activity::GetSyndicatedContent", "WebGUI::Workflow::Activity::ProcessRecurringPayments", - "WebGUI::Workflow::Activity::SummarizePassiveProfileLog"], + "WebGUI::Workflow::Activity::SyncProfilesToLdap", "WebGUI::Workflow::Activity::SummarizePassiveProfileLog"], "WebGUI::User"=>["WebGUI::Workflow::Activity::CreateCronJob"], "WebGUI::VersionTag"=>["WebGUI::Workflow::Activity::CommitVersionTag", "WebGUI::Workflow::Activity::RollbackVersionTag", "WebGUI::Workflow::Activity::TrashVersionTag", "WebGUI::Workflow::Activity::CreateCronJob"] @@ -163,6 +163,8 @@ sub addWorkflow { $activity->set("title", "Expire old subscription codes"); $activity = $workflow->addActivity("WebGUI::Workflow::Activity::SummarizePassiveProfileLog", "pbwfactivity0000000014"); $activity->set("title", "Summarize Passive Profiling Data"); + $activity = $workflow->addActivity("WebGUI::Workflow::Activity::SyncProfilesToLdap", "pbwfactivity0000000015"); + $activity->set("title", "Sync User Profiles With LDAP"); WebGUI::Workflow::Cron->create($session, { title=>'Daily Maintenance', enabled=>1, @@ -222,6 +224,7 @@ sub addWorkflow { }, "pbcron0000000000000003"); $session->db->write("alter table assetVersionTag add column isLocked int not null default 0"); $session->db->write("alter table assetVersionTag add column lockedBy varchar(22) binary not null"); + $session->config->delete("SyncProfilesToLDAP_hour"); $session->config->delete("fileCacheSizeLimit"); $session->config->delete("passiveProfileInterval"); $session->config->delete("CleanLoginHistory_ageToDelete"); @@ -522,9 +525,8 @@ sub removeFiles { unlink '../../lib/WebGUI/i18n/Asset_IndexedSearch.pm'; unlink '../../sbin/Hourly/IndexedSearch_buildIndex.pm'; rmtree('../../lib/WebGUI/Asset/Wobject/IndexedSearch'); - # uncomment this after they've all been converted - #rmtree('../../sbin/Hourly'); - #unlink('../../sbin/runHourly.pl'); + rmtree('../../sbin/Hourly'); + unlink('../../sbin/runHourly.pl'); } #------------------------------------------------- diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index 79a6ed3f8..544555a17 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -276,13 +276,6 @@ "u" : "u_companyUrl" }, -# What hour of the day (for example, 22 : 10 PM = 22:00:00) -# should WebGUI try to synchronize user profile information from -# the LDAP server. Note that this will only happen for users -# that have LDAP as their authentication. - -"SyncProfilesToLDAP_hour" : 2, - # Define the subnets that WebGUI should expect Spectre communication # to come from. All other subnets will be ignored. The subnet # should be listed in CIDR notation. diff --git a/sbin/Hourly/SyncProfilesToLDAP.pm b/lib/WebGUI/Workflow/Activity/SyncProfilesToLdap.pm similarity index 55% rename from sbin/Hourly/SyncProfilesToLDAP.pm rename to lib/WebGUI/Workflow/Activity/SyncProfilesToLdap.pm index b4e38dd80..5734231da 100644 --- a/sbin/Hourly/SyncProfilesToLDAP.pm +++ b/lib/WebGUI/Workflow/Activity/SyncProfilesToLdap.pm @@ -1,23 +1,67 @@ -package Hourly::SyncProfilesToLDAP; +package WebGUI::Workflow::Activity::SyncProfilesToLdap; -#------------------------------------------------------ ------------- -# WebGUI is Copyright 2001-2006 Plain Black Corporation. -#------------------------------------------------------ ------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------ ------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------ ------------- -use Net::LDAP; +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2006 Plain Black Corporation. + ------------------------------------------------------------------- + Please read the legal notices (docs/legal.txt) and the license + (docs/license.txt) that came with this distribution before using + this software. + ------------------------------------------------------------------- + http://www.plainblack.com info@plainblack.com + ------------------------------------------------------------------- + +=cut + use strict; -use WebGUI::DateTime; -use WebGUI::Session; -use WebGUI::SQL; +use base 'WebGUI::Workflow::Activity'; +use Net::LDAP; use WebGUI::Auth; use WebGUI::User; +=head1 NAME + +Package WebGUI::Workflow::Activity::SyncProfilesToLdap + +=head1 DESCRIPTION + +Synchoronizes the data in your LDAP directory with the WebGUI user's profile. This is a one way sync, so data comes from LDAP to WebGUI, not the other way around. + +=head1 SYNOPSIS + +See WebGUI::Workflow::Activity for details on how to use any activity. + +=head1 METHODS + +These methods are available from this class: + +=cut + + +#------------------------------------------------------------------- + +=head2 definition ( session, definition ) + +See WebGUI::Workflow::Activity::defintion() for details. + +=cut + +sub definition { + my $class = shift; + my $session = shift; + my $definition = shift; + my $i18n = WebGUI::International->new($session, "AuthLDAP"); + push(@{$definition}, { + name=>$i18n->get("sync profiles to ldap"), + properties=> { } + }); + return $class->SUPER::definition($session,$definition); +} + + + my %ldapStatusCode = ( 0=>'success (0)', 1=>'Operations Error (1)', 2=>'Protocol Error (2)', 3=>'Time Limit Exceeded (3)', 4=>'Size Limit Exceeded (4)', 5=>'Compare False (5)', 6=>'Compare True (6)', 7=>'Auth Method Not Supported (7)', 8=>'Strong Auth Required (8)', @@ -51,15 +95,20 @@ sub _alias { } #------------------------------------------------------------------- -sub process { - my (@date, $userId, $u, $userData, $uri, $port, %args, $fieldName, $ldap, $search, $a, $b); - @date = WebGUI::DateTime::localtime(WebGUI::DateTime::time()); -print $date[3]; - if ($date[3] == $session{config}{SyncProfilesToLDAP_hour}) { - $a = WebGUI::SQL->read("select userId from users where authMethod='LDAP'"); + +=head2 execute ( ) + +See WebGUI::Workflow::Activity::execute() for details. + +=cut + +sub execute { + my $self = shift; + my ($userId, $u, $userData, $uri, $port, %args, $fieldName, $ldap, $search, $a, $b); + $a = $self->session->db->read("select userId from users where authMethod='LDAP'"); while (($userId) = $a->array) { - $u = WebGUI::User->new($userId); - my $auth = WebGUI::Auth->new("LDAP",$userId); + $u = WebGUI::User->new($self->session, $userId); + my $auth = WebGUI::Auth->new($self->session, "LDAP",$userId); $userData = $auth->getParams; $uri = URI->new($userData->{ldapUrl}); if ($uri->port < 1) { @@ -74,12 +123,12 @@ print $date[3]; if ($result->code == 0) { $search = $ldap->search( base=>$userData->{connectDN}, filter=>"&(objectClass=*)" ); if($search->code) { - print "Couldn't search LDAP ".$uri->host." to find user ".$u->username." (".$userId.").\nError Message from LDAP: ".$ldapStatusCode{$search->code}."\n"; + $self->session->errorHandler->warn("Couldn't search LDAP ".$uri->host." to find user ".$u->username." (".$userId.").\nError Message from LDAP: ".$ldapStatusCode{$search->code}); } elsif($search->count == 0) { - print "No results returned for user with dn ".$userData->{connectDN}."\n"; + $self->session->errorHandler->warn("No results returned for user with dn ".$userData->{connectDN}); } else { - my $user = WebGUI::User->new($userId); - $b = WebGUI::SQL->read("select fieldName from userProfileField where profileCategoryId<>4"); + my $user = WebGUI::User->new($self->session, $userId); + $b = $self->session->db->read("select fieldName from userProfileField where profileCategoryId<>4"); while (($fieldName) = $b->array) { if ($search->entry(0)->get_value(_alias($fieldName)) ne "") { $user->profileField($fieldName,$search->entry(0)->get_value(_alias($fieldName))); @@ -89,12 +138,11 @@ print $date[3]; } $ldap->unbind; } else { - print "Couldn't bind to LDAP host ".$uri->host."\nError Message from LDAP: ".$ldapStatusCode{$result->code}."\n"; + $self->session->errorHandler->warn("Couldn't bind to LDAP host ".$uri->host."\nError Message from LDAP: ".$ldapStatusCode{$result->code}); } } } $a->finish; - } } 1; diff --git a/lib/WebGUI/i18n/English/AuthLDAP.pm b/lib/WebGUI/i18n/English/AuthLDAP.pm index 20867d696..9d857faf6 100644 --- a/lib/WebGUI/i18n/English/AuthLDAP.pm +++ b/lib/WebGUI/i18n/English/AuthLDAP.pm @@ -1,6 +1,12 @@ package WebGUI::i18n::English::AuthLDAP; our $I18N = { + 'sync profiles to ldap' => { + message => q|Sync Profiles To LDAP|, + lastUpdated => 0, + context => q|the title for the sync profiles workflow activity| + }, + 'account template' => { message => q|Account Template|, lastUpdated => 1078852969 diff --git a/sbin/runHourly.pl b/sbin/runHourly.pl deleted file mode 100644 index 5957a8c26..000000000 --- a/sbin/runHourly.pl +++ /dev/null @@ -1,115 +0,0 @@ -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2006 Plain Black Corporation. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - - -our $webguiRoot; - -BEGIN { - $webguiRoot = ".."; - unshift (@INC, $webguiRoot."/lib"); -} - -use DBI; -use Getopt::Long; -use strict qw(subs vars); -use WebGUI::Session; -use WebGUI::Utility; - -$|=1; - -my $verbose; -my $help; - -GetOptions( - 'help'=>\$help, - 'verbose'=>\$verbose -); - -if ($help) { - print <