List Info

Thread: Creating Users




Creating Users
user name
2006-03-07 19:45:30
Thanks for the help David. It works great. But, I have a follow up question. After modifying the user hash, what would be the corresponding way to save/create the user? I though it would be:
 
$p4->SaveUser( $user );
 
But, this does not seem to work.
 
Thanks.....Scott...
-----Original Message-----
From: Weintraub, David [mailto:david.weintraubbofasecurities.com]
Sent: Tuesday, March 07, 2006 2:00 PM
To: Scott Lavender; p4perlperforce.com
Subject: RE: [p4perl] Creating Users

You don't need the "-f" in the FetchUsers method. In fact, I'm not even sure it takes it. Try:
 
$user = $p4->FetchUser("testUser");
 
or
 
$user = $p4->Run("users", "-o", "testUser");
 
Which is the equivalent. If you need the "-f" parameter, you'll have to do this:
 
$user = $p4->Run("users", "-of", "testUser");
 
Fetch user will also return a new user too, so you can't use it to test to see if a user already exists. Use:
 
$userList = $p4->FetchUsers();
 
or
 
$userList = $p4->Run("users", "-o");
 
if the first method doesn't work. Then, you have to parse what was returned to see if the user actually exists. I'm not 100% sure what this will return. You'll have to play around with it a bit. If you also set P4->Tagged(), this should return a reference to an array of hashes.


From: p4perl-bouncesperforce.com [mailto:p4perl-bouncesperforce.com] On Behalf Of Scott Lavender
Sent: Tuesday, March 07, 2006 1:27 PM
To: p4perlperforce.com
Subject: [p4perl] Creating Users

I need to write a script to create users. But, I am having problems performing a fetch on the user command. First I thought of using this:
 

require P4;
my $p4 = new P4;
 
$p4->ParseForms();
$p4->Connect or die ( "Failed to connect to Perforce Server" );

my $fetched = $p4->FetchUser( "-f testUser" );
...

 
Nothing is returned by the call to FetchUser. I assume it has to do with the force option. Is there a way to do this when creating new users?
 
Thanks.....
 
Scott Lavender | SCM Specialist | Visiprise | office: 770.619.4166 | www.visiprise.com
 

It is our company policy not to accept email of any data controlled by the International Traffic in Arms Regulations (ITAR). Please contact our Security Officer, Matt Reeves, for instructions and authorization to transmit such data.

 
Creating Users
user name
2006-03-08 11:20:38
Hi Scott,

On Tuesday 07 March 2006 19:45, Scott Lavender wrote:
> Thanks for the help David. It works great. But, I have
a follow up
> question. After modifying the user hash, what would be
the corresponding
> way to save/create the user? I though it would be:
>
> $p4->SaveUser( $user );
>
> But, this does not seem to work.

If you're attempting to modify another user's details, you
will need to invoke 
the power of the '-f' flag. This should do the trick:

	$p4->SaveUser( "-f", $user );

Note also that when things don't 'seem to work', it's
worth printing the 
output returned from the command and the contents of the
$p4->Errors() and 
$p4->Warnings() arrays. They'll yield valuable clues.

You can also use $p4->DebugLevel( 3 ) (in the latest
builds of P4Perl) to see 
way more information than you really want. 

Tony
_______________________________________________
p4perl mailing list
p4perlperforce.com

http://maillist.perforce.com/mailman/listinfo/p4perl
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )