前篇簡單說明如何啟動WinCE上的FTPD功能,當然前提是必須在Platform Builder就已加入FTPD功能。但前所提的方式是以匿名方式存取WinCE FTPD,在獨立網域系統內這是最簡單便捷的方式,但若在開放網路環境下這方法就十分不保險,任何有心人士都能輕易找到這個匿名節點,所以至少要設專用的帳號密碼,以下說明如何讓WinCE FTPD具有登入特定帳號的功能。
Private Sub SetFTPD(byVal User as string, ByVal Password as string )
NTLMSetUserInfo(User , Password )
Dim strKeyName As String = "HKEY_LOCAL_MACHINE\Comm\FTPD"
Microsoft.Win32.Registry.SetValue(strKeyName, "AllowAnonymousUpload", 0)
Microsoft.Win32.Registry.SetValue(strKeyName, "AllowAnonymous", 0)
Microsoft.Win32.Registry.SetValue(strKeyName, "UseAuthentication",1)
Microsoft.Win32.Registry.SetValue(strKeyName, "IsEnabled", 1)
Microsoft.Win32.Registry.SetValue(strKeyName, "DefaultDir", "\")
Microsoft.Win32.Registry.SetValue(strKeyName, "UserList", User)
End Sub
首先在WinCE內創造一給FTPD專用的獨立帳號,在此WinCE是用NTLMSetUserInfo這個函數函數,其P/Inoke如下:
<DllImport("ntlmssp.dll")> _
Public Shared Function NTLMSetUserInfo(ByVal pszUser As String, ByVal pszPassword As String) As Boolean
End Function
之後再根據前篇文章的介紹,將Anonymous兩個權限關閉、認證和FTPD設定開啟狀態,並碼使用者清單(UserList)只設給該使用者即可。
留言列表