4.2 Disconnecting a Particular User Connection
This example illustrates the use of the RPC methods defined in this specification to enumerate a connection on the RRAS server. This example shows a Windows Server 2008 operating system server when 10 remote access connections are active and one of the clients (foo) has connected from a multilink (2-port) machine that is compliant with the polices on the server [MS-RNAP]. The connection of foo is enumerated and all the ports (2) of that connection are disconnected.
The client calls the RPC method RRasAdminConnectionEnum (section 3.1.4.2) with the following parameters:
The DIM_HANDLE (section 2.2.1.1.6) that the client obtains during initialization (section 3.1.3).
The level of information required. In this example, the RRAS server supports level 3.<354>
The pointer to DIM_INFORMATION_CONTAINER (section 2.2.1.2.1) (pInfoStruct) that the RRAS server uses to pass the information.
The dwPreferedMaximumLength is set to -1, so that the buffer returned is large enough to hold all available information.
The lpdwResumeHandle parameter is zero (0) because this is the first call.
When the client calls the RPC method as previously described, the RRAS server returns ERROR_SUCCESS. Additionally, the following parameter values are updated:
The dwBufferSize in the pointer to DIM_INFORMATION_CONTAINER (pInfoStruct) will contain the size of information being passed; in this case, it will be 10 times the size of RASI_CONNECTION_3 (section 2.2.1.2.80).
The lpdwEntriesRead and lpdwTotalEntries will point to DWORD, which has a value of 10.
The pBuffer in the pointer to DIM_INFORMATION_CONTAINER (pInfoStruct) will contain a pointer to a 10-element array of RASI_CONNECTION_3.
The dwVersion in RASI_CONNECTION_3 will be 1.
The dwSize in each instance of RASI_CONNECTION_3 will be the size of RASI_CONNECTION_3 in bytes.
The dwConnection in RASI_CONNECTION_3 will be a unique handle to identify the connection.
The wszUserName in one of the 10 instances of RASI_CONNECTION_3 will be "foo".
The dwInterfaceType in RASI_CONNECTION_3 will be ROUTER_IF_TYPE_CLIENT.
The guid in RASI_CONNECTION_3 will be a unique GUID to identify a connection.
The PppInfo3 RASI_CONNECTION_3 will contain the PPP information of the connection.
The rasQuarState in RASI_CONNECTION_3 will be RAS_QUAR_STATE_NORMAL because the client is healthy.
The timer in RASI_CONNECTION_3 will not be valid because the client is healthy.
The client then stores the dwConnection in RASI_CONNECTION_3, which has the wszUserName "foo" in a local variable hRasConnection.
The client frees the buffer pointed to by pBuffer.
The client calls the RPC method RRasAdminPortEnum (section 3.1.4.5) with the following parameters:
The DIM_HANDLE is the same handle that the client obtains earlier during initialization.
The dwLevel is set to 0.
The hRasConnection is the handle that the client obtained in dwConnection in RASI_CONNECTION_3 during the previous call RRasAdminConnectionEnum.
The pointer to DIM_INFORMATION_CONTAINER (pInfoStruct) that the RRAS servers uses to pass the information.
The dwPreferedMaximumLength is set to -1, so that the buffer returned is large enough to hold all available information.
The lpdwResumeHandle parameter is zero (0) because all the information required is present.
When the client calls the RPC method as previously described, the RRAS server returns ERROR_SUCCESS. Additionally, the following parameter values are updated:
The dwBufferSize in the pointer to DIM_INFORMATION_CONTAINER (pInfoStruct) will contain the size of information being passed; in this case, it will be the size of RASI_PORT_0 (section 2.2.1.2.75).
The pBuffer in the pointer to DIM_INFORMATION_CONTAINER (pInfoStruct) will contain a pointer to RASI_PORT_0.
The lpdwEntriesRead will point to a DWORD that contains 2.
The client stores the dwPort in each instance of RASI_PORT_0 into a local variable array hPort[2].
The client frees the buffer pointed to by pBuffer.
The client then calls the RPC method RRasAdminPortDisconnect (section 3.1.4.9) twice with the following parameters:
The DIM_HANDLE is the same handle that the client obtains earlier during initialization.
The hPort[n] handle is obtained previously by calling RRasAdminPortEnum (n= 0,1).
When the client calls the RPC method as described in this section, the method returns ERROR_SUCCESS, and the user connection is disconnected.