使用 AUTH=NTLM 针对 Exchange imap 服务器验证 imaplib.IMAP4_SSL

发布于 2024-08-14 03:36:43 字数 866 浏览 3 评论 0原文

昨天,IT部门对Exchange服务器进行了更改。我以前可以使用 imaplib 从服务器获取消息。但现在看来他们已经关闭了我正在使用的身份验证机制。从下面的输出来看,服务器现在似乎仅支持 NTLM 身份验证。

>>> from imaplib import IMAP4_SSL
>>> s = IMAP4_SSL("my.imap.server")
>>> s.capabilities
('IMAP4', 'IMAP4REV1', 'IDLE', 'LOGIN-REFERRALS', 'MAILBOX-REFERRALS', 
'NAMESPACE', 'LITERAL+', 'UIDPLUS', 'CHILDREN', 'AUTH=NTLM')
>>> s.login("username", "password")
...
imaplib.error: Clear text passwords have been disabled for this protocol.

问题:

  1. 如何使用 NTLM 和 imaplib 对 imap 服务器进行身份验证?我假设我需要使用 IMAP4_SSL.authenticate("NTLM", authobject) 来执行此操作?如何设置 authobject 回调。
  2. 由于 SSL/TLS 是连接到服务器的唯一方式,因此重新启用明文密码身份验证不应构成安全风险。正确的?

顺便说一句,连接到 imap 服务器的进程正在 Linux 上运行。所以我无法使用 pywin32。

编辑:

我自己能够弄清楚1.。但是 2.:通过 SSL 的 IMAP 中的明文密码不是安全问题,不是吗?

Yesterday, the IT department made changes to the Exchange server. I was previously able to use imaplib to fetch messages from the server. But now it seems they have turned off the authentication mechanism I was using. From the output below, it looks as if the server now supports NTLM authentication only.

>>> from imaplib import IMAP4_SSL
>>> s = IMAP4_SSL("my.imap.server")
>>> s.capabilities
('IMAP4', 'IMAP4REV1', 'IDLE', 'LOGIN-REFERRALS', 'MAILBOX-REFERRALS', 
'NAMESPACE', 'LITERAL+', 'UIDPLUS', 'CHILDREN', 'AUTH=NTLM')
>>> s.login("username", "password")
...
imaplib.error: Clear text passwords have been disabled for this protocol.

Questions:

  1. How do I authenticate to the imap server using NTLM with imaplib? I assume I have need to use IMAP4_SSL.authenticate("NTLM", authobject) to do this? How do I set up the authobject callback.
  2. Since SSL/TLS is the only way to connect to the server, re-enabling clear text password authentication should not be a security risk. Correct?

The process that connects to the imap server is running on Linux, BTW. So I am not able to use pywin32.

Edit:

I was able to figure out 1. myself. But how about 2.: Clear text passwords in IMAP over SSL is not a security problem, is it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听风念你 2024-08-21 03:36:43

我能够使用 python-ntlm 项目。

python-ntlm 实现 HTTP 的 NTLM 身份验证。通过扩展该项目,可以轻松为 IMAP 添加 NTLM 身份验证。

我提交了项目补丁以及我的添加内容。

I was able to use the python-ntlm project.

python-ntlm implements NTLM authentication for HTTP. It was easy to add NTLM authentication for IMAP by extending this project.

I submitted a patch for the project with my additions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文