- byte[] domain = Encoding.Unicode.GetBytes (_domain.ToUpper (CultureInfo.InvariantCulture));
- byte[] user = Encoding.Unicode.GetBytes (_username);
- byte[] host = Encoding.Unicode.GetBytes (_host.ToUpper (CultureInfo.InvariantCulture));
+ byte[] target = EncodeString (_domain);
+ byte[] user = EncodeString (_username);
+ byte[] host = EncodeString (_host);
+
+ byte[] lm, ntlm;
+ if (_type2 == null) {
+ if (_level != NtlmAuthLevel.LM_and_NTLM)
+ throw new InvalidOperationException (
+ "Refusing to use legacy-mode LM/NTLM authentication " +
+ "unless explicitly enabled using DefaultAuthLevel.");
+
+ using (var legacy = new ChallengeResponse (_password, _challenge)) {
+ lm = legacy.LM;
+ ntlm = legacy.NT;
+ }
+ } else {
+ ChallengeResponse2.Compute (_type2, _level, _username, _password, _domain, out lm, out ntlm);
+ }