Having trouble authenticating with Symantec Web Gateway version 18.104.22.168 from C#
I know this forum would not typically deal with a c# application connecting to a Symantec Web Gateway but I am hoping you guys might be able to provide some insight.. Because I am guess I probably am not authenticating against the correct page on the gateway or something along that line. So here goes..
I have an application that I am developing that must first authenticate with a Symantec Web Gateway. My customer is using Symantec Web Gateway version 22.214.171.124. I am writing the application in C# and it will be running on a machine that is not joined to the domain and they do not want to enter an exception in the gateway box.
The gateway uses NTLM (NTLMSSP) authentication. The code I have written works perfectly to authenticate against some of our company websites that use NTLM but it does not seem to work against the web gateway and I am wondering if I need to hit specific pages on the gateway box first before trying to go out to the web. I have tried going straight to http://google.com and passing the authentication but the gateway returns a page telling me that I did not authenticate.
I have also tried hitting the same page the browser hits if you try to authenticate. The page url takes the form of:
If I hit against this page it will drop to the catch of the exception handling and return the error message:
The remote server returned an error: (401) Unathorized.
The username, password and domain are all correct. I can use them in Internet Explorer and authenticate just fine from the same box. If I watch the connections in WireShark and try to authenticate with the gateway I do not see the username being passed but when I hit it against some other websites I have that are running on Windows IIS it passes the username and mentiones NTLMSSP just like IE does when authenticating with the Symantec Web Gateway. So my guess is that I am just not hitting the right page or something or have possibly missed something in the code.
Here is my code. Any help or suggestions you may be able to offer are appreciated:
private void TestAuthenticationButton_Click(object sender, EventArgs e)
StatusLabel.Text = "Requesting Page...";
OutputTextBox.Text = "";
StringBuilder sb = new StringBuilder();
byte buf = new byte;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(WebSiteAddressTextBox.Text);
if (DomainNameTextBox.Text != "")
credential = new NetworkCredential(UserNameTextBox.Text, PasswordTextBox.Text, DomainNameTextBox.Text);
credential = new NetworkCredential(UserNameTextBox.Text, PasswordTextBox.Text);
CredentialCache credentialCache = new CredentialCache();
credentialCache.Add(new Uri(WebSiteAddressTextBox.Text), "Negotiate", credential);
request.Credentials = credentialCache;
request.PreAuthenticate = true;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
tempString = Encoding.ASCII.GetString(buf, 0, count);
while (count > 0);
OutputTextBox.Text = sb.ToString();
StatusLabel.Text = "Request Complete.";
catch (Exception ex)
StatusLabel.Text = "Error...";