django应用程序是否可以知道用户的Windows域名?

django应用程序是否可以知道用户的Windows域名?

问题描述:

我需要在公司内部网络中使用一个简单的知识库类型的应用程序。为了简化和快速地为最终用户使用我想跳过所有的登录部分(因为它将只对我们信任的内部网络用户可见),并自动从用户提取域用户名,并将它进入数据库(不希望人们浪费时间手动输入他们的名字;他们浪费使用应用程序的时间,他们实际使用的机会越高)。

I need to make a simple knowledge-base type application to use in company internal network. To make it simple and fast to use for end-users I would like to skip all the login in part (as it will be only visible to internal network users who we trust anyway) and automaticly pull the domain user name from the user and put it into the database (don't want people to waste time manually entering their name; the littler time they waste using the app, the higher chance they will actually use it).

那么,是否可以在服务器上获取这种信息? Windows浏览器会将其发送到一些可信任的头文件中吗?

So, is it possible to get that kind of information on a server? Do windows browsers send it in some headers that I could trust to be there?

如果您使用IIS和Internet Explorer,可以打开集成Windows身份验证(NTLM身份验证)。这导致IE自动使用您的域基础架构认证用户。自动登录后,您可以使用环境变量 LOGON_USER 访问用户名。此外,还有一个Apache(mod_ntlm)模块,尽管我不知道它的状态。

If you are using IIS and Internet Explorer, you could turn on 'Integrated Windows Authentication' (NTLM authentication). This causes IE to automatically authenticate the user using your domain infrastructure. After automatic login, you can access the user name using the environment variable LOGON_USER. There is also a module for Apache (mod_ntlm) for this purpose, although I don't know its status.

也许你可以事件尝试实现 NTLM身份验证,但这肯定会有很多工作。

Maybe you could event try to implement NTLM authentication yourself, but this will certainly be a lot of work.

除此之外,似乎没有办法,因为没有合理的浏览器将发送用户名...

Other than that, there seems to be no way since no reasonable browser will send the user name...

编辑:似乎 python-win32 extensions 或 python-ntlm 可以做的诀窍,查看这个线程。不过,您仍然必须将其整合到Django中。

It seems that python-win32 extensions or python-ntlm could do the trick, check out this thread. You still have to integrate it into Django, though.