简体   繁体   中英

NTLM authentication not working after convertion to .net3.5 from .net4.5

following code is post method in webservice. Issue: NTML authentication works fine in .net framework 4.5 but i want to run the code in .net framework 3.5 to make the project compatible with windows xp.

Error: 401 unauthorised

try
            {
                System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object sender2, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
                {
                    return true;
                };

                WebRequest request = WebRequest.Create("http://192.168.100.254"+urldata);
                request.Method = "POST";

                //NTML authentication
                CredentialCache cc = new CredentialCache();
                cc.Add(

                    new Uri("http://192.168.100.254"),
                    "NTLM",
                    new NetworkCredential("admin", "mnjkl"));
                request.Credentials = cc;


                byte[] byteArray = Encoding.UTF8.GetBytes(data);
                request.ContentType = "application/x-www-form-urlencoded";
                request.ContentLength = byteArray.Length;
                Stream dataStream = request.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();
                WebResponse response = request.GetResponse();

                dataStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);
                string responseFromServer = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
                response.Close();
                return responseFromServer;
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

plesase any one who knows about NTLM authentication in .net3.5, help me out. thanks.

I to had the same issue. I was able to solve them by altering the highlighted local group policy all you need to do is right click on that policy and click properties and you need to uncheck the use 128 bit ssl Screenshot of the settings in local group policy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM