コード例 #1
0
 public InformationServiceConnection(InfoServiceProxy proxy, bool takeOwnership)
 {
     this.service = proxy;
     bProxyOwner = takeOwnership;
     if (bProxyOwner)
     {
         this.proxy = proxy;
     }
 }
コード例 #2
0
        public InformationServiceContext(string endpointName)
        {
            if (endpointName == null)
            {
                throw new ArgumentNullException("endpointName");
            }
            if (endpointName.Length == 0)
            {
                throw new ArgumentException("endpoint name is empty", "endpointName");
            }

            this.proxy = new InfoServiceProxy(endpointName);
            this.proxy.Open();
        }
コード例 #3
0
        private void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (proxy != null)
                    {
                        proxy.Dispose();
                        proxy = null;
                    }
                }

                disposed = true;
            }
        }
コード例 #4
0
        public InformationServiceContext(string endpointName, ServiceCredentials credentials)
        {
            if (endpointName == null)
            {
                throw new ArgumentNullException(nameof(endpointName));
            }
            if (endpointName.Length == 0)
            {
                throw new ArgumentException("endpoint name is empty", nameof(endpointName));
            }
            if (credentials == null)
            {
                throw new ArgumentNullException(nameof(credentials));
            }

            Proxy = new InfoServiceProxy(endpointName, credentials);
            Proxy.Open();
        }
コード例 #5
0
        public InformationServiceContext(string endpointName, string remoteAddress)
        {
            if (endpointName == null)
            {
                throw new ArgumentNullException(nameof(endpointName));
            }
            if (endpointName.Length == 0)
            {
                throw new ArgumentException("endpoint name is empty", nameof(endpointName));
            }
            if (remoteAddress == null)
            {
                throw new ArgumentNullException(nameof(remoteAddress));
            }

            Proxy = new InfoServiceProxy(endpointName, remoteAddress);
            Proxy.Open();
        }
コード例 #6
0
        public InformationServiceContext(string endpointName, string remoteAddress, ServiceCredentials credentials)
        {
            if (endpointName == null)
            {
                throw new ArgumentNullException("endpointName");
            }
            if (endpointName.Length == 0)
            {
                throw new ArgumentException("endpoint name is empty", "endpointName");
            }
            if (remoteAddress == null)
            {
                throw new ArgumentNullException("remoteAddress");
            }
            if (credentials == null)
            {
                throw new ArgumentNullException("credentials");
            }

            this.proxy = new InfoServiceProxy(endpointName, remoteAddress, credentials);
            this.proxy.Open();
        }
コード例 #7
0
ファイル: Subscription.cs プロジェクト: rbramwell/OrionSDK
        public Subscription(InfoServiceProxy swis, string endpointAddress, string query, string binding = "NetTcp", string dataFormat = "Xml", CredentialType credentialType = CredentialType.Certificate, string username = null, string password = null)
        {
            this.swis = swis;

            PropertyBag propertyBag = new PropertyBag
                {
                    {"Query", query}, 
                    {"EndpointAddress", endpointAddress}, 
                    {"Description", "SWQL Studio"}, 
                    {"DataFormat", dataFormat}, 
                    {"CredentialType", credentialType.ToString()}
                };

            if (!string.IsNullOrEmpty(binding))
                propertyBag["Binding"] = binding;

            if (credentialType == CredentialType.Username)
            {
                propertyBag.Add("Username", username);
                propertyBag.Add("Password", password);
            }

            SubscriptionUri = swis.Create(systemSubscription, propertyBag);
        }
コード例 #8
0
 //This is required by NCM. NCM provide it's own proxy object
 public InformationServiceConnection(InfoServiceProxy proxy) : this(proxy, false)
 {
 }
コード例 #9
0
        private void CreateProxy()
        {
            if (endpointName.Length != 0)
            {
                if (remoteAddress != null)
                {
                    if (credentials != null)
                        this.proxy = new InfoServiceProxy(endpointName, remoteAddress, credentials);
                    else
                        this.proxy = new InfoServiceProxy(endpointName, remoteAddress);
                }
                else
                {
                    if (credentials != null)
                        this.proxy = new InfoServiceProxy(endpointName, credentials);
                    else
                        this.proxy = new InfoServiceProxy(endpointName);
                }

                this.service = this.proxy;
            }
        }
コード例 #10
0
        public override void Close()
        {
            if (!bProxyOwner)
                return;
            if (proxy != null)
            {
                try
                {
                    this.proxy.Dispose();
                }
                catch (TimeoutException)
                {
                    this.proxy.Abort();
                }
                catch (CommunicationException)
                {
                    this.proxy.Abort();
                }
            }
            this.proxy = null;
            this.service = null;
            this.open = false;

        }
コード例 #11
0
ファイル: QueryTab.cs プロジェクト: rbramwell/OrionSDK
 private Subscription SubscribeHttp(InfoServiceProxy proxy, string query, SubscriberInfo subscriberInfo)
 {
     return new Subscription(proxy, subscriberInfo.EndpointAddress, query, subscriberInfo.Binding, subscriberInfo.DataFormat, CredentialType.Username, "subscriber", "subscriber");
 }
コード例 #12
0
ファイル: QueryTab.cs プロジェクト: rbramwell/OrionSDK
 private Subscription SubscribeNetTcp(InfoServiceProxy proxy, string query, SubscriberInfo subscriberInfo)
 {
     return new Subscription(proxy, subscriberInfo.EndpointAddress, query, subscriberInfo.Binding, subscriberInfo.DataFormat);
 }
コード例 #13
0
ファイル: ConnectSwis.cs プロジェクト: rbramwell/OrionSDK
        private InfoServiceProxy ConnectNetTcp()
        {
            InfoServiceProxy infoServiceProxy;
            EndpointAddresses addresses = V2.IsPresent ? (EndpointAddresses)new V2EndpointAddresses() : new V3EndpointAddresses();

            if (Trusted.IsPresent)
            {
                var binding = new NetTcpBinding {MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue};
                binding.Security.Mode = SecurityMode.Transport;
                binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;

                var uri = new Uri(string.Format(addresses.activeDirectory, Hostname ?? "localhost"));

                infoServiceProxy = new InfoServiceProxy(uri, binding, new WindowsCredential());
            }
            else if (Certificate.IsPresent)
            {
                var binding = new NetTcpBinding(SecurityMode.Transport) {MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue};
                binding.Security.Mode = SecurityMode.Transport;
                binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate;
                binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
                binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;

                if (Streamed.IsPresent)
                {
                    binding.TransferMode = TransferMode.Streamed;
                    binding.PortSharingEnabled = true;
                    binding.ReceiveTimeout = new TimeSpan(15,0,0);
                    binding.SendTimeout = new TimeSpan(15, 0, 0);
                }

                var address = (Streamed && !V2.IsPresent)
                                  ? ((V3EndpointAddresses) addresses).streamedCertificate
                                  : addresses.certificate;

                var uri = new Uri(string.Format(address, Hostname ?? "localhost"));

                ServiceCredentials credentials = new MyCertificateCredential("SolarWinds-Orion", StoreLocation.LocalMachine, StoreName.My);

                infoServiceProxy = new InfoServiceProxy(uri, binding, credentials);
            }
            else
            {
                var binding = new NetTcpBinding {MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue};
                binding.Security.Mode = SecurityMode.TransportWithMessageCredential;
                binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;

                var uri = new Uri(string.Format(addresses.usernamePassword, Hostname ?? "localhost"));

                string username = string.Empty;
                string password = string.Empty;

                if (IsUserNamePresent)
                {
                    SecureString securePassword = StringToSecureString(this.Password);
                    this.Credential = new PSCredential(this.UserName, securePassword);
                }

                // the credential dialog adds a slash at the beginning, need to strip
                username = Credential.UserName.TrimStart('\\');
                password = SecureStringToString(Credential.Password);

                var credentials = new UsernameCredentials(username, password);

                infoServiceProxy = new InfoServiceProxy(uri, binding, credentials);
            }
            return infoServiceProxy;
        }