> -----Original Message-----
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of PeteDK
> Sent: 20 August 2008 17:54
> To: Django users
> Subject: Re: how to locate the OS currently logged in user??
> 
> 
> 
> 
> On 20 Aug., 17:56, "Emily Rodgers" <[EMAIL PROTECTED]> wrote:
> > > -----Original Message-----
> > > From: django-users@googlegroups.com
> > > [mailto:[EMAIL PROTECTED] On Behalf Of Steve Holden
> > > Sent: 20 August 2008 16:37
> > > To: django-users@googlegroups.com
> > > Subject: Re: how to locate the OS currently logged in user??
> >
> > > PeteDK wrote:
> > > > Hi.
> >
> > > > I want to retreive the name of the currently logged in user
> > > on the OS
> > > > on which my django app lives.
> > > > Is this possible?
> >
> > > > The thing is. The app is to be used in a private
> > > environment, so all
> > > > the users have to log on to the webserver first(this cant
> > > be changed).
> > > > I would be nice to avoid having them to log into the django app 
> > > > afterwards.
> >
> > > > So after they are logged into the webserver it would be
> > > fair to assume
> > > > they are authorised users and if i could just locate their
> > > OS username
> > > > somehow then i could use this username to login the current
> > > user, in
> > > > the background with a standard password.
> >
> > > > I hope you get my meaning:)
> >
> > > > i have looked into the python standard library, and a 
> module named
> > > > getpass() however i cant get i to work:-(
> >
> > > > i hope someone has a clever idea to solve this problem.
> >
> > > You seem to be assuming that the server is always accessed from a 
> > > browser running on the same machine. You should guarantee this by 
> > > running Django only on the 127.0.0.1 interface. As has 
> already been 
> > > pointed out, they need not be the only user logged on, however.
> >
> > It does seem like a really odd thing to do. Are you sure you don't 
> > just want to find out the user viewing the webapp via a 
> browser (who 
> > has already authenticated in a system other than django)?
> 
> Well yeah that is what i want. I'm sorry if i haven't 
> explained myself well enough.
> The system works like this: The user follows a link to the django app.
> The app is stored on a server which requires authentication. 
> (This way the users can use the same password for the server 
> as they use on the rest of the system.) What i want is i want 
> to know the user who is trying to view the django app, so 
> that i can, in the background, log this user into the django 
> app. This way they dont have to have 2 separate user accounts 
> with 2 separate passwords.
> 
> So i dont need to know the users password, just the username. 
> Because then i can use this to find a corresponding username 
> in the django app and log the user in this way. i hope i made 
> it more clear :-)
> 
> But actually i think the first solution would work find:
> 
> namelist = [line.split()[0] for line in 
> commands.getoutput("/usr/bin/ who").split("\n")] 
> userLoggingIn = namelist[-1]
> 
> unless there can be problems with using the latest user entry 
> in the namelist?


Have you tested the suggestion above with someone who is not sshed into
the box, because if it is just the remote user of the app you want, you
really don't want to be doing '/usr/bin/ who' because that will return
the users sshed onto the box (and *not* the users logged into the web
app via your authentication system!).

I am basically doing what you are (authenticating against LDAP), and the
way you can access the remote user is request.META['AUTHENTICATE_UID'].
I am not even using the django auth.User stuff for basic web app usage
(since the user must be authenticated already, I just look to see who
they are), only for the admin stuff. Only a very small number of people
will be using the admin site so I am not to bothered about them having
to log in again (although if there is an easy way of passing credentials
across I could use that!).

HTH,
Emily



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to