public static string GetPassword(Uri targetUri, string username) { using (Credential creds = new Credential()) { creds.Target = GetTargetString(targetUri, username); creds.PersistenceType = PersistenceType.LocalComputer; if (creds.Exists()) { creds.Load(); return creds.Password; } else { return null; } } }