[rt-users] Re: modifing users
seph
seph at directionless.org
Thu Nov 6 08:58:57 EST 2003
> I want to do same export from a software that I use into rt.
please don't ask question twice.
> But I can't make get the UpdateRecordObject to work.
it's been a bit since I started at the code, but when I did this, I
didn't use UpdateRecordObject. It doesn't sound familer. Here's most
of my subroutine:
# set up the attributes array:
my %user_attributes;
$user_attributes{'Name'} = $user_name;
$user_attributes{'Gecos'} = $login;
# let's create an rt user object, and we'll see
my $user_obj = new RT::User($CurrentUser);
$user_obj->Load($user_name);
# alrighty, create the user, if they don't exist.
unless ($user_obj->id) {
print "User '$user_name' not found, creating\n" if($verbose);
my ($status, $msg) =
$user_obj->Create( %user_attributes );
print "$msg\n" if($verbose);
}
# if they already exist, let's just frob them...
else {
# now that we know we have a user, let's set it's attributes
# this bit of code lifted from rtadmin
my @attributes = ('Name', 'Gecos',
'EmailAddress', 'Privileged', 'Comments', 'Signature',
'Organization', 'RealName', 'NickName',
'ExternalContactInfoId', 'ContactInfoSystem',
'ExternalAuthId', 'AuthSystem',
'HomePhone', 'WorkPhone', 'MobilePhone', 'PagerPhone',
'Address1', 'Address2', 'City', 'State', 'Zip',
'Country', 'FreeformContactInfo');
foreach my $attrib (@attributes) {
if ( (exists ($user_attributes{"$attrib"})) and
($user_obj->$attrib() ne $user_attributes{"$attrib"})) {
my $method = "Set$attrib";
my ($val, $msg) = $user_obj->$method($user_attributes{"$attrib"});
print "User ".$user_obj->Name. " $attrib: $msg\n" if($verbose);
}
}
seph
More information about the rt-users
mailing list