Authenticating on a Windows domain with IIS

    Date: 11/14/05 (PHP Community)    Keywords: php

    Hey guys,

    I'm currently working on a corporate intranet, and I'd like to avoid having users enter two passwords in the morning when they log in. Is there any way to have the intranet authenticate the user based on their windows domain username?

    For the record, I'm using php5, and IIS6. The user machines here are a combination of windows flavours, ranging from WinME (only used for a print server -- I can ditch this for intranet access), Windows 2000 (most users), and Windows XP (myself).

    I've come across this script:

    /*
    Getting netbios info
    CopyLeft 2002 (GNU GPL V2) by polo
    */

    error_reporting(E_ALL);

    /* get the ip of the client */
    if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
        
    $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
    } else {
        
    $ip = $_SERVER["REMOTE_ADDR"];
    }
    echo
    'ip : '.$ip.'
    '
    ;

    /* send a "special" packet */
    $fp = fsockopen('udp://'.$ip, 137);
    fwrite($fp, "\x80b\0\0\0\1\0\0\0\0\0\0 CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\0\0!\0\1");

    /* wait 2 secs, and get the data */
    socket_set_timeout($fp, 2);
    $data = fread($fp, 256);

    /* get netbios records number */
    $nbrec = ord($data[56]);

    /* display nebios records : the username is a record of type 3 */
    echo '';
    echo
    '';
    for(
    $i = 0; $i < $nbrec; $i++) {
        
    $offset = 18 * $i;
        
    printf ("", $i, ord($data[72 + $offset]), trim(substr($data, 57 + $offset, 15)));
    }
    echo
    '
    notypevalueh>
    %02d%02X%sd>
    '
    ;
    ?>




    It works, but I'm stuck on how to use that in site (how do I identify that 03 entry which shows the windows username).

    ip : 192.168.49.15
    notypevalue
    0000COMPUTER_NAME
    0100SYDNEY
    0203NET_NAME_1
    0320COMPUTER_NAME
    041ESYDNEY
    0503MYLOGIN



    Any suggestions would be appreciated.

    Source: http://www.livejournal.com/community/php/367349.html

« Tripod websites || Request For Comments: PHP... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home