Remove network connection

  • Thread starter Thread starter Jonas
  • Start date Start date
J

Jonas

I want to remove a remote access connection when a user logs out. The
connection is a dial up isdn adapter.

I can access the adapter via WMI namespace \root\microsoft\homenet, but i
don´t find any way to delete it.

Is it possible to do this or do i need to some pinvoke on rasapi32?
 
Hi,
I'm sorry that I am not sure if you want to close the connection or delete
an entry when a user logs out. Could you please lighten me more on your
issue?

Anyway, according to my experiences, RAS API is required on this issue and
the P/Invoke technology provides the appropriate way on .NET platform.

Firstly, you can use RasEnumConnections to emumerate all the available
active RAS connections handles on your system; Then use RasHangup to close
the connection by the handle.
If you wanted to delete the entry, please use RasEnumEntries to retrieve
the available entries, then use RasDeleteEntry to delete the entry.

For the RAS API references, please refer to:
Remote Access Service Functions
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rras/rras/r
as_start_page.asp

Please feel free to let me know if you need further research on this issue.
It's my pleasure to be of assistance.

Sincerely yours,
Charles Wang
Microsoft Online Community Support

======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 
Hi.

I want to delete the connection.

I will try with the RasDeleteEntry, do you know any way to accomplish this
via WMI?
 
Hi,
Thanks for your response.
Please forgive my confusion regarding your saying "delete the connection",
because generally we say that close a connection or disable a connection.
Did you mean that?

Unfortunately WMI is not designed to be able to disable a network
connection.
From this article,
https://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi
/wmi_tasks__networking.asp
we can see that:
If you're using DHCP, you can use the Win32_NetworkAdapterConfiguration and
the ReleaseDHCPLease method to release the IP address. If you are not using
DHCP, you cannot use WMI to disable a network connection.

If you have any other questions or concerns, please feel free to let me
know. It is my pleasure to be of assistance.

Charles Wang
Microsoft Online Community Support

======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 
Hi,

Appreciate your update and response. I am glad to hear that the problem has
been fixed. If you have any other questions or concerns, please do not
hesitate to contact us. It is always our pleasure to be of assistance.

Have a nice day!

Charles Wang
Microsoft Online Community Support

======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 
Back
Top