Results 1 to 7 of 7

Thread: [RESOLVED] Get Logged On Username

  1. #1

    Thread Starter
    Addicted Member kzatu's Avatar
    Join Date
    Aug 2003
    Location
    Nevada
    Posts
    148

    Resolved [RESOLVED] Get Logged On Username

    I'm new to PHP and I am writing my first web development project with it. My project is something that will only be used on our Intranet by a few select members.

    Instead of being bothered with logon screens and passwords, I'd rather just get the username of the person who's logged into Windows and run that against the database.

    So my question is, how do I, or is it even possible to, get the username from the Windows session?
    Changes are not permanent, but change is. {Neil Peart}

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: Get Logged On Username

    I think this can be done, but it the server needs to be running IIS. As far as i remeber there is an option in IIS that allows you to change the permissions of the website and select an authentication method.

    However this only allows people within the LAN to access the site.

    check out
    http://www.microsoft.com/technet/pro....mspx?mfr=true
    for more info.

  3. #3

    Thread Starter
    Addicted Member kzatu's Avatar
    Join Date
    Aug 2003
    Location
    Nevada
    Posts
    148

    Re: Get Logged On Username

    Well as I said, it would be an Intranet only site. Thanks for the link but I was hoping I didn't have to do anything on that level. Deailing with kerberos, hashes, and such.

    I planned on having a table in mySQL database which listed the users who could have access to this site. If I was able to retrieve the plaintext username of the person who is logged onto the computer, I'd just crosscheck that with the SQL table. If the name matches, you may pass go.

    Something along the lines of this VB6 sample would work nicely. Can PHP do something like this?
    VB Code:
    1. Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
    2. (ByVal lpBuffer As String, nSize As Long) As Long
    Changes are not permanent, but change is. {Neil Peart}

  4. #4
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Get Logged On Username

    The registry probably stores the username of the logged in user. I did a quick google and this came up.


    HTH

  5. #5

    Thread Starter
    Addicted Member kzatu's Avatar
    Join Date
    Aug 2003
    Location
    Nevada
    Posts
    148

    Re: Get Logged On Username

    Interesting. %username% is a Windows environment variable. Any chance I can get access to these variables through PHP?
    Changes are not permanent, but change is. {Neil Peart}

  6. #6
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: Get Logged On Username

    Quote Originally Posted by kfcSmitty
    The registry probably stores the username of the logged in user. I did a quick google and this came up.


    HTH
    PHP cannot read the registry of the client machine.

    What i was thinking of was this, see image, not setting up hashes etc.
    Attached Images Attached Images  

  7. #7

    Thread Starter
    Addicted Member kzatu's Avatar
    Join Date
    Aug 2003
    Location
    Nevada
    Posts
    148

    Resolved Re: Get Logged On Username

    Sorry John, but I setup notifications for this thread and never received one for your last post. Huh. Since I never bothered checking this thread for a few days, I've moved on to another method; using sessions. If that fails me then I'll come back and try your idea using IIS. In the meantime I'll mark this thread as resolved.
    Changes are not permanent, but change is. {Neil Peart}

Posting Permissions

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



Click Here to Expand Forum to Full Width