pymssql Windows 身份验证 [英] pymssql windows authentication

查看:87
本文介绍了pymssql Windows 身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pymssql 模块用于支持 windows 身份验证.现在好像不行了.尽管在某些地方它仍然表明它应该起作用.我一直无法找到这个问题的明确答案,也没有解决方案.最相关的链接:

The pymssql module used to support windows authentication. Now it seems it does not. Though in some places it still shows that it should work. I have been unable to find a definitive answer to this problem, nor a solution. Most relevant link:

https://groups.google.com/forum/#!topic/pymssql/QDMLTGBNeU0

pymssql 1.0 支持它,因为它利用并依赖于MS 提供的 DLL,它是 SQL Server 客户端堆栈的一部分.这个stack 负责处理所有 NTLM 协商等.这意味着,除其他外,它是一个仅限 Windows 的解决方案.

pymssql 1.0 supported it because it made use of and depended on the MS-provided DLL which was part of the SQL Server client stack. This stack was in charge of handling all of the NTLM negotiation and such. This meant, among other things that it was a Windows-only solution.

我可以模拟多种网络环境,因此我尝试了许多不同的设置.我试图能够使用此脚本通过 Windows 身份验证连接到远程 MSSQL 服务器.这就是问题所在.

I can simulate many sorts of network environments so I have tried many different setups. I am trying to be able to use this script to connect to a remote MSSQL server using windows authentication. And this is the problem.

根据我的研究,包括上面的链接,有两种方法可以通过 pymssql 模块使用 windows 身份验证,应该可以工作.

According to my research, including the links above, there are two ways to use windows authentication with the pymssql module that are supposed to work.

第一种方法:使用当前用户凭据:

pymssql.connect(server='server') 
# credentials come from active windows session
# some research shows that a "trusted=True" keyword should be provided.

第二种方法:使用给定的用户凭据:

pymssql.connect(server='server', user=r'domain\user', password='pass') 
# credentials are given in code and somehow converted to a 
# windows authentication in the background
# some research shows that a "trusted=True" keyword should be provided.

使用 _mssql 模块也是如此.

The same goes for using the _mssql module.

注意:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆