Python: get username for user to view?

Is there a way in Python / Django to get the username of the current Windows user from an application that does not work locally?

UPDATE: sorry to clarify, by this I mean the Windows username for the user viewing the web page, and not the user starting the server.

I tried both:

current_user = os.environ.get("USERNAME") current_user_getpass = getpass.getuser() 

But I think that they return the name of the user starting the server.

Thanks!

FURTHER UPDATE: I don't care about security. It doesn’t matter if users cheat on the username. What's the matter, it's convenience. I just need a way to get a username without having to tinker with passwords or install client software. Any ideas?

+4
source share
1 answer

Three ways, none of which work.

  • Use the identifier (AUTH) . It is technically cross-platform.

    ... except that for Windows there are exactly null name servers that can return a real username instead of a static string.

    Edit: Obviously, Retina Scan Identd can do this. (Tall.)

  • Require HTTP NTLM or Negotiate authentication. You get more than just checking your username,

    ... except for NTLM, it is unsafe, only Internet Exploder and Firefox support it, and they only use it on the local network (intranet) by default. Negotiate can use more secure Kerberos, but it (obviously) requires Kerberos both on the server and on the clients. If Windows PCs are in a domain, that’s good. If not...

  • If you control all client machines, you can use simple SSL client certificate authentication. It works in all modern browsers.

    ... but each user needs their own certificate. Creating an internal CA and issuing certificates is simple; their installation and operation in client machines is not so.

+2
source

Source: https://habr.com/ru/post/1341966/


All Articles