Authentication
|
|
|
|
<html>
<body>
<h1>PHP SMB Authentication</h1>
<form method="POST">
<table>
<tr><td>Username:</td><td><input type="text" name="USER" size="12"></td></tr>
<tr><td>Password:</td><td><input type="password" name="PASS" size="12"></td></tr>
<tr><td> </td><td><input type="submit" value="submit" name="submit"></td></tr>
</table>
</form>
<p>
<?php
if ($REQUEST_METHOD=="POST") {
global $USER;
global $PASS;
###
# Be sure to create a file in the '$NETLOGONfolder' share (Usually //SERVER/NETLOGON/)
# of the SMB PDC named '$filename', containing only the word 'allow'.
#
# This script requires the installation of Samba, http://samba.sourceforge.net/
#
# Example terminal line executed using defaults below. The contents of the '$filename' should be returned, ie 'allow'
# /usr/local/samba/bin/smbclient "//SERVER/NETLOGON" -I 192.168.27.1 -d 0 -E -U administrator%****** -W "DOMAIN" -c "get proxyauth -"
###
# PDC Variables Below:-
$SambaPath="/usr/local/samba/";
$ServerNetBIOS="SERVER";
$NETLOGONfolder="NETLOGON";
$ServerIP="192.168.27.1";
$DomainName="DOMAIN";
$filename="phpauth";
# Execute at UNIX command line:-
$smbauth = exec($SambaPath."bin/smbclient "//".$ServerNetBIOS."/".$NETLOGONfolder."" -I ".$ServerIP." -d 0 -E -U ".$USER."%".$PASS." -W "".$DomainName."" -c "get ".$filename." -"");
# Check to see if 'allow' is returned:-
if ($smbauth=="allow" || $smbauth=="allown") {
echo "Username and Password Accepted!";
} else {
echo "Bad Username/Password!";
}
}
?> </p>
</body>
</html>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|