5 Replies Latest reply on Mar 30, 2015 8:10 AM by Eugene Lee

    Where do I find online PISDK documentation?

    OmicronPi

      I'm having trouble navigating the new web site.

       

      If it's helpful to have more details, I'm specifically looking for updated documentation on the "IPISecurity Example".

       

      And, my specific issue is that I'm setting security but it doesn't seem to be "sticking" -- (ipis2.PutSecurity(NamedValues newSecurity) doesn't seem to do anything?)

       

      Thanks!

      Eric

        • Re: Where do I find online PISDK documentation?
          dng

          Hi Eric,

           

          There several ways to get the documentation for PI SDK:

          • On your computer that has PI SDK installed, the PI SDK reference guide is located at %pihome%\HELP\pisdk.chm. This should be the same version as the version of PI SDK installed.
          • You can look at the the PI SDK reference guide online in the OSIsoft Documentation Library (link here). Note that the latest version of the PI SDK reference guide is not available there. I encourage you to check out the local copy on your computer instead.

          Moving forward, we plan to migrate documentation contents into PI Live Library (link here). The reference guides are not in PI Live Library at the moment.

           

          Regarding you specific issue, check out the example in pisdk.chm for IPISecurity2. If you need further help, can you post your code snippet? We will then be able to further assist you.

            • Re: Where do I find online PISDK documentation?
              OmicronPi

              Hi Daphne-

               

              Thanks for your reply.  I have been referring to the local PI-SDK Help file on my computer, but the examples are about 10years old.  For example, the IPISecurity2 example uses VB6 and doesn’t demonstrate setting security with an Access Control List.

               

              This is essentially what I’m trying to do (bearing in mind, these aren’t the real privileges I’m trying to set):

               

              Imports OSIsoft

              Imports PISDK

              Imports PISDKCommon

               

              Public Class ModulesSecurity

                  Private myPiSdk As PISDK.PISDK = New PISDK.PISDK()

                  Private piServer As Server

                  Private securityConstants As PIConstant

                  Private securityIdx As Integer

               

               

                  Public Sub test()

                      Try

                          piServer = myPiSdk.Servers.DefaultServer

                          piServer.Open()

                      Catch ex As Exception

                          Throw

                      End Try

               

                      securityConstants = myPiSdk.PIConstants.Item("MDBBDBSecConstants")

                      Dim moduleSecurity As IPISecurity2 = piServer.PIModuleDB

                      Dim moduleSecurity1 As IPISecurity = piServer.PIModuleDB

                      Dim currentSecurity As PISDKCommon.NamedValues = moduleSecurity.GetSecurity()

               

                      Dim accessControlList = "piadmin: A(r,w) | piadmins: A(r,w) | PIWorld: A(r) | PIEngineers: A(r,w)"

               

                      securityIdx = securityConstants("Security").Value

                      Dim newSecurity = New NamedValues

                      newSecurity.Add(securityIdx, accessControlList)

               

                      Dim o = securityConstants("Owner").Value

                      Dim a = securityConstants("Access").Value

                      newSecurity.Add(o, "PIEngineers")

                      newSecurity.Add(a, "o:r g: w:rw")

               

                      Trace.WriteLine(currentSecurity("Security").Value)

                      'currentSecurity("Security").Value = accessControlList

               

                      Trace.Assert(moduleSecurity1.IsWriteable, "NOT WRITABLE")

                      moduleSecurity.PutSecurity(newSecurity)

                      Trace.WriteLine(currentSecurity("Security").Value)

                  End Sub

               

              The “before” and “after” security settings (currentSecurity("Security").Value) print the same string.  (I HAVE tried to “GetSecurity()” after “PutSecurity()”, but that doesn’t seem to make a difference.)

               

              Thanks!

              Eric

                • Re: Where do I find online PISDK documentation?
                  dng

                  Hi Eric,

                   

                  Since TS Case # 619603 was opened for this issue. I will continue to assist you there and post the final resolution to this thread.

                  • Re: Where do I find online PISDK documentation?
                    dng

                    The issue with the original code is the construction of the NamedValues collection for "newSecurity". The collection needs to have 4 pairs of name+value:

                    • Name: Owner; Value: (e.g. piadmin)
                    • Name: Group; Value: (e.g. piadmins)
                    • Name: Access; Value: (e.g. o:rw g:rw w:r)
                    • Name: Security; Value: (e.g. piadmin: A(r,w) | piadmins: A(r,w) | PIWorld: A(r))

                     

                    Nonetheless, we can use the existing NamedValues collection and just modify the value for the "Security" item as follow:

                     

                        Sub SecurityTest()
                            Dim myPisdk As PISDK.PISDK = New PISDK.PISDK()
                            Dim piServer As Server
                    
                            piServer = myPisdk.Servers.DefaultServer
                            Dim moduleSecurity As IPISecurity2 = piServer.PIModuleDB.PIModules("TestModule")
                            Dim currentSecurity As PISDKCommon.NamedValues = moduleSecurity.GetSecurity
                    
                            For index = 1 To currentSecurity.Count
                                Debug.WriteLine("{0}; {1}", currentSecurity(index).Name, currentSecurity(index).Value)
                            Next
                    
                            Dim oldACL = currentSecurity("Security").Value
                            Dim newACL = "piadmin: A(r,w) | piadmins: A(r,w) | PIWorld: A(r) | PIEngineers: A(r,w)"
                    
                            currentSecurity("Security").Value = newACL
                            moduleSecurity.PutSecurity(currentSecurity)
                            Dim currentSecurity2 As PISDKCommon.NamedValues = moduleSecurity.GetSecurity
                            For index = 1 To currentSecurity2.Count
                                Debug.WriteLine("{0}; {1}", currentSecurity2(index).Name, currentSecurity2(index).Value)
                            Next
                    
                            currentSecurity("Security").Value = oldACL
                            moduleSecurity.PutSecurity(currentSecurity)
                            Dim currentSecurity3 As PISDKCommon.NamedValues = moduleSecurity.GetSecurity
                            For index = 1 To currentSecurity3.Count
                                Debug.WriteLine("{0}; {1}", currentSecurity3(index).Name, currentSecurity3(index).Value)
                            Next
                        End Sub
                    
                      • Re: Where do I find online PISDK documentation?
                        Eugene Lee

                        Hi Daphne,

                         

                        Thanks for sharing! I was curious too and did some testing myself and I think if you just specify Security attribute, it is sufficient if the PI Server is 3.4.380 and above. Here is my code

                        Sub SecurityTest()
                                Dim myPisdk As PISDK.PISDK = New PISDK.PISDK()
                                Dim piServer As Server
                        
                                piServer = myPisdk.Servers.DefaultServer
                                Dim moduleSecurity As IPISecurity2 = piServer.PIModuleDB.PIModules("Element10")
                                Dim currentSecurity As PISDKCommon.NamedValues = moduleSecurity.GetSecurity
                        
                                For index = 1 To currentSecurity.Count
                                    Debug.WriteLine("{0}; {1}", currentSecurity(index).Name, currentSecurity(index).Value)
                                Next
                        
                                'Dim oldACL = currentSecurity("Security").Value
                                Dim newACL = "piadmin: A(r,w) | piadmins: A(r,w) | PIWorld: A(r,w)"
                        
                                Dim newsecurity As PISDKCommon.NamedValues = New PISDKCommon.NamedValues()
                                newsecurity.Add("Security", newACL)
                                'currentSecurity("Security").Value = newACL
                                moduleSecurity.PutSecurity(newsecurity)
                                Dim currentSecurity2 As PISDKCommon.NamedValues = moduleSecurity.GetSecurity
                                For index = 1 To currentSecurity2.Count
                                    Debug.WriteLine("{0}; {1}", currentSecurity2(index).Name, currentSecurity2(index).Value)
                                Next
                            End Sub
                        

                         

                        Below is my output

                         

                        Owner; piadmin

                        Group; piadmins

                        Access; o:rw g:rw w:r

                        Security; piadmin: A(r,w) | piadmins: A(r,w) | PIWorld: A(r)

                        Owner; piadmin

                        Group; piadmins

                        Access; o:rw g:rw w:rw

                        Security; piadmin: A(r,w) | piadmins: A(r,w) | PIWorld: A(r,w)