1 of 1 people found this helpful
As you said, you'll probably need to use a different connection method, since I assume currently it's using the PISystem.Connect() overload? If you choose to use the overload PISystem.Connect(NetworkCredential), you will need to provide the NetworkCredential object in your code. This object is of type System.Net.NetworkCredential, so you'll likely need to import System.Net into your project to access it. Otherwise, you may use another overload like Connect(bool, IWin32Window), which will provide a logon dialog similar to the one you see for PI System Explorer for credentials if the initial logon fails. This could be a better choice if the application is meant to be used both within and outside the domain environment (so you don't need to populate the NetworkCredential yourself in the code).
By the way, since we are talking about connecting to a PISystem (AF server) here, the PI Data Archive trusts do not come into play in the connection attempts. PI Data Archive trusts will only be considered for use if you are connecting to a PI Data Archive (OSIsoft.AF.PI.PIServer). Additionally, Windows authentication is the only option for connecting to PI AF servers.
Thank You for quick answer
As you wrote I imported System.net
and wrote some lines:
credential = NetworkCredential
%stworzenie obiektu reprezentującego bazy danych
and it is working!!!
but as You wrote it is not safe solution because I must to wrote password.
I tried use but I don't now what to write as the second argument
I tried write null, Nothing, NaN (base on PISystem.Connect Method (Boolean, IWin32Window)) ) but it didn't work
Could You help me once more and tell what should I import or declare to use Connect(bool, IWin32Window)?
My apologies, Piotr,
You may also need to add the System.Windows.Forms reference. Try adding that and see if that works.
I'll try it and let You know how it work in next few days