The rest of this article is the content of msdn. My own experiences are as follows:
- The prototype of the mpradmininitializedll function is defined as void in the built-in msdn of vs2003. If you follow this prototype, it will become ugly. The correct prototype is a DWORD type defined in online msdn (noerror indicates success)
- The user IP address provided by mpradminacceptnewconnection is actually a virtual IP address, rather than its real IP address. Therefore, it is of little use (you cannot determine whether the user is legal based on an IP address ).
- If you want to use mpradminserverconnect to obtain the RAS handle, you cannot call it in functions such as mpradmininitializedll. Because the RAS has not been successfully started yet, rpc_s_unknown_if will be returned, while calling in other events may lead to deadlocks, so, I started a thread in mpradmininitializedll and tried it every second until it was successfully obtained. Usually I will use the queueuserworkitem API to do this.
Ras refers to remote access service, while RAS Administration DLL refers to a dynamic link library written by the user. It implements the specified functions and is loaded by Ras, when a user is connected to or disconnected, Ras automatically calls these functions to enable additional requirements. For example, you can decide whether to allow a user to connect to the database, you can also specify the IP address (Virtual Network) for the user to record the log during the connection and disconnection: to let Ras know where the DLL we have compiled is, you must create a key named HKEY_LOCAL_MACHINE/software/Microsoft/RAS/admindll in the Registry, and then create two string values under the key:
Name |
Value |
Example |
Displayname |
Custom display name, which can be specified at will. |
No sound at the sound |
Dllpath |
The full name of the dll path. Multiple DLL names are separated by commas (,). However, Windows 2000 server does not support multiple DLL names. Currently, only 2003 is supported) |
C:/Foo/bar. dll |
Dll must at least implement and export the following four functions, otherwise the RAS startup will fail:
- Mpradminacceptnewlink
- Mpradmininitializedll
- Mpradminlinkhangupnotification
- Mpradminterminatedll
Usually, it will implement and export (or what will the DLL do ?) :
- Mpradminacceptnewconnection
- Mpradminconnectionhangupnotification
Or
- Mpradminacceptnewconnection2
- Mpradminconnectionhangupnotification2
In Windows 2000 Server, dll must also implement the mpradmingetipaddressforuser and mpradminreleaseipaddress functions.