Lots of bug fixes. Anonymous syncs now work
This commit is contained in:
parent
b74afadb9b
commit
a4ed315b32
1 changed files with 41 additions and 40 deletions
|
|
@ -19,6 +19,7 @@ use strict;
|
||||||
use base 'WebGUI::Workflow::Activity';
|
use base 'WebGUI::Workflow::Activity';
|
||||||
use Net::LDAP;
|
use Net::LDAP;
|
||||||
use WebGUI::Auth;
|
use WebGUI::Auth;
|
||||||
|
use WebGUI::LDAPLink;
|
||||||
use WebGUI::User;
|
use WebGUI::User;
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
@ -109,49 +110,49 @@ See WebGUI::Workflow::Activity::execute() for details.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub execute {
|
sub execute {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $userObject = shift; # Set to the current user by the instance
|
my $userObject = shift; # Set to the current user by the instance
|
||||||
my ($userId, $userData, $uri, $port, %args, $fieldName, $ldap, $search, $sth);
|
my $userId = $userObject->userId;
|
||||||
|
my $auth = WebGUI::Auth->new($self->session, "LDAP",$userId);
|
||||||
|
my $userData = $auth->getParams;
|
||||||
|
|
||||||
$userId = $userObject->userId;
|
#Don't bother with this script if the user is not using the LDAP auth module.
|
||||||
my $auth = WebGUI::Auth->new($self->session, "LDAP",$userId);
|
return $self->COMPLETE if($userObject->authMethod ne "LDAP");
|
||||||
$userData = $auth->getParams;
|
|
||||||
$uri = URI->new($userData->{ldapUrl});
|
|
||||||
if ($uri->port < 1) {
|
|
||||||
$port = 389;
|
|
||||||
} else {
|
|
||||||
$port = $uri->port;
|
|
||||||
}
|
|
||||||
|
|
||||||
%args = (port => $port);
|
my $ldapLink = WebGUI::LDAPLink->new($self->session,$userData->{ldapConnection});
|
||||||
$ldap = Net::LDAP->new($uri->host, %args);
|
# Just complete if can't setup ldapLink for the user
|
||||||
if ($ldap) {
|
|
||||||
my $result = $ldap->bind;
|
if($ldapLink) {
|
||||||
if ($result->code == 0) {
|
my $ldap = $ldapLink->bind();
|
||||||
$search = $ldap->search( base=>$userData->{connectDN}, filter=>"&(objectClass=*)" );
|
if($ldap) {
|
||||||
if($search->code) {
|
my $uri = $ldapLink->getURI();
|
||||||
$self->session->errorHandler->warn("Couldn't search LDAP ".$uri->host." to find user ".$userObject->username." (".$userId.").\nError Message from LDAP: ".$ldapStatusCode{$search->code});
|
my $search = $ldap->search(
|
||||||
}
|
base =>$ldapLink->getValue("ldapUserRDN"),
|
||||||
|
scope =>"sub",
|
||||||
|
filter =>$ldapLink->getValue("ldapIdentity").'='.$userObject->username
|
||||||
|
);
|
||||||
|
if($search->code) {
|
||||||
|
$self->session->errorHandler->warn("Couldn't search LDAP ".$uri->host." to find user ".$userObject->username." (".$userId.").\nError Message from LDAP: ".$ldapStatusCode{$search->code});
|
||||||
|
return $self->COMPLETE;
|
||||||
|
}
|
||||||
elsif ($search->count == 0) {
|
elsif ($search->count == 0) {
|
||||||
$self->session->errorHandler->warn("No results returned for user with dn ".$userData->{connectDN});
|
$self->session->errorHandler->warn("No results returned for user with dn ".$userData->{connectDN});
|
||||||
}
|
return $self->COMPLETE;
|
||||||
else {
|
}
|
||||||
$sth = $self->session->db->read("select fieldName from userProfileField where profileCategoryId<>4");
|
else {
|
||||||
while (($fieldName) = $sth->array) {
|
my $sth = $self->session->db->read("select fieldName from userProfileField where profileCategoryId<>4");
|
||||||
if ($search->entry(0)->get_value($self->_alias($fieldName)) ne "") {
|
while (my ($fieldName) = $sth->array) {
|
||||||
$userObject->profileField($fieldName,$search->entry(0)->get_value($self->_alias($fieldName)));
|
if ($search->entry(0)->get_value($self->_alias($fieldName)) ne "") {
|
||||||
}
|
$userObject->profileField($fieldName,$search->entry(0)->get_value($self->_alias($fieldName)));
|
||||||
}
|
}
|
||||||
$sth->finish;
|
}
|
||||||
}
|
}
|
||||||
$ldap->unbind;
|
$ldap->unbind;
|
||||||
}
|
} else {
|
||||||
else {
|
$self->session->errorHandler->warn("Error connecting to LDAP: ".$ldapLink->getErrorMessage);
|
||||||
$self->session->errorHandler->warn("Couldn't bind to LDAP host ".$uri->host."\nError Message from LDAP: ".$ldapStatusCode{$result->code});
|
return $self->ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self->COMPLETE;
|
return $self->COMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue