Coder Social home page Coder Social logo

Comments (14)

Hugovdberg avatar Hugovdberg commented on August 12, 2024

Currently this isn't supported in the python API, and I think I cannot test it locally. Would you be able to test it if I added it to the code?

from piconnect.

gygabyte017 avatar gygabyte017 commented on August 12, 2024

from piconnect.

Hugovdberg avatar Hugovdberg commented on August 12, 2024

Can you install the test version using pip install git+https://github.com/Hugovdberg/PIconnect@feature/511_connection_credentials?

You should then be able to connect to the PI Data Archive using something like the following:

import PIconnect as PI
from PIconnect.PIConsts import AuthenticationMode

with PI.PIServer(username='...', password='...', authentication_mode=AuthenticationMode.PI_USER_AUTHENTICATION) as server:
    points = server.search('*')
    print(len(points))

Note that it's required to provide both a username and password (no default username). If you need to provide a login domain you can use the argument domain. If you need Windows authentication instead of PI user authentication you should set the authentication_mode to AuthenticationMode.WINDOWS_AUTHENTICATION.

If you experience any issues please let me know!

from piconnect.

gygabyte017 avatar gygabyte017 commented on August 12, 2024

Thank you! Here's my results.

SecureString object seems not to be working: I get PIAuthenticationException.

Something seems wrong because if I print the SecurePassword.Length I get 0, so I guess no password is being passed to the server:

    def __enter__(self):
        if self._credentials:
            print(self.server_name)
            print(self._credentials[0].SecurePassword.Length)
            self.connection.Connect(*self._credentials)
            print(self.connection.CurrentUserName)

Instead, if I replace the SecureString with just a String:

cred = [username, password] + ([domain] if domain else [])

the connection is successful (I added some print to the __enter__ method to get sure that the correct server and the correct user is will logged in).

from piconnect.

gygabyte017 avatar gygabyte017 commented on August 12, 2024

This works with SecureString:

        if username:
            from System.Net import NetworkCredential
            from System.Security import SecureString
            
            secureString = SecureString()
            for c in password:
                secureString.AppendChar(c)

            cred = [username, secureString] + ([domain] if domain else [])
            self._credentials = (NetworkCredential(*cred), int(authentication_mode))

I guess a SecureString in .NET cannot be constructed from a string, but must be built char by char...

from piconnect.

Hugovdberg avatar Hugovdberg commented on August 12, 2024

Thanks for testing! I will fix the SecureString construction, that has some more guarantees the text is removed from memory as soon as possible.

from piconnect.

Hugovdberg avatar Hugovdberg commented on August 12, 2024

I pushed a new version that incorporates the correct construction of the SecureString, could you please update using the same command I previously sent?

from piconnect.

gygabyte017 avatar gygabyte017 commented on August 12, 2024

It works great! I tested with both AuthenticationModes and different domains/credentials, it works in every test.

I believe the issue is solved and can be committed to master, if you agree this can be closed.

Thank you again,
Regards

from piconnect.

Hugovdberg avatar Hugovdberg commented on August 12, 2024

Great to hear that! I will include it in the development release for now, it will trickle into master in the next release.

from piconnect.

panshu77 avatar panshu77 commented on August 12, 2024

thanks for adding this new function. Just wonder when the new release with this function will come out. And if not soon, is the test version still available? thanks.

from piconnect.

fouadsel88 avatar fouadsel88 commented on August 12, 2024

Thank you for fixing that, is the new release coming soon? I am getting the same issue and I would like to use AuthenticationMode.WINDOWS_AUTHENTICATION to my script.

from piconnect.

Hugovdberg avatar Hugovdberg commented on August 12, 2024

you can always install from the github development branch, but I'll try to make a new release soon.

To install the latest developments you can install using: pip install --upgrade git+https://github.com/Hugovdberg/PIconnect@develop

from piconnect.

mhernandez1005 avatar mhernandez1005 commented on August 12, 2024

Hello, is it possible to connect to PI database over VPN? I receive PIAuthenticationException when trying to connect to pi database. The PIconnect version is 0.9.1, with the updated secure string. Thank you,

from piconnect.

Hugovdberg avatar Hugovdberg commented on August 12, 2024

Can you connect using official PI software over that VPN? If the SDK supports it, it should be possible using PIconnect as well, but I don't have a VPN to test with, nor a PI server that requires manual authentication. What is the exact error message you get?

from piconnect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.