ICS中的FTP SERVER如何设定工作目录及用户帐号? |
尚未結案
|
xmxth001
一般會員 發表:5 回覆:3 積分:1 註冊:2004-05-06 發送簡訊給我 |
|
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
{ This event handler is called when the FTP component needs to build a } { directory listing. You can just return without doing anything then the } { component will build the directory for you, based on the actual disk } { content. But you can also build your own directory listing with anything } { you like in it. Just create a stream with the required content. The } { example below construct a virtual directory when the user is on the } { C:\VIRTUAL subdirectory (use elsewhere in this sample program). } procedure TFtpServerForm.FtpServer1BuildDirectory( Sender : TObject; Client : TFtpCtrlSocket; var Directory : TFtpString; Detailed : Boolean); var Buf : String; begin if UpperCase(Client.Directory) <> 'C:\VIRTUAL\' then Exit; InfoMemo.Lines.Add('! VIRTUAL DIR'); Client.UserData := 1; { Remember we created a stream } if Assigned(Client.DataStream) then Client.DataStream.Destroy; { Prevent memory leaks } Client.DataStream := TMemoryStream.Create; if Detailed then { We need to format directory lines according to the Unix standard } Buf := '-rwxrwxrwx 1 ftp ftp 0 Apr 30 19:00 FORBIDEN' #13#10 '-rwxrwxrwx 1 ftp ftp 0 Apr 30 19:00 TEST' #13#10 'drwxrwxrwx 1 ftp ftp 0 Apr 30 19:00 SOME DIR' #13#10 else Buf := 'FORBIDEN' #13#10 'TEST' #13#10; Client.DataStream.Write(Buf[1], Length(Buf)); Client.DataStream.Seek(0, 0); end; |
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
procedure TFtpServerForm.FtpServer1Authenticate(Sender: TObject; Client: TFtpCtrlSocket; UserName, Password: TFtpString; var Authenticated: Boolean); begin { You should place here the code needed to authenticate the user. } { For example a text file with all permitted username/password. } { If the user can't be authenticated, just set Authenticated to } { false before returning. } { It is also the right place to setup Client.HomeDir } { If you need to store info about the client for later processing } { you can use Client.UserData to store a pointer to an object or } { a record with the needed info. } InfoMemo.Lines.Add('! ' Client.GetPeerAddr ' User ''' UserName ''' is authenticated'); if Password = 'bad' then Authenticated := FALSE; end; |
xmxth001
一般會員 發表:5 回覆:3 積分:1 註冊:2004-05-06 發送簡訊給我 |
This code is only for client response to change current FTP working directory. But How to set default working dir when FTP server is starting? As My testing the default dir is c:\ or c:\temp before client change directory. The 2nd code is OK for user authorization! Thanks.
|
robert1014
初階會員 發表:34 回覆:85 積分:43 註冊:2002-03-13 發送簡訊給我 |
|
xmxth001
一般會員 發表:5 回覆:3 積分:1 註冊:2004-05-06 發送簡訊給我 |
|
Ktop_Robot
站務副站長 發表:0 回覆:3511 積分:0 註冊:2007-04-17 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |