This project is read-only.

'entry' must have the PhoneNumber...

Mar 25, 2013 at 10:41 AM
I get sometimes, not always, the following message:

'entry' must have the PhoneNumber, DeviceType, DeviceName, FramingProtocol, and EntryType properties set as minimum.

when updating an existent VPN-entry.
I'm only updating the following props:
  • RemoteDefaultGateway
  • IPv6RemoteDefaultGateway
  • VpnStrategy
Any ideas?

Mar 25, 2013 at 9:37 PM
Edited Mar 25, 2013 at 9:40 PM
Basically in order for an entry to work there is a few properties that absolutely must be set on the entry in order to guarantee it will be functional. That rule has been surfaced by that exception you're seeing thrown.

Regardless what it is you're changing, if those values are not present the exception gets thrown so they can be fixed. The only thing I can suggest would be to make sure the entries you're trying to save have those values present.

Edit: I wanted to add, RAS stores the remote VPN server (DNS name or IP address) in the PhoneNumber setting if you might be curious why you need to set a "phone number" on a VPN connection.
Mar 26, 2013 at 8:51 AM
To clarify, I understand what you say, but what is bothering me is the fact that the error does not always come - only sometimes. PS. I'm not creating a new Entry, I'm only configuring an existing one.

I already added the props asked by the message:
Using PhoneBook As New DotRas.RasPhoneBook
  With PhoneBook.Entries(VPNConnectionName)
    .Device = DotRas.RasDevice.GetDevices(0) ' 0 = WAN Miniport (IKEv2) Vpn 
    .EntryType = DotRas.RasEntryType.Vpn
    .PhoneNumber = ""
    .FramingProtocol = DotRas.RasFramingProtocol.Ppp
  End With
But then sometimes I got the following message during RasDial later:
651 – The modem (or other connecting device) has reported an error
So I removed the code above.

I also made a test on a Windows 8-PC, if I get the first error, I can start "Clear Cached Credentials" and then I get no error.

I understand that for a new entry I have to add this properties, but for an existing one - really necessary? Maybe an enhancement for you to be made? a bug?


Mar 26, 2013 at 2:44 PM
I understand you're not creating a new entry, but that still doesn't mean those values don't need to be present on the entry in order for it to work. From an API perspective, all I know is you're trying to save changes to an entry, new or existing it does not matter. It's been years since I put that in place, but if I recall RAS returns an error from the RasSetEntryProperties function indicating there isn't enough information on the entry. I just surfaced that error code as that check before saving the entry. It's also documented here on Microsoft's website. Simply put, that check isn't going anywhere.

Looking at the code you posted you're assuming that the device at index 0 returned from GetDevices is the WAN Miniport (IKEv2) VPN device, which that's a pretty big assumption to be making. Given that you're getting modem related errors from a VPN connection, it's probably setting the wrong device occasionally.
Mar 26, 2013 at 3:11 PM
And how can I find out what Device is being used in the existing entry?
Mar 26, 2013 at 4:05 PM
Edited Mar 26, 2013 at 4:08 PM
Well if it had a device set, it'd be on the Device property on the entry.

Edit: When you open a phone book, all of the entries within it are iterated and have all of their settings retrieved from Windows. So after open, all of the entries in the phonebook.Entries properties contain whatever information Windows has.
Mar 27, 2013 at 4:18 PM
So it seems that Windows doesn't always fill the Device property, sometimes yes, sometimes not.
Any ideas what could influence this behavior?
What API is used internaly to get this info?


Mar 27, 2013 at 7:28 PM
It really depends if a device is present or not on a system. I know we've seen in the past that if a modem is used for an entry and then removed from the system (from being unplugged, disabled, whatever) the entry will no longer have the information about that particular device. This isn't something that's missing from my API, the Win32 call simply doesn't return it. That's why the Create method was exposed a few years back on the RasDevice class, for situations like that. That method comes with warning though, you're essentially creating a device that may or may not be in the system. That problem surrounded modems primarily, not VPNs.

Based on your previous code sample, it would seem you're trying to use IKEv2 VPN support which I believe was introduced in Windows 7. Depending on what operating systems you're targeting that may or may not have something to do with the device not being found.

RasGetEntryProperties is the Win32 API call that retrieves all of the information about the entry when the phone book is being loaded.