Search code examples
c#wpfactive-directorynetworkcredentials

Retrieving credentials / passwords from AD


I want to use a smpt email class in a WPF C# app

My smpt server is cloud based and I of course need my user and password.

Whilst I may be ok with saving the user for smpt server I would like to avoid putting the password in the code.

Reading up it seems that I can not retrieve the password from AD of a user due to the way it is stored. Is that correct or have I missed something?

I can think to store a password in SQL with SALT but it there a better way than this for WPF C#?

Update The links below help to secure and retrieve but I am being bit thick here I still have to put my password in the code / dll?

Is that secure?

For example

var str = "Password123"; var sc = new SecureString(); foreach(char c in str) sc.appendChar

Solution

  • You can certainly not retrive a password from AD.

    You may store the password in an encrypted configuration file but note that there is no completely safe way to store a password in an application. Regardless of whether you hard-code it in clear text in your source code or encrypt it, it can still be retrieved by a malicious user. The most secure thing would be not to store the password in the application at all, but instead let the user type it in on request for example.