How can I save network credentials to the Windows credentials cache/vault?

1.6k views Asked by At

I am evaluating a 3rd party API WebDAV.NET for gaining access to SharePoint web folders. This API accepts the standard .Net network credentials and gives me two options:

ICredentials credential = CredentialCache.DefaultCredentials;

and

NetworkCredential credential = new NetworkCredential("[user]", "[password]");

If I connect to a network location (web folder) through Windows Explorer and authentication is required, Windows will automatically prompt me for a user name and password. I can then choose to remember the credentials and Windows will store them. Having done this, I can then use the first method above CredentialCache.DefaultCredentials to connect to the SharePoint web folder using this 3rd party API.

If however, I have not connected via Windows Explorer first, I could use the second option and provide a user name and password. However, these credentials do not get saved and do not get remembered.

I do not want to create my own mechanism for securing and storing these credentials. What I would like to do is prompt the user for his user name and password, create a network credential and store this to the Windows vault such that I can then turn around and use the first method CredentialCache.DefaultCredentials in connecting to the SharePoint web folder.

I basically would like to accomplish what Windows Explorer does, prompt for user name and password and then remember these.

0

There are 0 answers