Connecting to a PIServer with a domain user

I'm trying to use the AF SDK to connect to a PI Server like this (simplified):

PIServers piServers = new PIServers();
_server = piServers[serverName];



string domain = mydomain;
string username = myusername;
string password = mypassword;


NetworkCredential netCred = new NetworkCredential(username, password, domain);


_server.Connect(netCred);

 

I've mapped the user to the piadmins Identity on the PI Server, but when I try to connect, I get an exception with the message "Cannot connect to the PI Data Archive."

 

In the PI Message Logs I get the following message: "Unsuccessful login  ID: 105. Address: 172.19.30.185. Name: God.Tag.Server.Console.vshost.exe(1748):remote. Credentials used: petter.brodin. Method: Explicit Login. Error: [-12001] Name Not Found in PInt"

 

Is there any reason why this shouldn't work? Is there a better way to approach this when attempting to log in with a domain user?

Parents
  • Hello Petter,

     

    I hope you will forgive me , I have flagged Roger answer as correct instead because Connecting to a PI Data Archive explains very well the several scenarios and is a useful resource for the question: Connecting to a PIServer with a domain user

    , especially:

    // Get the PIServers collection for the current user and default PIServer.
     PIServer myPIServer = new PIServers().["SERVER_NAME"];
    
     // Simple connect with current windows user
     myPIServer.Connect();
     myPIServer.Disconnect();
    
    // Connect and display a credential prompt dialog if current user login fails.
    myPIServer.Connect(true, null);
    

  • No problem.

     

    That being said, a credentials prompt won't work for us, as most of our software runs as services on servers that will ideally go months between each time someone logs into them. This means that the application should be able to restart and connect automatically.

     

    This has normally been solved with explicit logins with username/password specified in the App.config and read into a NetworkCredentials object, but we're running into a situation where we can't do explicit logins because of the client's security requirements. The idea was to add domain to the config and put it into the NetworkCredentials object as described above, but since that showed up in the PI Message Logs as failed explicit logins I started digging further.

Reply
  • No problem.

     

    That being said, a credentials prompt won't work for us, as most of our software runs as services on servers that will ideally go months between each time someone logs into them. This means that the application should be able to restart and connect automatically.

     

    This has normally been solved with explicit logins with username/password specified in the App.config and read into a NetworkCredentials object, but we're running into a situation where we can't do explicit logins because of the client's security requirements. The idea was to add domain to the config and put it into the NetworkCredentials object as described above, but since that showed up in the PI Message Logs as failed explicit logins I started digging further.

Children