Jump to content


"Perforce password (P4PASSWD) invalid or unset." when using tickets in P4API.NET

p4api.net login ticket

  • Please log in to reply
4 replies to this topic

#1 gharding

gharding

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 26 November 2016 - 03:35 PM

Hi,

We are having a problem using P4API.NET (C#) with tickets.
The API version is 2013.1.685046-vs2010_static_x64

First thing I checked was the ticket.  But the ticket works fine from the command line.
I can run these commands without any errors:

p4 -u <myUserName> -p <myServerAddress> tickets
p4 -u <myUserName> -p <myServerAddress> login -s
p4 -u <myUserName> -p <myServerAddress> client -o <myClient>
p4 -u <myUserName> -p <myServerAddress> -P<myTicket> tickets
p4 -u <myUserName> -p <myServerAddress> -P<myTicket> login -s
p4 -u <myUserName> -p <myServerAddress> -P<myTicket> client -o <myClient>

The "login -s" command gives the output "ticket expires in 185364 hours 28 minutes."

----

Here is our C# code:

// Config
string myServerAddress = ...
string myUserName = ...
string myTicket = ...
string myClient = ...

// Connect
var p4Server = new Server(new ServerAddress(myServerAddress));
var p4Repository = new Repository(p4Server);

p4Repository.Connection.UserName = myUserName;

var connectOptions = new Options();
connectOptions["Ticket"] = myTicket;
p4Repository.Connection.Connect(connectOptions);

// Login
string password = null;
var loginOptions = new Options();
loginOptions.Add("-s", null);

if (p4Repository.Connection.Login(password, loginOptions) == null)
{
	// Failed to login!
	// Any command run after this point will fail with the error "Perforce password (P4PASSWD) invalid or unset."
	throw new Exception();
}

The Login() call always returns null.
The log for P4API.NET contains the following errors:

Connect
P4 API log from P4API>NET: Perforce.P4.P4Exception:Perforce password (P4PASSWD) invalid or unset.
at Perforce.P4.P4Exception.Throw(String cmd, String[] args, P4ClientErrorList errors, String[] details)
at Perforce.P4.P4Server.RunCommand(String cmd, UInt32 cmdId, Boolean tagged, String[] args, Int32 argc)
at Perforce.P4.P4Command.RunInt(StringList flags)
at Perforce.P4.P4CommandResult..ctor(P4Command cmd, StringList flags)
at Perforce.P4.P4CommandResult..ctor(P4Command cmd)
at Perforce.P4.P4Command.Run()
at Perforce.P4.Client.Initialize(Connection connection)
at Perforce.P4.Connection.Connect(Options options)

Login
P4 API log from P4Command: Perforce.P4.P4Exception:Perforce password (P4PASSWD) invalid or unset.
at Perforce.P4.P4Exception.Throw(String cmd, String[] args, P4ClientErrorList errors, String[] details)
at Perforce.P4.P4Server.RunCommand(String cmd, UInt32 cmdId, Boolean tagged, String[] args, Int32 argc)
at Perforce.P4.P4Command.RunInt(StringList flags)

----

I have tried using both a local ticket and a ticket issued with "p4 login -a".
I have tried switching to the latest P4API.NET version (2106.1)
I have tried alternative code which sets password = ticket, for example:

var connectOptions = new Options();
options["Password"] = myTicket;
p4Repository.Connection.Connect(connectOptions);

// Login
string password = myTicket;
var loginOptions = new Options();
loginOptions.Add("-s", null);

if(p4Repository.Connection.Login(password, loginOptions) == null) { }
In each case, the result is the same. Login returns null and all commands fail with the message "Perforce password (P4PASSWD) invalid or unset."

I believe the server is security level 3.  Here are the server options from "p4 -ztag info":
... brokerVersion P4BROKER/LINUX26X86_64/2014.1/895936
... clientLock none
... monitor enabled
... security enabled
... ldapAuth enabled
... serverVersion P4D/LINUX26X86_64/2015.2/1377629 (2016/04/18)
... serverServices commit-server
... caseHandling insensitive
... integEngine 3
... allowPush 2
... allowFetch 2

I suspect it is something in the server configuration, because the code was working until recently.  I'll try to find out if anything changed on the server.

In the meantime, any clue what is wrong?

#2 valinia

valinia

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 31 December 2016 - 02:26 PM

I have same problem here.

Any solution, please?

#3 mgelgoot

mgelgoot

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 20 March 2017 - 06:18 PM

Same here. That problem appeared for the first time a few month ago without any changes on our client side.

Any suggestions?

Thanx

#4 jasdev55

jasdev55

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 18 April 2017 - 07:11 PM

I'm trying to use the "login -s" command in a Visual Studio extension, and am getting the same results.  My assumption was that this command doesn't require a password because it is only checking the current login status.

#5 p4rfong

p4rfong

    Advanced Member

  • Staff Moderators
  • 343 posts

Posted 08 May 2017 - 08:27 PM

The standard 'p4tickets' file location is %USERPROFILE%\p4tickets.txt on Windows, and in $HOME/.p4tickets on other operating systems. Therefore the question is - what user is running Perforce commands commands from your P4API.Net program? You may also run 'p4 login' from within the API to populate the right tickets file.

If you are still having problems, make sure the login works from the Perforce command line.
p4 -u <Perforce user> tickets
p4 -u <Perforce user> login -s
p4 -u <Perforce user> login
p4 -u <Perforce user> tickets

For more troubleshooting, you can erase you p4tickets.txt or .p4tickets file in your home directory and run the above commands again.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users