networkcredential without password

556 views Asked by At

I'm developping for CRM 2011 and I have to get the files in a SharePoint library. I'm able to get the files, but my problem is to hide the password in the code.

here my code :

string password = "password";
SecureString securePassword = new SecureString();
for (int g = 0; g < password.Length; g++)
  securePassword.AppendChar(password[g]);
ClientContext ctx = new ClientContext(url);
ctx.Credentials = new NetworkCredential("login", securePassword, "Foo");

return ctx;

I also tried with ctx.Credentials = CredentialCache.DefaultNetworkCredentials; but the user don't have the rights for the SharePoint Library.

Anyone has a solution to hide the password?

Thanks!

1

There are 1 answers

0
mydevexperience On BEST ANSWER

Create a custom entity called "SharePoint Config" with username and password. When a record is created encrypt the password using a plugin / JavaScript. From your custom workflow code get the password using the username from the "SharePoint Config" and decrypt the password.