Commit 1cbc4570 by Chris Church Committed by Brian Coca

Only try kerberos auth when username contains `@` and pass realm to pywinrm.…

Only try kerberos auth when username contains `@` and pass realm to pywinrm. Alternative to #10644, fixes #10577.
parent baa6426c
...@@ -80,13 +80,18 @@ class Connection(object): ...@@ -80,13 +80,18 @@ class Connection(object):
netloc = '%s:%d' % (self.host, port) netloc = '%s:%d' % (self.host, port)
exc = None exc = None
for transport, scheme in self.transport_schemes['http' if port == 5985 else 'https']: for transport, scheme in self.transport_schemes['http' if port == 5985 else 'https']:
if transport == 'kerberos' and not HAVE_KERBEROS: if transport == 'kerberos' and (not HAVE_KERBEROS or not '@' in self.user):
continue continue
if transport == 'kerberos':
realm = self.user.split('@', 1)[1].strip() or None
else:
realm = None
endpoint = urlparse.urlunsplit((scheme, netloc, '/wsman', '', '')) endpoint = urlparse.urlunsplit((scheme, netloc, '/wsman', '', ''))
vvvv('WINRM CONNECT: transport=%s endpoint=%s' % (transport, endpoint), vvvv('WINRM CONNECT: transport=%s endpoint=%s' % (transport, endpoint),
host=self.host) host=self.host)
protocol = Protocol(endpoint, transport=transport, protocol = Protocol(endpoint, transport=transport,
username=self.user, password=self.password) username=self.user, password=self.password,
realm=realm)
try: try:
protocol.send_message('') protocol.send_message('')
return protocol return protocol
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment