[rt-users] RT3.6.5 / LDAP / User Fields not updated

Patterson, Craig crpatter at ci.grand-rapids.mi.us
Thu Feb 21 10:18:24 EST 2008


I apologize; I didn't provide enough details in my previous post.

My trouble code is not in my User_Local.pm, it's actually in an external
perl script I run in a weekly cronjob.  Basically, it's purpose is to
update any users who have been update more recently in AD than in RT.
But the symptoms are similar, so jumped on this thread.


Anyway, I entered your suggestions and am still having the issues.  Here
are snippets from my code...

    my $UserObj = RT::User->new($RT::SystemUser);
    $UserObj->Load($userid);

    $ARGS{'Name'} = $UserObj->Name;    
    $UserObj->USER_LOCAL::CanonicalizeUserInfo(\%ARGS);

....bunch of logic to determine if the record needs updating, if so I
fire this code...

	$RT::Logger->info("COGR - RT-LDAP-Cron-Cleanup Script:  Updating
-> " 		. $UserObj->Name);

	# Save the Record!
	my ($method_success, $method_msg) =  $UserObj->Update( 
	    	AttributesRef => \@fields,
			ARGSRef => \%ARGS 
		);

	if (!$method_success){
	    $RT::Logger->debug("update failed.  $method_msg");
	}else {
	    $RT::Logger->debug("======  Update Succeeded =====");
	}

As you can see, I do use the SystemUser and I know that the UserObject
is being loaded because the log shows the name, but the Update method
never succeeds.

Any suggestions,

Craig

-----Original Message-----
From: Mike Peachey [mailto:mike.peachey at jennic.com] 
Sent: Thursday, February 21, 2008 7:59 AM
To: Patterson, Craig; RT Users
Subject: Re: [rt-users] RT3.6.5 / LDAP / User Fields not updated

Patterson, Craig wrote:
> I'm having a similar issue.  I call $UserObj->Update(....) after
setting
> my args.  Is there some type of Commit function I need to call
> afterwards?
> 
> Robert, is this similar to the way you do it?


The problem is almost certainly permissions, and I've suddenly come a 
cropper on it too.

Make this change to your User_Local.pm:

Replace:
         $self->$method($args{$key});

With:
         my ($method_success,$method_msg) = $self->$method($args{$key});
         if (!$method_success) {
             $RT::Logger->debug("$method Failed. $method_msg");
         }

And for each field it can't update it will log a debug message about it.

For me, at the moment, it works with a privileged user because they are 
allowed to edit their user information, but it doesn't work for an 
unprivileged user because they are not.

Since you are calling the Set$method methods on the User Object itself, 
if that user doesn't have permission to change their own details, you 
can't do it.

You can get around it by doing something like this which is to create an

RT::SystemUser object, and then load the user inside it.

             my $UserObj = RT::User->new($RT::SystemUser);
             $UserObj->Load($name_to_update);
             my ($val, $message) = $UserObj->SetDisabled(1);
-- 
Kind Regards,

__________________________________________________

Mike Peachey, IT
Tel: +44 114 281 2655
Fax: +44 114 281 2951
Jennic Ltd, Furnival Street, Sheffield, S1 4QT, UK
Comp Reg No: 3191371 - Registered In England
http://www.jennic.com
__________________________________________________



More information about the rt-users mailing list