From 87ce9aa5c17f763c821017d8157ad185d7ba72ce Mon Sep 17 00:00:00 2001 From: JinZY Date: Mon, 23 Aug 2021 17:11:33 +0800 Subject: [PATCH] Support PI User Authentication mode, in the case of when user name provided with empty password. --- PIconnect/PI.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/PIconnect/PI.py b/PIconnect/PI.py index 45faabc1..da01a1cd 100644 --- a/PIconnect/PI.py +++ b/PIconnect/PI.py @@ -79,10 +79,6 @@ def __init__( if server and server not in self.servers: message = 'Server "{server}" not found, using the default server.' warn(message=message.format(server=server), category=UserWarning) - if bool(username) != bool(password): - raise ValueError( - "When passing credentials both the username and password must be specified." - ) if domain and not username: raise ValueError( "A domain can only specified together with a username and password." @@ -92,8 +88,10 @@ def __init__( from System.Security import SecureString secure_pass = SecureString() - for c in password: - secure_pass.AppendChar(c) + + if password != None: + for c in password: + secure_pass.AppendChar(c) cred = [username, secure_pass] + ([domain] if domain else []) self._credentials = (NetworkCredential(*cred), int(authentication_mode)) else: