WSL 可以继承 Windows 身份验证凭据吗 [英] Can WSL inherit windows auth credentials

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

问题描述

我在专门的 Windows 环境中使用 WSL,因为有许多工具仅适用于 Linux.我经常以编程方式连接到数据库,并且希望能够在不指定我的登录信息的情况下做到这一点.例如在 Python 中通过 Windows 我可以这样做:

导入pymssqlcon = pymssql.connect(服务器,端口)

该连接无需我指定任何凭据即可完成,因为我的 AD 帐户可以访问服务器,而 pymssql 在未指定凭据时将使用 Windows 身份验证.

在 WSL 上运行的 python 但是这不起作用,因此要建立相同的连接,我必须另外传递 userpassword 参数.>

有什么办法可以让WSL在运行Linux进程时继承windows认证?

解决方案

I got you Fam!

这是解决方案:http://michaeljw.com/blog/post/keyring-r-python-windows/

这是酱汁:

  1. 使用 Windows 凭据管理器存储您要使用的凭据

https:///support.microsoft.com/en-us/windows/accessing-credential-manager-1b5c916a-6a16-889f-8581-fc16e8165ac0

  1. 这是在 Python 中访问凭证管理器的命令:


keyring.get_password(u"[域或 URI]", u"[用户名]")


只要用户在信用管理器中,您就应该能够使用该命令来改变信用.您可能需要稍微尝试一下才能让它正确,但它会起作用.请务必阅读链接的文章.

享受

I'm using WSL in an exclusively windows environment because of a number of tools that are only really available for Linux. I often connect to DBs programmatically and would like to be able to do that without specifying my login information. For example in Python through Windows I could do this:

import pymssql

con = pymssql.connect(server, port)

And that connection would go through without my having to specify any credentials because my AD account has access to the server, and pymssql will use windows auth when no credentials are specified.

In python running on WSL however that doesn't work, and so to make the same connection I would have to additionally pass the user and password parameters.

Is there any way to make WSL inherit windows authentication when running Linux processes?

解决方案

I got you Fam!

Here is the solution : http://michaeljw.com/blog/post/keyring-r-python-windows/

Here is the Sauce:

  1. Use the Windows Credential Manager to store the creds you want to use

https://support.microsoft.com/en-us/windows/accessing-credential-manager-1b5c916a-6a16-889f-8581-fc16e8165ac0

  1. Here is the command for accessing the credential manager in Python:


keyring.get_password(u"[Domain or URI]", u"[username]")


As long as the user is in the cred manager, you should be able to use that command to variablize creds. You will probably have to play with it a bit to get it right, but it will work. Be sure to read the linked articles.

Enjoy

这篇关于WSL 可以继承 Windows 身份验证凭据吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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