[rt-devel] Permissions during mass import of users

Matt Simonsen matt_lists at careercast.com
Mon Feb 17 20:25:17 EST 2003


The code at the bottom of this page imports users from a parsed CSV
file. I am now working on setting it up to set the users up as enabled,
able to be given permissions, and able to create and own tickets
automatically. 

I see SetPrivileged in User_Overlay.pm, but I haven't been able to get
that to work. Any tips or example code would be greatly appreciated- I
know think I'm close - just missing a method or something.

Thanks
Matt



  while (<USERS>) {
    my $user_obj = RT::User->new($RT::SystemUser);
    my $user = {} ;
    bless ($user) ;
    my @user = split /","/ ;
    substr ($user[0], 0, 1) = "" ;
    substr ($user[11], -3) = "" ;
    my $old_id = $user[0] ;
    $user->{'Name'} = $user[1] ;
    $user->{'EmailAddress'} = $user[2] ;
    $user->{'EmailAddress'} = $user[0] unless ($user->{'EmailAddress'}
=~ m/@/ );
    $user->{'WorkPhone'} = "$user[3] $user[4]" ;
    $user->{'MobilePhone'} = $user[5] ;
    $user->{'Comments'} = "$user[10] IMPORTED from F2W" ;
    $user->{'Organization'} = $user[11];
# This is intended to set it so uses can be given privileges... doesn't
work
    $user->{'SetPrivileged'} = '0' ;
    my ($uid, $umsg) = $user_obj->Create( %{$user} );
    #Save new user ID
    my $id = $user_obj->Id();
    $user_map->{$old_id} = $id;
  }






More information about the Rt-devel mailing list