Comments (14)
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.
from piconnect.
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.
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.
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.
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.
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.
It works great! I tested with both AuthenticationMode
s 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.
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.
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.
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.
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.
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.
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)
- Question - how are servers discovered? HOT 2
- AttributeError: 'PIPoint' object has no attribute 'CurrentValue' HOT 1
- Open PI Connection without context manager HOT 3
- _time.to_af_time_range does not parse relative times correctly
- Search for attribute by providing entire Path as String in PIAF HOT 1
- Was able to connect for a while, until the server was migrated. HOT 4
- Create Point
- Get dataset from an event frame based on time period and choose attributes
- Search PI points by name and description using queries HOT 2
- Checking that status of Multiple PI Tag HOT 1
- Error when trying to fetch the highest value of the last 30 days
- PIData.py PISeriesContainer summary
- PIAuthenticationException
- Attribute Error: AFBufferOption, tried venv, also local download how fix? HOT 1
- Time Filtered Function as in Pidatalink
- Can not connect to PI server
- Connecting to All Known Data Archive and Asset Framework Servers on Import HOT 3
- Access PI Library Tables HOT 6
- recorded_values: exists a limit for output HOT 1
- duplicate name exists on network HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from piconnect.