SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    request.servervariables("logon_user") issues

    Heres my scenario. I'm trying to have the user's logon to the domain information stored into variables. Now I've been reading up on the request.servervariables("logon_user"), but am having troubles getting it to work. All I want is whoever is logged on the machine to be stored into a variable on my page. Any suggestions, ideas, or complaints?? Thanks in advance!

  2. #2
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this over a LAN? Your problem is this. Unless you have your website set up to use NT challenge/response to make people log in to your site then they don't pass on their username to your server, and thus logon_user remains null.

    This works over our Intranet (we tried it), but I don't know if it would work over the Internet:

    Q: I have that all straightened out and it still doesn't work unless the users type in their domain!

    A: This happens a lot in a master domain model, where the user accounts do not reside in the same NT domain as the web server. You can fix this easily.

    Under IIS 3.0: Open regedit. Under "HKEY_LOCAL_MACHINE\System\Current Control Set\Services\W3SVC\Parameters", add a string value called 'DefaultLogonDomain'. Set its value to the name of the domain you'd like to authenticate against. Stop restart the Web Publishing service.

    Under IIS 4.0: You can change this in the management console. I'll try to remember where for version 1.1 of this file.
    We're actually running IIS 4.0 and it worked anyway when we followed the IIS 3.0 instructions!

    G

  3. #3
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Actually this is running on a intranet. Ill try that out, thanks

  4. #4
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's actually a brilliant way to authenticate users over an intranet when you have a decent NT network set up. We use this function:

    Code:
    Function fnUserName()
     Dim varPos, strRemoteUser
     strRemoteUser = Request.ServerVariables("REMOTE_USER")
     If strRemoteUser > "" Then
      varPos = InStr(strRemoteUser,"\") + 1
      fnUserName = Mid(strRemoteUser,varPos)
     Else
      fnUserName = "User name not known"
     End If
    End Function
    Pulls out the annoying DOMAIN\username that always gets returned.

  5. #5
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    and this is used in conjunction with the regedit hack you showed me?

  6. #6
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PERFECTO!!! YOU RULE! Thanks alot, worked really well!

  7. #7
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep. So for example, now on our intranet server I have a users table and a login script. When you log in the script checks your NT username from that function, then checks it againts the NT usernames that I have in a database along with your levels of access.

    Then I just write a couple of values to the session to confirm that that individual is logged in and their level of access as pulled from the dB. Then just use a simple SSI to check at the top of each page if the person calling that page is authorised to do so. Cool, huh?


  8. #8
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This is actually a extremely useful tool, now I don't have to create user accounts in the database anymore, I can just go off of their login names that they already use. Very useful. Thanks! Got any other useful secrets your holding out on??

  9. #9
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hmmm worked the first time, now I'm pulling back "user name not know" Any ideas why it only worked once?

  10. #10
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    No one asked before .....

    I've a few.

  11. #11
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmmmmmmm. No. It always works for me, but then I only call it once, write the session variable and then I don't need it any more .... that's a new one on me.


  12. #12
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hmmmm this is my luck, works perfectly first time then dies. Still no luck. I tried logging off and then back on, with no luck.

  13. #13
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just been checking it out on our servers and it's fine -- exactly what I posted ...... have you tried bouncing the web server? It could be IIS messing up.

  14. #14
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'm actually testing off of my local host. Could possibly have something to do with it, let me move this over the our server and test it


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •