locked
Windows 2003 Server behavior after WNetCancelConnection2 RRS feed

  • Question

  • The program I'm working on uses the Windows API WNetAddConnection2 to connect to a Windows 2003 Server. Then after a file transfer operation, WNetCancelConnection2 is called to disconnect from the server.

    The problem is the user stays logged in even after the connection is cut. (The WNetCancelConnection2 returns with no error.) This is not what I want. How do I cancel the connection AND log off the user? Or is there any way to work around it if it's not programmatically possible?

    Friday, December 28, 2007 8:52 AM

All replies

  • I used the equivalent C# code for:

    result = WNetAddConnection2(netResource, password, user, CONNECT_TEMPORARY);  // connect with lpLocalName == null

    result = WNetCancelConnection2(connection.lpRemoteName, CONNECT_UPDATE_PROFILE, true);

    I have observed that WNetCancelConnection2 does not really close the connection. I used with and without CONNECT_UPDATE_PROFILE as well as with and without fForce set true with no error and no success.

    I have searched extensively and found many noting this problem with no solution.

    Tuesday, August 5, 2014 8:59 PM