呼呼,具体可以参考 Serv-U 帮助 Add-on DLLs Overview
Serv-U can use an external DLL to verify client access and retrieve information such as a client's home directory etc. If one of more external DLLs are specified and Serv-U cannot find the appropriate information internally it will question each of the external DLL's in turn. This can be used to create an interface to external user databases, which can then control FTP server access. With the appropriate DLL, for example the NT build-in user database could be used, or a Novell user database.
Setup
To make Serv-U use external DLLs for client access verification the DLL names need to be added to the ServUDaemon.ini file. There is currently no interactive user setup to do this, so the INI file has to be edited directly with a text editor such as NotePad. There can be more than one DLL, and Serv-U will query them in the order specified until one of the DLLs signals that it had the required information.
The DLL names need to be added to a section named '[EXTERNAL]'. The format is as follows (using made-up DLL names):
[EXTERNAL]
ClientCheckDLL1=CHKNOVELL.DLL
ClientCheckDLL2=CHKNT.DLL
.
.
The file names can be either full path names, or file names only. If the full path is specified then Serv-U will look at that path only. If a file name is given with path information Serv-U will first look in the program directory, then the current directory, the entire PATH, and finally in the Windows directories.
DLL Specifications
Upon startup Serv-U looks for DLLs in the 慬EXTERNAL]?section of the ServUDaemon.ini file and tries to bind to a specific function in the DLLs. The DLL entry point for Serv-U needs to be the following function:
int __cdecl HandleClientEvent(RClientEventStr* pEventStruc)
Please note that the function name is case sensitive and uses the "C" calling convention. This is defined as "generate underbars, case sensitive, push parameters right to left, calling function cleans stack". For the Borland line of C/C++ compilers (and those were used to create Serv-U) this is the default calling convention, or it can be specified explicitly by using the 慱_cdecl?keyword. For other compilers you may have to use a different keyword. Check your compiler抯 documentation for a matching type. Using the wrong calling convention will likely result in a program crash immediately during or after the first time Serv-U tries to call the HandleClientEvent() function.
The function should return TRUE (=1) if it handled the event and does not want it to be passed on to the next DLL. It should return FALSE (=0) in case it did not handle the event.
The RClientEventStr structure is defined as follows:
struct RClientEventStr {
int Event; // event code
int Flag; // flag, meaning depends on event
char User[40]; // user name
char Aux[512]; // auxiliary area, usage depends on event
char HostIP[16]; // server domain IP address
unsigned long SessionID; // unique session ID
int DomainID; // unique ID for the domain the client connected to
int DomainPort; // server domain port number the client connected to
}
The 'Event' code determines the nature of the request and can have the following values:
#define SRVU_LoginMesFile 1 // get login message file
#define SRVU_HomeDir 2 // get home dir
#define SRVU_Password 3 // verify password
#define SRVU_IPAccess 4 // verify IP access
#define SRVU_WriteFile 5 // verify write access
#define SRVU_ReadFile 6 // verify read access
#define SRVU_ModifyFile 7 // verify mod./del. file access
#define SRVU_ExecProg 8 // verify execute access
#define SRVU_ListDir 9 // verify dir listing access
#define SRVU_ChangeDir 10 // verify dir change access
#define SRVU_DeleteDir 11 // verify dir delete access
#define SRVU_CreateDir 12 // verify dir create access
#define SRVU_HideHidden 13 // get setting for 'hide hidden files'
#define SRVU_RelPaths 14 // get setting for 'relative paths'
#define SRVU_RatioType 15 // get setting for type of ratios
#define SRVU_RatioDown 16 // get setting for download ratio
#define SRVU_RatioUp 17 // get setting for upload ratio
#define SRVU_RatioCredit 18 // get/adjust ratio credit setting
#define SRVU_RatioFree 19 // verify if file is free for ratios
#define SRVU_QuotaEnable 20 // verify if disk quota is enabled
#define SRVU_QuotaChange 21 // change in disk quota
#define SRVU_QuotaMax 22 // maximum disk quota
#define SRVU_AlwaysLogin 23 // always allow login
#define SRVU_OneLoginPerIP 24 // allow one login per user/IP pair
#define SRVU_LogClientIP 25 // log client from this IP address
#define SRVU_SpeedLimit 26 // maximum transfer speed
#define SRVU_PassChange 27 // change user's password
#define SRVU_TimeOut 28 // get user time-out value
#define SRVU_MaxUsers 29 // max. no. of users for account
#define SRVU_PassChallenge 30 // get password challenge if needed
#define SRVU_Connect 31 // information only: client connected
#define SRVU_Close 32 // information only: client disconnected
#define SRVU_MaxLoginPerIP 33 // max. no. of logins from same IP for user
#define SRVU_VerifyPasswd 34 // verify old password before changing it
#define SRVU_AppendFile 35 // verify append file access
#define SRVU_SignOnMes 36 // get signon message file
#define SRVU_SignOffMes 37 // get signoff message file
#define SRVU_Maintenance 38 // switch to maintenance mode
#define SRVU_SessionTimeOut 39 // session time-out
#define SRVU_SecureOnly 40 // only allow login over secure connection
Be sure to read the section on access verification events before implementing a DLL!
Serv-U Help - Copyright ?1995-2003 Cat-Soft, All Rights Reserved