1 Reply Latest reply on Oct 25, 2012 8:52 AM by harwoodsj

    Information Service - Forbidden 403

    harwoodsj

      Hi

       

      I found a post on this forum showing how to create a node using the Information Service from c#, this is something i need to do too but i am getting an error:

       

      The code Compiles fine and runs until i get to the actual CREATE statement where it returns the following message:

      {"The HTTP request was forbidden with client authentication scheme 'Basic'."}

       

      Does anyone know how to get round this? I have tried a few different usernames and passwords but am getting the same response.

       

      Code Below (With some bits changed of course).

       

      using System;

      using System.Diagnostics;

      using System.Net;

      using System.Net.Security;

      using System.Security.Cryptography.X509Certificates;

      using System.ServiceModel;

      using System.ServiceModel.Channels;

      using SolarWinds.InformationService.Contract2;

      using System.Web;

       

       

      namespace AddNode

      {

          class Program

          {

              static void Main(string[] args)

              {

                  ServicePointManager.ServerCertificateValidationCallback = ValidateRemoteCertificate;

       

                  const string username = "admin";

                  const string password = "";

       

                  var address = new Uri("https://[hostname]:17778/SolarWinds/InformationService/OrionBasic");

                  var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

                  binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

       

                  var credentials = new UsernameCredentials(username, password);

                  var swis = new InfoServiceProxy(address, binding, credentials);

                  string uri = swis.Create("Orion.Nodes", new PropertyBag

                                                            {

                                                                {"EntityType", "Orion.Nodes"},

                                                                {"IPAddress", "127.0.01"},

                                                                {"Caption", "sim-r_test01"},

                                                                {"DynamicIP", false},

                                                                {"EngineID", 1},

                                                                {"Status", 1},

                                                                {"Allow64BitCounters", true},

                                                                {"ObjectSubType", "SNMP"},

                                                                {"SysObjectID", ""},

                                                                {"MachineType", ""},

                                                                {"VendorIcon", ""},

                                                                {"Community", "public"},

                                                                {"SNMPVersion", 2}

                                                            });

                  Console.WriteLine(uri);

       

       

                  if (Debugger.IsAttached)

                  {

                      Console.WriteLine("Press enter to exit.");

                      Console.ReadLine();

                  }

              }

       

       

              //Function ValidateRemoteCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean

              private static bool ValidateRemoteCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)

              {

                  return true;

              }

          }

      }

       

      Any Help gratefully received.

       

      Regards

       

      Si