Windows 7 and DotRas

Aug 25, 2009 at 7:17 PM

Hi,

I have successfully created a program that uses DotRas to simply create VPN connections for users that have entered their credentials in a config file. After forgetting to actually put the credentials object into the Dial() method, this is now working perfectly! ;)

But, the problem is that HangUp() simply does not do anything. I have looked in the discussion forum to see if anyone had this problem yet, but unfortunatly not.

My code (copied from example) :

                System.Collections.ObjectModel.ReadOnlyCollection<RasConnection> connections = _rasDialer.GetActiveConnections();
                if (connections != null && connections.Count > 0)
                    foreach (RasConnection connection in connections)
                        if (connection.EntryName == this.vpnItem.Name)
                        {
                            RasConnectionStatus status = connection.GetConnectionStatus();
                            if (status != null)
                                if (connection.HangUp())
                                {
                                   _frmMain.Invoke(_frmMain.delegateAddString, new Object[] { "VPN Connection Terminated.", VPNprogram.Globals.LoggingTarget.Waitscreen});
                                }
                        }

Could this be going wrong, because I am using Windows 7 RTM?

Greetz!

Coordinator
Aug 25, 2009 at 7:28 PM

From what other users on here have told me, Windows 7 RTM requires the application to have the privileges elevated or the UAC disabled while the release candidates do not.

It sounds like Microsoft added the RAS stuff into the list of things the UAC manages.

Aug 25, 2009 at 7:51 PM

Jeff,

You're absolutely right. I have right-clicked my app, choose Run As Administrator and the HangUp() works. That's fine for know. Maybe their is some way to check for it to tell users that they have to start the program as Administrator.

Thanks!

Greetz

Sjoerd

Coordinator
Aug 25, 2009 at 8:13 PM

I do have plans to add that information into the SDK, however as for displaying any information back to the user about that, no. It's up to the application designer to change the privileges needed for their application to comply with the Microsoft security requirements for running high privilege applications. You can have the .NET framework elevate the privileges requested for your application for you, I just don't remember how off the top of my head. I believe it was somewhere in the app.config file...

The only thing I would consider doing is changing whatever exception (if any) is thrown by the assembly and switching it to a SecurityException with "Access is denied." as the error message.

Was an exception thrown by DotRas when you called the HangUp method when the privileges weren't elevated?

Aug 26, 2009 at 7:36 AM

Very strange. After running my tool just one time with Run As Administrator, it looks like Windows as remembered I want to do this. I can now use the HangUp() every single time, successfully. Even if I turn the UAC to the most annoying setting ;)

As I remembered the HangUP() did not threw an exception when I first went debugging before using the Rus As function.

 

Aug 26, 2009 at 10:39 PM

When you create the app as a full installer, you no longer have to run as administrator. only while testing your app you must do that, but when you release create a full install app all will work fine on win 7 without having to set as admin or even reducing the UAC.