Python Forum
Get username - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Get username (/thread-22762.html)



Get username - ALFA - Nov-26-2019

Hi!
I have Flask app with CherryPy webserver. I need to do authentication using Active Directory. I can get user data from Active Directory but dont know how to get username(windows) from the user who launched my webapp. Are there any ways to get current user name(windows login)?


RE: Get username - DeaD_EyE - Nov-26-2019

The module os can help you.

deadeye@nexus ~ $ import os                                   
deadeye@nexus ~ $ os.getuid()                                 
1000
deadeye@nexus ~ $ os.getlogin()                               
'deadeye'
deadeye@nexus ~ $
Don't worry, it's not inside a Python REPL, it's XONSH.


RE: Get username - ALFA - Nov-26-2019

Module os and getpass do not work as I need.
when I use the specified module(os or getpass), it always returns the data of a user authorized on the server where my application is installed. I would like to receive the data of the user who opened my application on his computer in a browser