public function testReaddirSuccess() { $state = smbclient_state_new(); smbclient_state_init($state, null, SMB_USER, SMB_PASS); $dir = smbclient_opendir($state, 'smb://' . SMB_HOST . '/' . SMB_SHARE); $smb = array(); while (($out = smbclient_readdir($state, $dir)) !== false) { $smb[] = $out['name']; } // Compare this with a copy we get through the filesystem: $local = scandir(SMB_LOCAL); // Sort both arrays to ensure equality: sort($smb); sort($local); $this->assertEquals($smb, $local); }
public function testOptionNTHash() { $state = smbclient_state_new(); if (smbclient_option_get($state, SMBCLIENT_OPT_USE_NT_HASH) === null) { smbclient_state_free($state); return; } smbclient_option_set($state, SMBCLIENT_OPT_USE_NT_HASH, true); // NTLM hash of 'password' generated at http://www.tobtu.com/lmntlm.php smbclient_state_init($state, null, SMB_USER, SMB_HASH); $dir = smbclient_opendir($state, 'smb://' . SMB_HOST . '/' . SMB_SHARE); while (($out = smbclient_readdir($state, $dir)) !== false) { } $this->assertTrue(is_resource($dir)); smbclient_closedir($state, $dir); smbclient_state_free($state); }
/** * @param resource $dir * @return array */ public function readdir($dir) { $result = @smbclient_readdir($this->state, $dir); $this->testResult($result, $dir); return $result; }