NetSessionDel (netapi32)
Last changed: -198.54.202.18

.
Summary
Deletes a network session. A better explanation would be that this api disconnects another computer which is connected to your computer. If the user is copying files then he/she will receive an error. This however does not stop the user from reconnecting.

MSDN Signature:

NET_API_STATUS NetSessionDel(

  LPWSTR servername,
  LPWSTR UncClientName,
  LPWSTR username

);

C# Signature:

    [DllImport("NetApi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
    internal static extern uint NetSessionDel(
         string servername,
         string UncClientName,
         string username);

VB Signature:

    ''' <summary>
    ''' The NetSessionDel function ends a network session between a server and a workstation.
    ''' </summary>
    ''' <param name="serverName">[in] Pointer to a string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is NULL, the local computer is used. </param>
    ''' <param name="UncClientName">[in] Pointer to a string that specifies the computer name of the client to disconnect. If UncClientName is NULL, then all the sessions of the user identified by the username parameter will be deleted on the server specified by servername.</param>
    ''' <param name="username">[in] Pointer to a string that specifies the name of the user whose session is to be terminated. If this parameter is NULL, all users' sessions from the client specified by the UncClientName parameter are to be terminated.</param>
    ''' <returns>If the function succeeds, the return value is NERR_Success. If the function fails, the return value can be one of the following error codes. ERROR_ACCESS_DENIED-The user does not have access to the requested information. ERROR_INVALID_PARAMETER-The specified parameter is invalid. ERROR_NOT_ENOUGH_MEMORY-Insufficient memory is available. NERR_ClientNameNotFound-A session does not exist with that computer name.</returns>
    ''' <remarks>Only members of the Administrators or Server Operators local group can successfully execute the NetSessionDel function.</remarks>
    <DllImport("netapi32.dll", SetLastError:=True)> Private Shared Function NetSessionDel(<MarshalAs(UnmanagedType.LPWStr)> ByVal serverName As String, <MarshalAs(UnmanagedType.LPWStr)> ByVal UncClientName As String, <MarshalAs(UnmanagedType.LPWStr)> ByVal username As String) As Integer
    End Function!!!!User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

I don't know about the LPWStr's, they might not need to be there.

Tips & Tricks:

Please add some!

Sample Code:

NetSessionDel(Nothing, Nothing, "USERNAMETODELETE")

Documentation