|
Email lists >
P4Perl discussion >
Re: [p4perl] Impersonating a user (p4perl 2007.3) >
Re: [p4perl] Impersonating a user (p4perl 2007.3)
Re: [p4perl] Impersonating a user (p4perl 2007.3)
This post if a part of this thread
|
2008-07-10 05:12:32 |
|
|
Re: Impersonating a user (p4perl 2007.3)
|
Hi Guillaume,
> 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.
Have you got a valid ticket for the super-user? You have to
prove you are the
super-user before you can run 'p4 login <otheruser>'.
Can you run other
commands as that super-user?
> 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: isconnec
t(). 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;
>
> $p4->Connect();
> my $usersref = $p4->RunUsers();
> $p4->Disconnect();
>
> foreach my $userref ( $usersref) {
> my $user = $userref->{'User'};
> $p4 = new P4;
> $p4->SetUser($user);
> $p4->Connect();
> my info = $p4->RunInfo();
> # Do something with info
> $p4->Disconnect();
> }
>
> Surely there must be a better way ! Any ideas ?
No, that's the right way to do it - authentication is done
once per session,
not once per command (otherwise that would be slow), so you
need a new
session for each user you want to impersonate.
Regards,
Tony
_______________________________________________
p4perl mailing list
p4perl perforce.com
http://maillist.perforce.com/mailman/listinfo/p4perl
|
|
|
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|