How to get windows user id in web2py for intranet application?

I use web2py for the intranet site and should get the current user ID of the login window on the controller. Is any feature available?

+4
source share
3 answers

You need to install the NTLM authentication module on your web server, for example mod_sspi or mod_ntlm, and then check the request REMOTE_USER environment variable. Here is something similar in Django: http://brandonkonkle.com/blog/2008/sep/13/django-apache-and-mod_auth_sspi/

+4
source

If you mean that you need a code on the server to find out the window identifier of the current browser user, web2py will not be able to say so. Windows authentication has nothing to do with web protocols.

+1
source

I don't know if this works, but try the psutil module, which should work on both Windows and Unix.

import os, psutil ownPid = os.getpid() #This one works in Windows, but os.getuid() does not... ownUid = [p.uid for p in psutil.process_iter() if p.pid == ownPid][0] 
0
source

All Articles