sassoftware / saspy

A Python interface module to the SAS System. It works with Linux, Windows, and Mainframe SAS as well as with SAS in Viya.
https://sassoftware.github.io/saspy
Other
373 stars 150 forks source link

Cannot connect on Windows 10 Enterprise with local SAS 9.4 #465

Closed shriv closed 2 years ago

shriv commented 2 years ago

Describe the bug I've gone through a bunch of troubleshooting to connect to SAS via saspy in jupyter notebook and I get the error below. The different trouble-shooting I've done:

Any assistance would be greatly appreciated and happy to provide more info as needed! Many thanks in advance.

Java Error:
log4j:WARN No appenders could be found for logger (com.sas.services.connection).
log4j:WARN Please initialize the log4j system properly.
com.sas.services.connection.LoginException: The application could not log on to the server "localhost:0". Integrated Windows authentication failed.                                                                  
    at com.sas.services.connection.ClusterEnvelope.getConnection(ClusterEnvelope.java:121)
    at com.sas.services.connection.AggregationKernel.doGetConnection(AggregationKernel.java:242)
    at com.sas.services.connection.ConnectionFactoryKernel.getConnection(ConnectionFactoryKernel.java:325)
    at com.sas.services.connection.ConnectionFactoryShell.getConnection(ConnectionFactoryShell.java:69)
    at com.sas.services.connection.ConnectionFactoryShell.getConnection(ConnectionFactoryShell.java:51)
    at pyiom.saspy2j.main(saspy2j.java:201)
Caused by: org.omg.CORBA.NO_PERMISSION: Access denied.  vmcid: 0x0  minor code: 5  completed: No
    at com.sas.iom.orb.brg.Engine.parseErrorXML(Engine.java:2181)
    at com.sas.iom.orb.brg.Engine.checkForErrorPacket(Engine.java:2002)
    at com.sas.iom.orb.brg.Engine.readPacket(Engine.java:5782)
    at com.sas.iom.orb.brg.Engine.flowSendAuth(Engine.java:4291)
    at com.sas.iom.orb.brg.Engine.flow(Engine.java:713)
    at com.sas.iom.orb.brg.Engine.initClient(Engine.java:673)
    at com.sas.iom.orb.brg.ORBImpl.uri_to_object(ORBImpl.java:114)
    at com.sas.services.connection.ClusterEnvelope.createObject(ClusterEnvelope.java:293)
    at com.sas.services.connection.ClusterEnvelope.getConnection(ClusterEnvelope.java:78)
    ... 5 more
Caused by: com.sas.iom.SASIOMDefs.GenericError: Unexpected error in function AcceptSecurityContext.  Error -2146893044 (The logon attempt failed ).
    at com.sas.iom.orb.brg.Engine.parseErrorXML(Engine.java:2082)
    ... 13 more

Desktop (please complete the following information):

sascfg_personal

SAS_config_names=["winlocal"]

SAS_config_options = {
    "lock_down": False,
    "verbose"  : True
    }
# build out a local classpath variable to use below for Windows clients
cpW  =  "C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94410__prt__xx__sp0__1\\deploywiz\\sas.security.sspi.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94410__prt__xx__sp0__1\\deploywiz\\log4j.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94410__prt__xx__sp0__1\\deploywiz\\sas.core.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94410__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar"
cpW += ";C:\\Users\\<username>\\.conda\\envs\\saspython\\Lib\\site-packages\\saspy\\java\\saspyiom.jar"

winlocal = {
    "java"      : "java",
    "encoding"  : "windows-1252",
    "classpath" : cpW
    }

import os
os.environ["PATH"] += ";C:\\Program Files\\SASHome\\SASFoundation\\9.4\\core\\sasext"
tomweber-sas commented 2 years ago

So, the error you're getting is documented as number 6, here. I'm not sure what you mean by However, DLL is not in pathext so I'm not sure if this is a problem? Are you saying the sspiauth.dll file isn't in this directory; C:\Program Files\SASHome\SASFoundation\9.4\core\sasext? But you have a SAS 9 deployment on this machine in this location? The other thing is that you shouldn't code up the classpath, it's already provided by saspy, so I'm not sure if that might be contributing to any issue either. But the first error seems to have to do with the localhost setting, though the sspiauth.dll has to be found also - that error is number 3 in the above link and isn't what you're getting here. So this still sounds like the etc/host file and the definition of localhost, just going by the error.

shriv commented 2 years ago

Thanks for your response @tomweber-sas! Apologies I wasn't clearer earlier.

However, DLL is not in pathext I was referring to the note from this issue where there is an explicit point about having the DLL in the pathext variable. I don't have this. I only asked the sysadmin to add the path to the sspiauth.dll.

I made the change in the hosts file. Copied below and I realise that there is a setting of localhost made by docker for kubernetes. Could that be interfering?

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost
# Added by Docker Desktop
XXX.XX.XX.XX host.docker.internal
XXX.XX.XX.XX gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
# For SASPy
127.0.0.1 localhost <host-name>.<dns-suffix>
tomweber-sas commented 2 years ago

Yes, that is the problem, docker hijacking 127.0.0.1 and not having it associated with localhost. But, having those 2 lines won't fix it. Just change it to one line like the following: 127.0.0.1 localhost kubernetes.docker.internal That should fix it. I tried this same thing w/ my etc/host and saw the same errors for the different cases; just the docker line, docker line plus your extra line, then only one line with both aliases and that's the only one that works and didn't get the same error as you're getting.

tomweber-sas commented 2 years ago

Oh, and I see what you were referring to about the PATHEXT variable. I didn't recognize that, as that's not something you need to do. That was just something a user tried that didn't actually have anything to do with the problem. You don't need to do that. Thanks, Tom

shriv commented 2 years ago

Wonderful! Thanks so much for your help @tomweber-sas ..! I have made the change and got saspy connection working now! :-)