return InternalAuthenticate (webRequest, credentials);
}
+ static byte [] GetBytes (string str)
+ {
+ int i = str.Length;
+ byte [] result = new byte [i];
+ for (--i; i >= 0; i--)
+ result [i] = (byte) str [i];
+
+ return result;
+ }
+
static Authorization InternalAuthenticate (WebRequest webRequest, ICredentials credentials)
{
HttpWebRequest request = webRequest as HttpWebRequest;
// If domain is set, MS sends "domain\user:password".
if (domain == null || domain == "" || domain.Trim () == "")
- bytes = Encoding.Default.GetBytes (userName + ":" + password);
+ bytes = GetBytes (userName + ":" + password);
else
- bytes = Encoding.Default.GetBytes (domain + "\\" + userName + ":" + password);
+ bytes = GetBytes (domain + "\\" + userName + ":" + password);
string auth = "Basic " + Convert.ToBase64String (bytes);
return new Authorization (auth);