I have a flask app (using Python version 3.7) running on an Apache server (version 2.4), using mod_wsgi (version 4.6.4), and SQLAlchemy (1.2.11).
I am working on designing a logic where I want to get the name of the manager of the current user logged in on Windows:
(Using get pass module with getuser method).
My query:
get_manager_name = session.query(Table.employee_first_name + " " + Table.employee_last_name).filter(Table.employee_net_username == getpass.getuser()).all()
The above query works if I bypass Apache (using the development server that comes with Flask).
On the other hand, If I use Apache, then the query returns an empty list []
.
I debugged my code using logging module in Python (logging.debug(getpass.getuser()))
and found that getpass.getuser()
returns the name of the service account under which Apache is running on my end and not the username of the current user logged in.
So my question is what I need to do to get the username of the logged in user through Apache on Windows?
I found a similar question on the similar issue, but it was related to IIS: