This project is read-only.

Change VPN phonebook entry (C#)

Mar 2, 2011 at 4:37 PM

I want to change the server address of a entry in the phonebook, this is what i already got:

RasPhoneBook book = new RasPhoneBook();
book.Open(true);
RasEntry foundEntry = null;
foreach (RasEntry entry in book.Entries)
{
	if (entry.Name == connectionName)
	{
		foundEntry = entry;
		break;
	}
}
if(foundEntry != null)
{
	foundEntry.PhoneNumber = "new server";
	
}

So i think the changed entry must be written back. But how?

Mar 2, 2011 at 4:49 PM
Edited Mar 2, 2011 at 4:49 PM

I found it (and i optimized my code a little bit):

RasPhoneBook book = new RasPhoneBook();
book.Open(true);

if (book.Entries.Contains(connectionName))
{
	wlog("Configuring PPTP connection");
	RasEntry foundEntry = book.Entries[connectionName];
	foundEntry.PhoneNumber = "new server";
	foundEntry.Update();
}
else
{
	//Create a new one
}