views:

78

answers:

3

I'm using web2py for an intranet site and need to get current login windows user id in my controller. Whether any function is available?

+1  A: 

If you mean you need code at the server to know the windows id of the current browser user, web2py isn't going to be able to tell you that. Windows authentication has nothing to do with web protocols.

Ned Batchelder
A: 

I don't know if that works but try psutil module, which is supposed to 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]
macieksk
+2  A: 

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

nFreeze