3 Replies Latest reply on Sep 1, 2011 12:01 AM by Ahmad Fattahi

    Unauthorized Access Exception


      Hi all,


      Its been quite a while since I have been able to post to VCampus and that makes me sad. Been very busy trying to learn new SCADA system, Cisco Systems and not enough PI, not good to have PI withdrawls....


      I could use some help with ane error ...


      This code was written and ran sucessfully against PI Server before version WIS (3.4.380.36), our current version. I suspect that the new version is contributing to my problem, not the server itself but the fact that my coding should and has to be different, and I dont have a lot of time to dig deep hence could "Batman" or any of the other "super stars" on this site be so kind to school me.


      Also this code always did seem to take "too long" any cunstructive critism on improving performance would be appreciated


      The error comes at line


      nvsSum = ipid.Summaries2("-5m", "*", "", ArchiveSummariesTypeConstants.asCount, CalculationBasisConstants.cbEventWeighted)
                  valTot = nvsSum("Count").Value


      and reads


      Insufficient permission to access or complete operation.[-10400] No Read Access - Secure Object


      Thanks in Advance

              Dim g_pi As New PISDK.PISDK
              Dim srv As Server
              srv = g_pi.Servers.Item("x")
              srv.Open("UID=pidemo;PWD= ")
              Dim ipid As IPIData2
              Dim pdata As PIData
              Dim nvsSum As NamedValues
              Dim valTot As PIValues
              Dim pt As PIPoint
              Dim strQuery As String
              Dim ptList As PointList
              ptList = New PointList
              Dim ptCnt As Integer
              Dim pointNameCounter As Integer
              Dim eventCounter As Integer
              ' Set the value of the counter variable.
              pointNameCounter = 0
              eventCounter = 0
              strQuery = "Tag LIKE '*'"
              ptList = srv.GetPointsSQL(strQuery)
              ptCnt = CInt(ptList.Count)
              For Each pt In ptList
                  pdata = pt.Data
                  ipid = pdata
                  nvsSum = ipid.Summaries2("-5m", "*", "", ArchiveSummariesTypeConstants.asCount, CalculationBasisConstants.cbEventWeighted)
                  valTot = nvsSum("Count").Value
                  For m = 1 To valTot.Count
                      eventCounter = valTot(m).Value + eventCounter
                  pointNameCounter = pointNameCounter + valTot.Count
              Label2.Text = pointNameCounter
              Label1.Text = eventCounter


        • Re: Unauthorized Access Exception
          Ahmad Fattahi

          Most likely the security on the user pidemo changed after your upgrade resulting in the PI user pidemo not having read privileges, having a password, or going away altogether. Please try one of the following to see if it narrows down the security issue. You can pass an empty string "" as the parameter to the Open method (as opposed to "UID=pidemo;PWD= ") and see if it makes any changes. This will try connecting to the PI Server using different methods than explicit user name/password. If it doesn't work, then you can add a mapping on the PI Server for the Windows user initiating the connect to the PI Server (recommended) or alternatively create a trust on the PI Server. In any case, make sure that the corresponding PI user has sufficient read privileges on the tags.


          This is the better way to move forward. If for any reason it is not feasible to make such changes, you can create a user called pidemo with a password on the PI Server. Then you can pass the password in your connection string.


          Hope it helps. For more information on the parameters to pass you can see the PI SDK documentation for Open method (Server Object).

            • Re: Unauthorized Access Exception



                           Thanks I switched "UID=pidemo;PWD= "  to "" as you suggested and it works.


              Please further my education here...


              By passing "" to the open method I gather I am telling the program to search the login options defined in the PI-SDK login methods which in my case I have Windows Method first and since my login is mapped to PI World Identity and PIAdmin User I am getting authenicated that way.


              I see in the PI Log that my domain username connected.


              Heres what Im not sure about I can still connect as pidemo blank password if I do a "connect as" within the PI-SDK connection manager. This is what you refer to as an explicit log on. Correct?


              I am just trying to understand for sure, I think I understand from a administrative perspective but as I have mentioned before I am very novice at the programming side, a few college courses over 10 years ago....




              Thanks for all your help


              with that in mind I would think that pidemo still has read access, on those tables

                • Re: Unauthorized Access Exception
                  Ahmad Fattahi



                  Your description is right. My intention was to let PI SDK decide based on the set order you described; fortunately the WIS method, which is the recommended method, turned out to be the highest on the list and worked in your security environment with sufficient privileges.


                  Yes, that's what I would refer to as explicit log in. In your case, the user name/password seems to be existing and fine on the PI Server. However, pidemo should be lacking read privilegs on some PI tag(s). In your loop you can have it list the name of the current tag so you know where it is failing if you are interested.


                  Having said that, it is absolutely not recommended to use pidemo/"" as the username/password for obvious security reasons. The WIS would be the way to go. Glad it worked!