SASL-GSSAPI on windows fails during bind - python

I have tried below lined of code on RHEL it works so great. On Linux I just have to acquire the Kerberos ticket.
mport ldap
import ldap.sasl
conn=ldap.initialize('ldap://auto.test-auto.com',trace_level=2)
conn.set_option(ldap.OPT_PROTOCOL_VERSION, ldap.VERSION3)
conn.set_option(ldap.OPT_REFERRALS,0)
sasl = ldap.sasl.gssapi()
conn.sasl_interactive_bind_s('', sasl)
Then I copied same thing in to a windows 2k3 server where ActivePython-2.7","python-ldap-2.4.10", "openssl-0.9.8o","setup-sasl-1.5.27" are installed.
Traceback (most recent call last):
File "C:\susanta\test-sasl.py", line 10, in <module>
conn.sasl_interactive_bind_s('', sasl)
File "C:\Python27\lib\site-packages\ldap\ldapobject.py", line 229, in sasl_interactive_bind_s
return self._ldap_call(self._l.sasl_interactive_bind_s,who,auth,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls),sasl_flags)
File "C:\Python27\lib\site-packages\ldap\ldapobject.py", line 99, in _ldap_call
result = func(*args,**kwargs)
LOCAL_ERROR: {'desc': 'Local error'}
Could some one help me out?

Are you using Cyrus SASL as backend? If so, it compiled against MIT or Heimdal. You don't have access to the TGT. Search for registry key: session key tgt.
But Cyrus SASL is not really usable on Windows if you use GSS-API unless you try Kerberos for Windows.

Related

runtime error while using Pvporcupine sdk for Picovoice python

I m using pvporcupine python SDK for picovoice for hot word detection, while using the below code I'm getting runtime error
import pvporcupine
access_key = "[my_acces_key]" # AccessKey obtained from Picovoice Console (https://picovoice.ai/console/)
#access key is altered for security reason
handle = pvporcupine.create(access_key=access_key, keywords=['porcupine'])
here is the error stack trace
Traceback (most recent call last):
File "c:/Users/Pjan/saa2/actions/pic_again.py", line 5, in <module>
handle = pvporcupine.create(access_key=access_key, keywords=['porcupine'])
File "C:\Users\Pjan\.conda\envs\sam_env\lib\site-packages\pvporcupine\__init__.py", line 82, in create
sensitivities=sensitivities)
File "C:\Users\Pjan\.conda\envs\sam_env\lib\site-packages\pvporcupine\porcupine.py", line 158, in __init__
raise self._PICOVOICE_STATUS_TO_EXCEPTION[status]()
pvporcupine.porcupine.PorcupineRuntimeError
here is the official site for picovoice SDK for python
any help is highly appreciated!
Well I contacted the official repository of picovoice and here I mentioned them what clearly was going on.
So anyone still facing it , then here is the solution for such behaviour https://github.com/Picovoice/porcupine/issues/617
Thanks!

Logging into GCP SQL: How to Ensure PromptSession Is Imported or Otherwise Resolve

I am trying to use the Cloud Shell to update some user permissions. I am logging in using gcloud sql connect my-instance --user=root
gcloud sql connect my-instance
Whitelisting your IP for incoming connection for 5 minutes...done.
Connecting to database with SQL user [sqlserver].********************************************************************************
Python command will soon point to Python v3.7.3.
Python 2 will be sunsetting on January 1, 2020.
See http://https://www.python.org/doc/sunset-python-2/
Until then, you can continue using Python 2 at /usr/bin/python2, but soon
/usr/bin/python symlink will point to /usr/local/bin/python3.
To suppress this warning, create an empty ~/.cloudshell/no-python-warning file.
The command will automatically proceed in seconds or on any key.
********************************************************************************
> Password:
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/mssqlcli/main.py", line 117, in <module>
main()
File "/usr/local/lib/python2.7/dist-packages/mssqlcli/main.py", line 110, in main
run_cli_with(mssqlcli_options)
File "/usr/local/lib/python2.7/dist-packages/mssqlcli/main.py", line 43, in run_cli_with
from mssqlcli.mssql_cli import MssqlCli
File "/usr/local/lib/python2.7/dist-packages/mssqlcli/mssql_cli.py", line 18, in <module>
from prompt_toolkit.shortcuts import PromptSession, CompleteStyle
ImportError: cannot import name PromptSession
A) I have made the root user's password so insecure and easy there is no way I am mistyping it.
B) It is the third of January, so I really don't know what this Python version error is on about. I made the file but FYI ~/.cloudshell did not exist so I had to make it first. Even so, it just suppresses the version warning, the main error persists when I try to log in.
The documentation acknowledges there are a couple other login methods using glcoud beta sql connect, but that gets me another error
2020/01/04 18:38:41 Rlimits for file descriptors set to {&{8500 1048576}}
2020/01/04 18:38:41 invalid json file "/tmp/tmp.s38C662KKr/legacy_credentials/me#gmail.com/adc.json": open /tmp/tmp.s38C662KKr/legacy_credentials/me#gmail.com/adc.json: no such file or directory
ERROR: (gcloud.beta.sql.connect) Failed to start the Cloud SQL Proxy.
Same for alpha.
This is the first thing I have typed into Cloud Shell, so I can't imagine what could have broken PromptSession.
How can I resolve this error and log into SQL Server using Cloud Shell?
There most likely is an issue while attempting to connect from the Cloud Shell (I managed to connect from a Compute Engine instance with this command); possibly related to the Python run-time / environment variable. It has been reported here. Engineering is aware and are looking into it.

RuntimeError: ALBroker::createBroker

I need help in python. I tried to put this code in python shell:
from naoqi import ALProxy
tts = ALProxy("ALTextToSpeech", "127.0.0.1",9559)
tts.say("Hello, world!")
and I get this error:
Traceback (most recent call last):
File "C:/Users/USER/Desktop/say.py", line 2, in <module>
tts = ALProxy("ALTextToSpeech", "127.0.0.1",9559)
File "C:/Users/USER/Desktop\naoqi.py", line 227, in __init__
inaoqi.proxy.__init__(self, args[0], args[1], args[2])
File "C:\Python27\lib\site-packages\inaoqi.py", line 318, in __init__
this = _inaoqi.new_proxy(*args)
RuntimeError: ALBroker::createBroker
Cannot connect to tcp://127.0.0.1:9559
This order happen whether I use virtual robot or real, I use choregraphe 1.14.5 version and python version 2.7.13
The connection is almost never done to 127.0.0.1:9559:
If you're connecting to a real robot, you should replace 127.0.0.1 by it's IP address (or it's domain name, e.g. "nao.local", but may or may not work depending of your local network configuration; when it does work it's more convenient)
If you're connecting to Choregraphe's virtual robot, you should replace 9559 by the virtual robot's port, which you can find in Choregraphe's preferences, at the bottom of the "Virtual Robot" tab, as seen in this image.

win32.SetCommState with Pyserial in win10

Until recently I was happily using win7 + pythonX and pyserial.
Lately I upgraded to win10, now I have a problem running some python serial code which I had working on win7.
However I can even run the simple example from: Full examples of using pySerial package
What I get is the same error, on all pyserial related codes:
Traceback (most recent call last):
File ".\t.py", line 10, in
bytesize=serial.SEVENBITS
File "C:\Python37\lib\site-packages\serial\serialwin32.py", line 31, in init
super(Serial, self).init(*args, **kwargs)
File "C:\Python37\lib\site-packages\serial\serialutil.py", line 240, in init
self.open()
File "C:\Python37\lib\site-packages\serial\serialwin32.py", line 78, in open
self._reconfigure_port()
File "C:\Python37\lib\site-packages\serial\serialwin32.py", line 222, in _reconfigure_port
'Original message: {!r}'.format(ctypes.WinError()))
serial.serialutil.SerialException: Cannot configure port, something went wrong. Original message: OSError(22, 'The parameter is incorrect.', None, 87)
however I found out that the reason for this is the exception raised by a call "win32.SetCommState(self._port_handle, ctypes.byref(comDCB)):" from serialwin32.py
This call returns 0, indicating something is wrong, but when i comment it out then I can get the serial communication working again, anyone else experienced this ? any idea why this is happening ?

How do I connect to a Netcool / Omnibus "Object Server" using Python?

I'm trying to connect to a Netcool 7.1 Object Server using Python, but I'm running into issues. It seems to be a Sybase type database, but stripped down. I'm using the Sybase module and freetds, but I get the following error when I try to connect:
Traceback (most recent call last):
File "netcool.py", line 12, in <module>
db = Sybase.connect('foo','foo','foo','foo')
File "/usr/lib64/python2.6/site-packages/Sybase.py", line 1194, in connect
datetime, bulkcopy, locale, inputmap, outputmap)
File "/usr/lib64/python2.6/site-packages/Sybase.py", line 850, in __init__
self.connect()
File "/usr/lib64/python2.6/site-packages/Sybase.py", line 898, in connect
status = conn.ct_options(CS_SET, CS_OPT_CHAINXACTS, not self.auto_commit)
File "/usr/lib64/python2.6/site-packages/Sybase.py", line 272, in _servermsg_cb
raise DatabaseError(msg)
Sybase.DatabaseError: Msg 17001, Level 10
No SRV_OPTION handler installed.
Has anyone successfully connected to a Netcool Object Server using Python? Is there any way I can edit the Sybase module to make it work? Worst case scenario, would it be possible to write something that communicates with the nco_sql client? I want the ability to read and write to the DB.
Any help or info would be greatly appreciated.
Eventually I figured this out on my own. If you use the SAP Sybase JDBC drivers (jconn4.jar) in conjunction with the JayDeBeApi module, you can successfully connect and read/write to the object server. This is the only Python solution I could find that works. If anyone else has an different method, feel free to share.

Categories