Mega Code Archive

 
Categories / Php / User Management
 

Smb_auth

<? /* Example: $test = new smb_auth(); $test->host = "cannondale"; $test->smbclient = "/usr/bin/smbclient"; #default is "/usr/bin/smbclient" $test->username = "guest"; $test->password = "dontlook"; if($test->authenticate() != 0){ echo "Invalid Authentication"; }else{ echo "Authenticated"; } */ class smb_auth { var $host; var $username; var $password; var $smbclient = "/usr/bin/smbclient"; function smb_auth() { return 0; } function authenticate() { /* Make sure smbclient path is correct */ if(!is_executable($this->smbclient)){ die("Error: '$this->smbclient' invalid smbclient path"); } /* create the shell script */ $script = "$this->smbclient //$this->host/IPC$ $this->password " ."-U $this->username -c 'quit' > /dev/null 2>&1"; $stuff = system ($script,$result); return $result; } } ?> /* example */ <? include "smb_auth.php"; $test = new smb_auth(); $test->host = "cannondale"; $test->smbclient = "/usr/bin/smbclient"; $test->username = "guest"; $test->password = "dontlook"; if($test->authenticate() != 0){ echo "Invalid Authentication"; }else{ echo "Authenticated"; } ?>