2 Replies Latest reply on May 2, 2018 9:44 AM by Thanawat

    How to connect PI Server by PI-SDK using window authentication


      Hi all,

           I'm looking for the way How to connect PI Server by PI-SDK using window authentication.

      Normally, i used the local pi user to connect piserver like code below.

      srv.Open("UID=pidemo;PWD= ")

      But, if i would like to connect by domain user like this.

      srv.Open("UID=domianname\username;PWD=passwrd ")

      Is ti possible to do that?



        • Re: How to connect PI Server by PI-SDK using window authentication

          Hello Thanawat,


          When you sign-in to Windows using your domain credentials, you become authenticated by the domain controller. Using Windows authentication means to authenticate as the user already logged on to Windows. By default every application is launched under your domain user credentials and unless you like to use a different account than the one which is already signed in, you don't need to do anything in code with regards to authentication.


          Please see AL00206 - Security Alert: PI Authentication Weakness to learn why we discourage against using explicit login. The remaining options are PI Trust or PI Mapping. With PI Mapping a Windows user account becomes mapped to a PI Identity. While Windows Security is highly recommended, you can set the protocol order to be used with connection attempts on each client individually. Under the assumption, the information provided with a connection attempt would allow to authenticate via PI Trust as well as via PI Mapping, than it really depends on the client setting what will be attempted and hence used in first place.


          The following PI SDK sample works uses Windows Security in my environment.


                      PISDK.Server pisrv = new PISDK.PISDK().Servers["GB-PIDA1"];
                      PIPoint pt = pisrv.PIPoints["CDT158"];
                      PIValues vals = pt.Data.RecordedValues("*-1h", "*", BoundaryTypeConstants.btInside, "", FilteredViewConstants.fvShowFilteredState, null);
                      foreach(PIValue val in vals)
                          Console.WriteLine("Value {0} at {1}", val.Value, val.TimeStamp.LocalDate);


          Last but not least, please be informed that we highly discourage from using PI SDK with recent development projects because it is announced for deprecation.

          4 of 4 people found this helpful