This project is read-only.

Using stored credentials

Apr 14, 2009 at 5:33 AM
On the home page, the following comment is made about the Dial() method - "depending on how you store your credentials in the phone book, you may or may not have problems connecting using the stored credentials"

I'm wondering what options there are to store credentials?

I've got a machine where I have saved the username and password using the 'Me Only' option from the UI, but when I retrieve that entry I don't get back the password.

Is there a way to use the DotRas code to dial this entry and use the saved username and password?

Apr 14, 2009 at 5:50 AM
Edited Apr 14, 2009 at 5:51 AM
That depends on a few things:

1) Which compiled version of the assembly you're working with. I say this because the WINXP and higher build types contain support for storing those credentials in the All User's profile for connections that are stored in the All User's phone book. If you're using the default version (Windows 2000) the credentials are stored in the current user profile only.

2) Where the connection is stored at. Connections stored in the current user's profile cannot have credentials stored in the all user's profile simply because the connection does not exist in that phone book.

The password retrieved in the Password field of the credentials object will never be the actual password. It is rather a handle to the saved password as described in the Windows SDK ( You should also never use information found in that property in your application other than to test if the stored password exists. The SDK specifically states "do not develop code that depends on the contents or format of this value."

If you simply call the Dial method on the RasDialer component and do not specify any credentials Windows should automatically use any credentials that have been stored which are available.

After reading the extra information in the SDK, I may have found a bug with dialing connections using stored credentials. Is this method not working correctly?
Apr 14, 2009 at 7:35 AM

If I call Dial(new NetworkCredential("username", "password")) then it does work, but if I just call Dial() then it fails.

The phonebook that has the entry I'm trying to use is the current user (not the all user).

Apr 14, 2009 at 1:37 PM
That's what I thought when I looked at the code. You can either grab the latest changeset and compile it yourself or wait until I release the 1.0 version tomorrow.

It should fix the problem you're seeing.
Apr 15, 2009 at 4:41 AM
I compiled from the latest revision and it works now.

May 4, 2009 at 11:30 PM
Edited May 4, 2009 at 11:36 PM
Is there a way to store the user credentials for all users?  I see the UpdateCredentials function in the RasEntry class but this only seems to save the credentials for the current user.  I am using the WINXPSP2 build.  I may just be doing it wrong but I am calling the .Open(false) on a new RasPhoneBook as below.

 Dim pbk As New RasPhoneBook
pbk.Entries(name).UpdateCredentials(New NetworkCredential("username", "password"))





May 4, 2009 at 11:58 PM
The entry needs to be stored in the all users profile, which it looks like you have done (since you're opening the all user's phone book). With the WINXP, WINXPSP2, or WIN2K8 build you just need to call UpdateCredentials and use the overload and pass true into it. There's a flag on the 2nd overload that indicates whether the credentials should be stored in the all user's profile.
May 5, 2009 at 3:00 PM
I totally missed that overload.  Thanks, Jeff!