المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Correct use of Secure String



C# Programming
11-20-2012, 01:50 PM
Hi Newbie here,

I've starting using C# a while ago and started a nice project to help my company maintiance PC profiles.
This application i'm writing connects to AD and retrieves a users email and with the push of a button changes a users profile to .old so he can login agian with a fresh windows profile.
I want to protect the communication with AD and the application by puttin the password in a secure string.
And i was looking for some feedback if i have done this correctly.
The follwing code bit shows the secure string and Authenticate a bit of the Authenticate process.

Any suggestions or critisism is welcome.

Thanks in advance.
private void btnLogIn_Click(object sender, EventArgs e) { // Beveiligd? string PwProtect = txtPassword.Text; char[] PasswordChars = PwProtect.ToCharArray(); SecureString Password = new SecureString(); foreach (char c in PasswordChars) Password.AppendChar(c); if (Authenticate(txtLogIn.Text, txtPassword.Text)) { gbxProfiel.Show(); txtPassword.Clear(); return; }