0

I'm creating a desktop app in C# using aejw API. Then i have to map a persistent network drive connection with stored authentication.

There is a sample code i using without effect. The code maps share succesfully, but dont store a password in Credential Manager. It is posssible to take the effect(store password) what i want using 'Runtime.InteropServices'

NetworkDrive nd = new NetworkDrive();
             nd.LocalDrive = "Y:";
             nd.Persistent = true;
             nd.SaveCredentials = true;
             nd.ShareName = @"\\server\share";
             nd.MapDrive(username, password);
  • That code P/Invokes with CONNECT_CMD_SAVECRED but you also need to prompt for credentials and even then it is missing a required flag. – Anders Nov 07 '19 at 14:12
  • @Anders you mean flag 'connect_cmd_savecred' works only when operating system prompts for a credential ? So there is any other way to save credentials in Credential Manager which can be used to authentication for network share ? – Litte Programmer Nov 07 '19 at 14:19
  • That is what MSDN says about that flag, I don't know if it is true. – Anders Nov 07 '19 at 14:32
  • @Anders You were right. But I would avoid any prompts for user. – Litte Programmer Nov 08 '19 at 08:15
  • You would have to write the cred. yourself then. Perhaps debug net.exe to see exactly what it does. – Anders Nov 08 '19 at 15:37

0 Answers0