[p4perl] Impersonating a user (p4perl 2007.3)

G Barthelemy gb.perforce at googlemail.com
Wed Jul 9 10:15:33 PDT 2008

Hi P4Perlers,

How can users who have password-protected accounts be impersonated,
using p4perl 2007.3 ?

I get a "password invalid" error when running
$p4->RunLogin($user_to_impersonate) even if a superuser has been
specified with SetUser, so no ticket gets generated.

Another related question: the only method I found to impersonate users
(without password protection), is a bit convoluted: for each user, I
have to use P4::SetUser($user_to_impersonate), which means have to
P4::Connect() and therefore P4::Disconnect(). The latter seems to act
as a destructor, so I end up having to re-instance a P4 object inside
a foreach loop, i.e.:

use P4;
our $p4 = new P4;

my $usersref = $p4->RunUsers();

foreach my $userref (@$usersref) {
    my $user = $userref->{'User'};
    $p4 = new P4;
    my @info = $p4->RunInfo();
    # Do something with @info

Surely there must be a better way ! Any ideas ?


More information about the p4perl mailing list