Re: how to locate the OS currently logged in user??
Did you look at the information attached to ticket 689 [1] ? This is about using the credentials provided by the webserver. Typical use case is having apache authenticate the user (eg via mod_ntlm, mod_auth_sspi or another authentication system), pass the username into the django app and use this info in django to authenticate (and authorise) the user. I am not sure this is what you are looking for, because I did not quite understand your explanations. Just giving you the pointer. Koen [1]: http://code.djangoproject.com/ticket/689 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: how to locate the OS currently logged in user??
2008/8/27 PeteDK <[EMAIL PROTECTED]>: > On 21 Aug., 16:25, "Guillaume Lederrey" <[EMAIL PROTECTED]> > wrote: >> 2008/8/21 PeteDK <[EMAIL PROTECTED]>: >> > On 21 Aug., 13:10, "Guillaume Lederrey" <[EMAIL PROTECTED]> >> > wrote: >> >> 2008/8/21 PeteDK <[EMAIL PROTECTED]>: >> >> I'm still not clear on how your user log into the server. Via SSH, >> >> HTTP Auth, other ? >> >> > Sorry i failed to answer your question. I must admit i don't know >> > exactly how the user logs in. I will try to get that information :-) >> >> I'm pretty sure we will be able to give you more meaningful answers >> with that piece of information ... ;-) > > I now have some new information. I now believe that what i need is the > visitors information. > > On another system on the same network(written in Perl) it is done this > way: > $loginbruger=uc($ENV{AUTHENTICATE_SAMACCOUNTNAME}); > > (loginbruger is danish for loginuser) > > can i do the same thing in python?? get the visitors username? Again, without understanding how the users log into the server, we can only guess ... SAMACCOUNTNAME makes me think about Windows (SAM = Security Account Manager), but that's just based on the name, and that name could well mean something else in your context. >From what I understand, the name is stored in an environment variable (but I dont know how it gets there). Usually, the environment of a process isnt changed from the outside after creation. And Django is a long running process, so it should not pick up users logging in after startup. But I can be completely wrong on that one ... Assuming I am wrong above, you should be able to access the same environment variable from python code with : import os loginbruger = os.environ['AUTHENTICATE_SAMACCOUNTNAME'] More infos on http://docs.python.org/lib/os-procinfo.html The real problem I see there is that if there is multiple users connected to the server, I dont see how the right user could be associated with an HTTP session ... Good luck, and please, try to get the info on how the login process works ! -- Jabber : [EMAIL PROTECTED] Skype : Guillaume.Lederrey Projects : * http://rwanda.ledcom.ch/ * http://trock.ch/ Others : * http://kiva.org/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: how to locate the OS currently logged in user??
On 21 Aug., 16:25, "Guillaume Lederrey" <[EMAIL PROTECTED]> wrote: > 2008/8/21 PeteDK <[EMAIL PROTECTED]>: > > > > > > > > > On 21 Aug., 13:10, "Guillaume Lederrey" <[EMAIL PROTECTED]> > > wrote: > >> 2008/8/21 PeteDK <[EMAIL PROTECTED]>: > > >> > The server is running Debian Linux and they are logging on to the > >> > server using the username and password stored in the active directory > >> > on one of the other servers. > > >> I'm still not clear on how your user log into the server. Via SSH, > >> HTTP Auth, other ? > > > Sorry i failed to answer your question. I must admit i don't know > > exactly how the user logs in. I will try to get that information :-) > > I'm pretty sure we will be able to give you more meaningful answers > with that piece of information ... ;-) > > MrG > > -- > Jabber : [EMAIL PROTECTED] > Skype : Guillaume.Lederrey > Projects : > *http://rwanda.ledcom.ch/ > *http://trock.ch/ > Others : > *http://kiva.org/ I now have some new information. I now believe that what i need is the visitors information. On another system on the same network(written in Perl) it is done this way: $loginbruger=uc($ENV{AUTHENTICATE_SAMACCOUNTNAME}); (loginbruger is danish for loginuser) can i do the same thing in python?? get the visitors username? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: how to locate the OS currently logged in user??
2008/8/21 PeteDK <[EMAIL PROTECTED]>: > > > > On 21 Aug., 13:10, "Guillaume Lederrey" <[EMAIL PROTECTED]> > wrote: >> 2008/8/21 PeteDK <[EMAIL PROTECTED]>: >> >> >> >> > The server is running Debian Linux and they are logging on to the >> > server using the username and password stored in the active directory >> > on one of the other servers. >> >> I'm still not clear on how your user log into the server. Via SSH, >> HTTP Auth, other ? > > Sorry i failed to answer your question. I must admit i don't know > exactly how the user logs in. I will try to get that information :-) I'm pretty sure we will be able to give you more meaningful answers with that piece of information ... ;-) MrG -- Jabber : [EMAIL PROTECTED] Skype : Guillaume.Lederrey Projects : * http://rwanda.ledcom.ch/ * http://trock.ch/ Others : * http://kiva.org/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: how to locate the OS currently logged in user??
On 21 Aug., 13:10, "Guillaume Lederrey" <[EMAIL PROTECTED]> wrote: > 2008/8/21 PeteDK <[EMAIL PROTECTED]>: > > > > > The server is running Debian Linux and they are logging on to the > > server using the username and password stored in the active directory > > on one of the other servers. > > I'm still not clear on how your user log into the server. Via SSH, > HTTP Auth, other ? > > -- > Jabber : [EMAIL PROTECTED] > Skype : Guillaume.Lederrey > Projects : > *http://rwanda.ledcom.ch/ > *http://trock.ch/ > Others : > *http://kiva.org/ Sorry i failed to answer your question. I must admit i don't know exactly how the user logs in. I will try to get that information :-) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: how to locate the OS currently logged in user??
On 21 Aug., 13:44, "Emily Rodgers" <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: django-users@googlegroups.com > > [mailto:[EMAIL PROTECTED] On Behalf Of PeteDK > > Sent: 21 August 2008 11:14 > > To: Django users > > Subject: Re: how to locate the OS currently logged in user?? > > > > 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 > > > Hey. I haven't had a chance of testing it yet but it sounds > > like your method is the one i am looking for :) The thing is, > > i am not very good with server stuff (i am sure you have > > figured this out already) ;-) But as i wrote in my last post. > > The user logs onto the server using the username and password > > stored in the active directory. This is required before they > > can access anything on the server. > > > After they pass the login they are redirected to my django > > app, where i would like to avoid having them to log in again. > > so all i really need is the username of the user logging in > > to the server, so that i can (in the background) log them in > > to the django app. > > > When it comes to the admin part of my django app they will > > have to use a separate username and password. This is not a > > problem however since this will be 2 or 3 users at the most. > > > I hope this made it more clear? :-) > > > but Emily?? > > Do you think your method will work on debian linux, and do i > > need to import something extra in order to get it to work? > > I am not very technical either, so I am not entirely sure, but it doesn't > sound like an OS thing, it sounds like a webserver configuration thing. If > you have used PHP with apache before it is lke doing > $_SERVER['REMOTE_USER']. > > When you say "The user logs onto the server", do you mean that users point > their browser at a url and a username / password box pops up saying > something like "A user name and password are being requested > byhttp://blah.com.;? > > If the box is set up so that you have to authenticate to view the web pages, > then I would imagine it will work. The webserver will know who the remote > user is because they have authenticated (otherwise they would not be allowed > on), so it is just a matter of accessing this, and the data will be > somewhere in the request object. It is just a matter of finding it. > > I think what I did to figure out how to get the user, was something like > logging.debug(vars(request.META)) (in my view), got a couple of people in my > office a link to my webapp, and hunted around from there. > > To use logging.debug you need to do this: > > import logging > logging.basicConfig( > level = logging.DEBUG, > format = '%(asctime)s %(levelname)s %(message)s', > ) > > If you are still stuck it is worth asking the person who set up the web > server to give you more details about it, and find out how the django server > is started (and let us know). > > Em :) Thank you :-) I can't try it out monday, but if it doesn't work i will let you all know :-) thanks again!! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
RE: how to locate the OS currently logged in user??
> -Original Message- > From: django-users@googlegroups.com > [mailto:[EMAIL PROTECTED] On Behalf Of PeteDK > Sent: 21 August 2008 11:14 > To: Django users > Subject: Re: how to locate the OS currently logged in user?? > > > > 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 > > Hey. I haven't had a chance of testing it yet but it sounds > like your method is the one i am looking for :) The thing is, > i am not very good with server stuff (i am sure you have > figured this out already) ;-) But as i wrote in my last post. > The user logs onto the server using the username and password > stored in the active directory. This is required before they > can access anything on the server. > > After they pass the login they are redirected to my django > app, where i would like to avoid having them to log in again. > so all i really need is the username of the user logging in > to the server, so that i can (in the background) log them in > to the django app. > > When it comes to the admin part of my django app they will > have to use a separate username and password. This is not a > problem however since this will be 2 or 3 users at the most. > > I hope this made it more clear? :-) > > but Emily?? > Do you think your method will work on debian linux, and do i > need to import something extra in order to get it to work? I am not very technical either, so I am not entirely sure, but it doesn't sound like an OS thing, it sounds like a webserver configuration thing. If you have used PHP with apache before it is lke doing $_SERVER['REMOTE_USER']. When you say "The user logs onto the server", do you mean that users point their browser at a url and a username / password box pops up saying something like "A user name and password are being requested by http://blah.com.;? If the box is set up so that you have to authenticate to view the web pages, then I would imagine it will work. The webserver will know who the remote user is because they have authenticated (otherwise they would not be allowed on), so it is just a matter of accessing this, and the data will be somewhere in the request object. It is just a matter of finding it. I think what I did to figure out how to get the user, was something like logging.debug(vars(request.META)) (in my view), got a couple of people in my office a link to my webapp, and hunted around from there. To use logging.debug you need to do this: import logging logging.basicConfig( level = logging.DEBUG, format = '%(asctime)s %(levelname)s %(message)s', ) If you are still stuck it is worth asking the person who set up the web server to give you more details about it, and find out how the django server is started (and let us know). Em :) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: how to locate the OS currently logged in user??
2008/8/21 PeteDK <[EMAIL PROTECTED]>: > > The server is running Debian Linux and they are logging on to the > server using the username and password stored in the active directory > on one of the other servers. I'm still not clear on how your user log into the server. Via SSH, HTTP Auth, other ? -- Jabber : [EMAIL PROTECTED] Skype : Guillaume.Lederrey Projects : * http://rwanda.ledcom.ch/ * http://trock.ch/ Others : * http://kiva.org/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: how to locate the OS currently logged in user??
> 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 Hey. I haven't had a chance of testing it yet but it sounds like your method is the one i am looking for :) The thing is, i am not very good with server stuff (i am sure you have figured this out already) ;-) But as i wrote in my last post. The user logs onto the server using the username and password stored in the active directory. This is required before they can access anything on the server. After they pass the login they are redirected to my django app, where i would like to avoid having them to log in again. so all i really need is the username of the user logging in to the server, so that i can (in the background) log them in to the django app. When it comes to the admin part of my django app they will have to use a separate username and password. This is not a problem however since this will be 2 or 3 users at the most. I hope this made it more clear? :-) but Emily?? Do you think your method will work on debian linux, and do i need to import something extra in order to get it to work? thank you /Pete --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: how to locate the OS currently logged in user??
On 21 Aug., 01:59, "Garrett Garcia" <[EMAIL PROTECTED]> wrote: > On Wed, Aug 20, 2008 at 9:53 AM, PeteDK <[EMAIL PROTECTED]> wrote: > > > 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. > > What do you mean when you say "the server requires authentication"? How are > users accessing the server? Are they SSH-ing in or do you mean they are > accessing a different web site hosted on this server and are authenticating > through that? > > > > > 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? The server is running Debian Linux and they are logging on to the server using the username and password stored in the active directory on one of the other servers. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
RE: how to locate the OS currently logged in user??
> -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 -~--~~~~--~~--~--~---
Re: how to locate the OS currently logged in user??
On Wed, Aug 20, 2008 at 9:53 AM, PeteDK <[EMAIL PROTECTED]> wrote: > > > > 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. > What do you mean when you say "the server requires authentication"? How are users accessing the server? Are they SSH-ing in or do you mean they are accessing a different web site hosted on this server and are authenticating through that? > > 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? > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: how to locate the OS currently logged in user??
I assume you are using linux. But in windows it's like this import os os.environ ['USERPROFILE'].split('\\')[-1] James On Wed, Aug 20, 2008 at 9:53 AM, PeteDK <[EMAIL PROTECTED]> wrote: > > > > 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? > > > -- http://www.goldwatches.com/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
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? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
RE: how to locate the OS currently logged in user??
> -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)? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
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. You might want to examine the server environment for REMOTE_USER: if present, this should be the user name by which the user authenticated when they logged on to the client (which we are assuming is also the server). regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: how to locate the OS currently logged in user??
2008/8/20 PeteDK <[EMAIL PROTECTED]>: > I want to retreive the name of the currently logged in user on the OS > on which my django app lives. > Is this possible? You should realize that there is no direct connection between the user logged in the webserver and the user connecting via HTTP to your Django app. There is nothing preventing a user to connect to your Django app without logging to the server first ... > 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 what you seem to be looking for is a Single Sign On (SSO) solution. I dont know of any standard way to do that under Linux, but if you are using Windows, there is a standard mechanism for that. I think it is based on Kerberos and integrates with Active Directory. I'm far from a Windows expert, so dont ask me for the details, but I have been using this solution : * use IIS as a front proxy, IIS will do the authentication * IIS will forward the request to the backend server (in your case Django, running on Apache or even running on IIS) * the request is forwarded with additional HTTP headers describing the authentication (including the username) * you can then write a specialized authentication middleware that will use those headers to associate the session with the user > 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. > > Thanks! :) > > /Pete > > PS: and the webserver runs linux. :-) > > > -- Jabber : [EMAIL PROTECTED] Skype : Guillaume.Lederrey Projects : * http://rwanda.ledcom.ch/ * http://trock.ch/ Others : * http://kiva.org/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: how to locate the OS currently logged in user??
On 20 Aug., 15:14, Christian Joergensen <[EMAIL PROTECTED]> wrote: > 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? > > You are aware that on most systems, more than one user is allowed to > login concurrently? > I must admit. i didn't know that. :-( > > > 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. > > > PS: and the webserver runs linux. :-) > > This will give you a list of the currently logged in users: > > >>> import commands > >>> [line.split()[0] for line in > commands.getoutput("/usr/bin/who").split("\n")] > ['razor'] > > /Christian > > -- > Christian Joergensenhttp://www.technobabble.dk Thanks. it works great. Now do you know how this list is sorted? If it is sorted by time of login then it should be fine to just use the latest user in the list?? or is there some kind of problem here that i am not aware off? again, thanks! :-) eller mange tak:-) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
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? You are aware that on most systems, more than one user is allowed to login concurrently? [...] > 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. > > PS: and the webserver runs linux. :-) This will give you a list of the currently logged in users: >>> import commands >>> [line.split()[0] for line in commands.getoutput("/usr/bin/who").split("\n")] ['razor'] /Christian -- Christian Joergensen http://www.technobabble.dk --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---