Jump to content

P4API.net connection.Credentials is always null

p4api.net connection credentials

  • Please log in to reply
1 reply to this topic

#1 Lubos Suk

Lubos Suk


  • Members
  • Pip
  • 5 posts

Posted 01 November 2019 - 11:57 AM

Using P4Api .Net in C# and trying to retrieve Credentials from Connection object, but Credentials property on Connection object is always null.

In code below you can see simple example of what am i using. Create server, repository, get connection and connect user.

After this methods Login returns Credential object to credential variable which is ok.

But i expects that then property Credential on object connection will be same, but its always null.

Server server = new Server(new ServerAddress(P4Consts.ServerAddress));
var Repository = new Repository(server);
Connection connection = Repository.Connection;
// use the connection variables for this connection
connection.UserName = userName;
// connect to the server
if (connection.Status == ConnectionStatus.Disconnected)
// set the program name and version
Options options = new Options();
options["ProgramName"] = "testApp";
options["ProgramVersion"] = "2018.0.1";
bool succes = connection.Connect(options);
//Setting Command Time Out. If a command times out, P4API.NET will throw a P4CommandTimeOutException
connection.CommandTimeout = TimeSpan.FromSeconds(60);
// login to the server to get credential		   
//credential = connection.Login(password);

var credential = connection.Login(password);
var cred = connection.Credential;

version 2019.2.185.9614

#2 p4bill


    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 18 November 2019 - 04:53 PM

Currently, Credential can be set, but is not set on the Connection object on login. You could set it on login with
connection.Credential = connection.Login(password);
It seems reasonable to expect that the connection.Credential would be automatically set on Login. I'll log an issue here to request that to be implemented.

Also tagged with one or more of these keywords: p4api.net, connection, credentials

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users