Ejemplo n.º 1
0
    public void OnButtonConnect()
    {
        if (session != null)
        {
            FunapiSession.Destroy(session);
            session = null;
        }

        // Create session
        SessionOption option = new SessionOption();

        option.sessionReliability    = false;
        option.sendSessionIdOnlyOnce = false;

        session = FunapiSession.Create(address.text, option);
        session.SessionEventCallback    += onSessionEvent;
        session.TransportEventCallback  += onTransportEvent;
        session.TransportErrorCallback  += onTransportError;
        session.ReceivedMessageCallback += onReceivedMessage;

        if (protocol1.type != TransportProtocol.kDefault)
        {
            session.Connect(protocol1.type, encoding1.type, ushort.Parse(port1.text));
        }

        if (protocol2.type != TransportProtocol.kDefault)
        {
            session.Connect(protocol2.type, encoding2.type, ushort.Parse(port2.text));
        }

        if (protocol3.type != TransportProtocol.kDefault)
        {
            session.Connect(protocol3.type, encoding3.type, ushort.Parse(port3.text));
        }
    }
Ejemplo n.º 2
0
 public Bootstrap Option(SessionOption option, object value)
 {
     if (option == null)
         throw new ArgumentNullException();
     option.Value = value;
     if (!options.Contains(option)) options.Add(option);
     return this;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (GetIsComputerNameSpecified(context))
            {
                targetCommand.AddParameter("ComputerName", PSComputerName.Get(context));
            }

            if (Authentication.Expression != null)
            {
                targetCommand.AddParameter("Authentication", Authentication.Get(context));
            }

            if (Credential.Expression != null)
            {
                targetCommand.AddParameter("Credential", Credential.Get(context));
            }

            if (CertificateThumbprint.Expression != null)
            {
                targetCommand.AddParameter("CertificateThumbprint", CertificateThumbprint.Get(context));
            }

            if (Name.Expression != null)
            {
                targetCommand.AddParameter("Name", Name.Get(context));
            }

            if (OperationTimeoutSec.Expression != null)
            {
                targetCommand.AddParameter("OperationTimeoutSec", OperationTimeoutSec.Get(context));
            }

            if (Port.Expression != null)
            {
                targetCommand.AddParameter("Port", Port.Get(context));
            }

            if (SessionOption.Expression != null)
            {
                targetCommand.AddParameter("SessionOption", SessionOption.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Ejemplo n.º 4
0
        /// <summary>
        /// BeginProcessing method.
        /// </summary>
        protected override void BeginProcessing()
        {
            WSManHelper helper = new WSManHelper(this);

            if (proxyauthentication.Equals(ProxyAuthentication.Basic) || proxyauthentication.Equals(ProxyAuthentication.Digest))
            {
                if (_proxycredential == null)
                {
                    InvalidOperationException ex = new InvalidOperationException(helper.GetResourceMsgFromResourcetext("NewWSManSessionOptionCred"));
                    ErrorRecord er = new ErrorRecord(ex, "InvalidOperationException", ErrorCategory.InvalidOperation, null);
                    WriteError(er);
                    return;
                }
            }

            if ((_proxycredential != null) && (proxyauthentication == 0))
            {
                InvalidOperationException ex = new InvalidOperationException(helper.GetResourceMsgFromResourcetext("NewWSManSessionOptionAuth"));
                ErrorRecord er = new ErrorRecord(ex, "InvalidOperationException", ErrorCategory.InvalidOperation, null);
                WriteError(er);
                return;
            }

            // Creating the Session Object
            SessionOption objSessionOption = new SessionOption();

            objSessionOption.SPNPort             = spnport;
            objSessionOption.UseUtf16            = useutf16;
            objSessionOption.SkipCNCheck         = skipcncheck;
            objSessionOption.SkipCACheck         = skipcacheck;
            objSessionOption.OperationTimeout    = operationtimeout;
            objSessionOption.SkipRevocationCheck = skiprevocationcheck;
            // Proxy Settings
            objSessionOption.ProxyAccessType     = _proxyaccesstype;
            objSessionOption.ProxyAuthentication = proxyauthentication;

            if (noencryption)
            {
                objSessionOption.UseEncryption = false;
            }

            if (_proxycredential != null)
            {
                NetworkCredential nwCredentials = _proxycredential.GetNetworkCredential();
                objSessionOption.ProxyCredential = nwCredentials;
            }

            WriteObject(objSessionOption);
        }
    void createSession()
    {
        // Create session
        SessionOption option = new SessionOption();

        option.sessionReliability    = false;
        option.sendSessionIdOnlyOnce = false;

        session = FunapiSession.Create(info.address, option);
        session.SessionEventCallback    += onSessionEvent;
        session.TransportEventCallback  += onTransportEvent;
        session.TransportErrorCallback  += onTransportError;
        session.ReceivedMessageCallback += onReceivedMessage;

        address_changed = false;
    }
        /// <summary>
        /// Event fired when the Session Option is changed
        /// </summary>
        /// <param name="sender">Sender that calls the event (item clicked)</param>
        /// <param name="e">Event arguments</param>
        private void PreserveVariablesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var clickedItem = sender as ToolStripMenuItem;

            if (clickedItem == null)
            {
                return;
            }

            _sessionOption = clickedItem.Checked ? SessionOption.UseSameSession : SessionOption.UseNewSession;
            if (_mySqlXProxy != null)
            {
                _mySqlXProxy.CleanConnection();
                _mySqlXProxy    = null;
                CodeEditor.Dock = ResultsTabControl.Visible ? DockStyle.Top : DockStyle.Fill;
            }
        }
Ejemplo n.º 7
0
        public void Connect(TransportProtocol protocol, FunEncoding encoding)
        {
            if (session == null)
            {
                SessionOption option = new SessionOption();
                option.sessionReliability    = false;
                option.sendSessionIdOnlyOnce = false;

                session = FunapiSession.Create(address, option);
                session.SessionEventCallback    += onSessionEvent;
                session.TransportEventCallback  += onTransportEvent;
                session.TransportErrorCallback  += onTransportError;
                session.ReceivedMessageCallback += onReceivedMessage;
            }

            session.Connect(protocol, encoding, getPort(protocol, encoding));
        }
Ejemplo n.º 8
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (ApplicationName.Expression != null)
            {
                targetCommand.AddParameter("ApplicationName", ApplicationName.Get(context));
            }

            if (BasePropertiesOnly.Expression != null)
            {
                targetCommand.AddParameter("BasePropertiesOnly", BasePropertiesOnly.Get(context));
            }

            if ((ComputerName.Expression != null) && (PSRemotingBehavior.Get(context) != RemotingBehavior.Custom))
            {
                targetCommand.AddParameter("ComputerName", ComputerName.Get(context));
            }

            if (ConnectionURI.Expression != null)
            {
                targetCommand.AddParameter("ConnectionURI", ConnectionURI.Get(context));
            }

            if (Dialect.Expression != null)
            {
                targetCommand.AddParameter("Dialect", Dialect.Get(context));
            }

            if (Enumerate.Expression != null)
            {
                targetCommand.AddParameter("Enumerate", Enumerate.Get(context));
            }

            if (Filter.Expression != null)
            {
                targetCommand.AddParameter("Filter", Filter.Get(context));
            }

            if (Fragment.Expression != null)
            {
                targetCommand.AddParameter("Fragment", Fragment.Get(context));
            }

            if (OptionSet.Expression != null)
            {
                targetCommand.AddParameter("OptionSet", OptionSet.Get(context));
            }

            if (Port.Expression != null)
            {
                targetCommand.AddParameter("Port", Port.Get(context));
            }

            if (Associations.Expression != null)
            {
                targetCommand.AddParameter("Associations", Associations.Get(context));
            }

            if (ResourceURI.Expression != null)
            {
                targetCommand.AddParameter("ResourceURI", ResourceURI.Get(context));
            }

            if (ReturnType.Expression != null)
            {
                targetCommand.AddParameter("ReturnType", ReturnType.Get(context));
            }

            if (SelectorSet.Expression != null)
            {
                targetCommand.AddParameter("SelectorSet", SelectorSet.Get(context));
            }

            if (SessionOption.Expression != null)
            {
                targetCommand.AddParameter("SessionOption", SessionOption.Get(context));
            }

            if (Shallow.Expression != null)
            {
                targetCommand.AddParameter("Shallow", Shallow.Get(context));
            }

            if (UseSSL.Expression != null)
            {
                targetCommand.AddParameter("UseSSL", UseSSL.Get(context));
            }

            if (Credential.Expression != null)
            {
                targetCommand.AddParameter("Credential", Credential.Get(context));
            }

            if (Authentication.Expression != null)
            {
                targetCommand.AddParameter("Authentication", Authentication.Get(context));
            }

            if (CertificateThumbprint.Expression != null)
            {
                targetCommand.AddParameter("CertificateThumbprint", CertificateThumbprint.Get(context));
            }

            if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom))
            {
                targetCommand.AddParameter("ComputerName", PSComputerName.Get(context));
            }

            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (ComputerName.Expression != null)
            {
                targetCommand.AddParameter("ComputerName", ComputerName.Get(context));
            }

            if (ApplicationName.Expression != null)
            {
                targetCommand.AddParameter("ApplicationName", ApplicationName.Get(context));
            }

            if (ConnectionUri.Expression != null)
            {
                targetCommand.AddParameter("ConnectionUri", ConnectionUri.Get(context));
            }

            if (ConfigurationName.Expression != null)
            {
                targetCommand.AddParameter("ConfigurationName", ConfigurationName.Get(context));
            }

            if (AllowRedirection.Expression != null)
            {
                targetCommand.AddParameter("AllowRedirection", AllowRedirection.Get(context));
            }

            if (Name.Expression != null)
            {
                targetCommand.AddParameter("Name", Name.Get(context));
            }

            if (InstanceId.Expression != null)
            {
                targetCommand.AddParameter("InstanceId", InstanceId.Get(context));
            }

            if (Credential.Expression != null)
            {
                targetCommand.AddParameter("Credential", Credential.Get(context));
            }

            if (Authentication.Expression != null)
            {
                targetCommand.AddParameter("Authentication", Authentication.Get(context));
            }

            if (CertificateThumbprint.Expression != null)
            {
                targetCommand.AddParameter("CertificateThumbprint", CertificateThumbprint.Get(context));
            }

            if (Port.Expression != null)
            {
                targetCommand.AddParameter("Port", Port.Get(context));
            }

            if (UseSSL.Expression != null)
            {
                targetCommand.AddParameter("UseSSL", UseSSL.Get(context));
            }

            if (ThrottleLimit.Expression != null)
            {
                targetCommand.AddParameter("ThrottleLimit", ThrottleLimit.Get(context));
            }

            if (State.Expression != null)
            {
                targetCommand.AddParameter("State", State.Get(context));
            }

            if (SessionOption.Expression != null)
            {
                targetCommand.AddParameter("SessionOption", SessionOption.Get(context));
            }

            if (PSSessionId.Expression != null)
            {
                targetCommand.AddParameter("Id", PSSessionId.Get(context));
            }

            if (ContainerId.Expression != null)
            {
                targetCommand.AddParameter("ContainerId", ContainerId.Get(context));
            }

            if (VMId.Expression != null)
            {
                targetCommand.AddParameter("VMId", VMId.Get(context));
            }

            if (VMName.Expression != null)
            {
                targetCommand.AddParameter("VMName", VMName.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
 public override void ExplicitVisit(SessionOption fragment)
 {
     _fragments.Add(fragment);
 }
Ejemplo n.º 11
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (ApplicationName.Expression != null)
            {
                targetCommand.AddParameter("ApplicationName", ApplicationName.Get(context));
            }

            if ((ComputerName.Expression != null) && (PSRemotingBehavior.Get(context) != RemotingBehavior.Custom))
            {
                targetCommand.AddParameter("ComputerName", ComputerName.Get(context));
            }

            if (ConnectionURI.Expression != null)
            {
                targetCommand.AddParameter("ConnectionURI", ConnectionURI.Get(context));
            }

            if (OptionSet.Expression != null)
            {
                targetCommand.AddParameter("OptionSet", OptionSet.Get(context));
            }

            if (Port.Expression != null)
            {
                targetCommand.AddParameter("Port", Port.Get(context));
            }

            if (SessionOption.Expression != null)
            {
                targetCommand.AddParameter("SessionOption", SessionOption.Get(context));
            }

            if (UseSSL.Expression != null)
            {
                targetCommand.AddParameter("UseSSL", UseSSL.Get(context));
            }

            if (Credential.Expression != null)
            {
                targetCommand.AddParameter("Credential", Credential.Get(context));
            }

            if (Authentication.Expression != null)
            {
                targetCommand.AddParameter("Authentication", Authentication.Get(context));
            }

            if (CertificateThumbprint.Expression != null)
            {
                targetCommand.AddParameter("CertificateThumbprint", CertificateThumbprint.Get(context));
            }

            if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom))
            {
                targetCommand.AddParameter("ComputerName", PSComputerName.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Ejemplo n.º 12
0
        /// <summary>
        /// This method is used by Connect-WsMan Cmdlet and New-Item of WsMan Provider to create connection to WsMan.
        /// </summary>
        /// <param name="ParameterSetName"></param>
        /// <param name="connectionuri"></param>
        /// <param name="port"></param>
        /// <param name="computername"></param>
        /// <param name="applicationname"></param>
        /// <param name="usessl"></param>
        /// <param name="authentication"></param>
        /// <param name="sessionoption"></param>
        /// <param name="credential"></param>
        /// <param name="certificateThumbprint"></param>
        internal void CreateWsManConnection(string ParameterSetName, Uri connectionuri, int port, string computername, string applicationname, bool usessl, AuthenticationMechanism authentication, SessionOption sessionoption, PSCredential credential, string certificateThumbprint)
        {
            IWSManEx m_wsmanObject = (IWSManEx) new WSManClass();

            try
            {
                string connectionStr = CreateConnectionString(connectionuri, port, computername, applicationname);
                if (connectionuri != null)
                {
                    // in the format http(s)://server[:port/applicationname]
                    string[] constrsplit  = connectionStr.Split(":" + port + "/" + applicationname, StringSplitOptions.None);
                    string[] constrsplit1 = constrsplit[0].Split("//", StringSplitOptions.None);
                    computername = constrsplit1[1].Trim();
                }

                IWSManSession m_session = CreateSessionObject(m_wsmanObject, authentication, sessionoption, credential, connectionStr, certificateThumbprint, usessl);
                m_session.Identify(0);
                string key = computername ?? "localhost";

                AddtoDictionary(key, m_session);
            }
            catch (IndexOutOfRangeException)
            {
                AssertError(_resourceMgr.GetString("NotProperURI"), false, connectionuri);
            }
            catch (Exception ex)
            {
                AssertError(ex.Message, false, computername);
            }
            finally
            {
                if (!string.IsNullOrEmpty(m_wsmanObject.Error))
                {
                    AssertError(m_wsmanObject.Error, true, computername);
                }
            }
        }
Ejemplo n.º 13
0
        internal IWSManSession CreateSessionObject(IWSManEx wsmanObject, AuthenticationMechanism authentication, SessionOption sessionoption, PSCredential credential, string connectionString, string certificateThumbprint, bool usessl)
        {
            ValidateSpecifiedAuthentication(authentication, credential, certificateThumbprint);

            ////if authentication is given
            int sessionFlags = 0;

            if (authentication.ToString() != null)
            {
                if (authentication.Equals(AuthenticationMechanism.None))
                {
                    sessionFlags |= (int)WSManSessionFlags.WSManFlagUseNoAuthentication;
                }

                if (authentication.Equals(AuthenticationMechanism.Basic))
                {
                    sessionFlags = sessionFlags | (int)WSManSessionFlags.WSManFlagUseBasic | (int)WSManSessionFlags.WSManFlagCredUserNamePassword;
                }

                if (authentication.Equals(AuthenticationMechanism.Negotiate))
                {
                    sessionFlags |= (int)WSManSessionFlags.WSManFlagUseNegotiate;
                }

                if (authentication.Equals(AuthenticationMechanism.Kerberos))
                {
                    sessionFlags |= (int)WSManSessionFlags.WSManFlagUseKerberos;
                }

                if (authentication.Equals(AuthenticationMechanism.Digest))
                {
                    sessionFlags = sessionFlags | (int)WSManSessionFlags.WSManFlagUseDigest | (int)WSManSessionFlags.WSManFlagCredUserNamePassword;
                }

                if (authentication.Equals(AuthenticationMechanism.Credssp))
                {
                    sessionFlags = sessionFlags | (int)WSManSessionFlags.WSManFlagUseCredSsp | (int)WSManSessionFlags.WSManFlagCredUserNamePassword;
                }

                if (authentication.Equals(AuthenticationMechanism.ClientCertificate))
                {
                    sessionFlags |= (int)WSManSessionFlags.WSManFlagUseClientCertificate;
                }
            }

            IWSManConnectionOptionsEx2 connObject = (IWSManConnectionOptionsEx2)wsmanObject.CreateConnectionOptions();

            if (credential != null)
            {
                // connObject = (IWSManConnectionOptionsEx2)wsmanObject.CreateConnectionOptions();
                System.Net.NetworkCredential nwCredential = new System.Net.NetworkCredential();
                if (credential.UserName != null)
                {
                    nwCredential = credential.GetNetworkCredential();
                    if (string.IsNullOrEmpty(nwCredential.Domain))
                    {
                        if (authentication.Equals(AuthenticationMechanism.Digest) || authentication.Equals(AuthenticationMechanism.Basic))
                        {
                            connObject.UserName = nwCredential.UserName;
                        }
                        else
                        {
                            // just wanted to not use null domain, empty is actually fine
                            connObject.UserName = "******" + nwCredential.UserName;
                        }
                    }
                    else
                    {
                        connObject.UserName = nwCredential.Domain + "\\" + nwCredential.UserName;
                    }

                    connObject.Password = nwCredential.Password;
                    if (!authentication.Equals(AuthenticationMechanism.Credssp) || !authentication.Equals(AuthenticationMechanism.Digest) || authentication.Equals(AuthenticationMechanism.Basic))
                    {
                        sessionFlags |= (int)WSManSessionFlags.WSManFlagCredUserNamePassword;
                    }
                }
            }

            if (certificateThumbprint != null)
            {
                connObject.CertificateThumbprint = certificateThumbprint;
                sessionFlags |= (int)WSManSessionFlags.WSManFlagUseClientCertificate;
            }

            if (sessionoption != null)
            {
                if (sessionoption.ProxyAuthentication != 0)
                {
                    int ProxyAccessflags         = 0;
                    int ProxyAuthenticationFlags = 0;
                    if (sessionoption.ProxyAccessType.Equals(ProxyAccessType.ProxyIEConfig))
                    {
                        ProxyAccessflags = connObject.ProxyIEConfig();
                    }
                    else if (sessionoption.ProxyAccessType.Equals(ProxyAccessType.ProxyAutoDetect))
                    {
                        ProxyAccessflags = connObject.ProxyAutoDetect();
                    }
                    else if (sessionoption.ProxyAccessType.Equals(ProxyAccessType.ProxyNoProxyServer))
                    {
                        ProxyAccessflags = connObject.ProxyNoProxyServer();
                    }
                    else if (sessionoption.ProxyAccessType.Equals(ProxyAccessType.ProxyWinHttpConfig))
                    {
                        ProxyAccessflags = connObject.ProxyWinHttpConfig();
                    }

                    if (sessionoption.ProxyAuthentication.Equals(ProxyAuthentication.Basic))
                    {
                        ProxyAuthenticationFlags = connObject.ProxyAuthenticationUseBasic();
                    }
                    else if (sessionoption.ProxyAuthentication.Equals(ProxyAuthentication.Negotiate))
                    {
                        ProxyAuthenticationFlags = connObject.ProxyAuthenticationUseNegotiate();
                    }
                    else if (sessionoption.ProxyAuthentication.Equals(ProxyAuthentication.Digest))
                    {
                        ProxyAuthenticationFlags = connObject.ProxyAuthenticationUseDigest();
                    }

                    if (sessionoption.ProxyCredential != null)
                    {
                        try
                        {
                            connObject.SetProxy(ProxyAccessflags, ProxyAuthenticationFlags, sessionoption.ProxyCredential.UserName, sessionoption.ProxyCredential.Password);
                        }
                        catch (Exception ex)
                        {
                            AssertError(ex.Message, false, null);
                        }
                    }
                    else
                    {
                        connObject.SetProxy((int)sessionoption.ProxyAccessType, (int)sessionoption.ProxyAuthentication, null, null);
                    }
                }

                if (sessionoption.SkipCACheck)
                {
                    sessionFlags |= (int)WSManSessionFlags.WSManFlagSkipCACheck;
                }

                if (sessionoption.SkipCNCheck)
                {
                    sessionFlags |= (int)WSManSessionFlags.WSManFlagSkipCNCheck;
                }

                if (sessionoption.SPNPort > 0)
                {
                    sessionFlags |= (int)WSManSessionFlags.WSManFlagEnableSpnServerPort;
                }

                if (sessionoption.UseUtf16)
                {
                    sessionFlags |= (int)WSManSessionFlags.WSManFlagUtf16;
                }
                else
                {
                    // If UseUtf16 is false, then default Encoding is Utf8
                    sessionFlags |= (int)WSManSessionFlags.WSManFlagUtf8;
                }

                if (!sessionoption.UseEncryption)
                {
                    sessionFlags |= (int)WSManSessionFlags.WSManFlagNoEncryption;
                }

                if (sessionoption.SkipRevocationCheck)
                {
                    sessionFlags |= (int)WSManSessionFlags.WSManFlagSkipRevocationCheck;
                }
            }
            else
            {
                // If SessionOption is null then, default Encoding is Utf8
                sessionFlags |= (int)WSManSessionFlags.WSManFlagUtf8;
            }

            if (usessl)
            {
                sessionFlags |= (int)WSManSessionFlags.WSManFlagUseSsl;
            }

            IWSManSession m_SessionObj = null;

            try
            {
                m_SessionObj = (IWSManSession)wsmanObject.CreateSession(connectionString, sessionFlags, connObject);
                if (sessionoption != null)
                {
                    if (sessionoption.OperationTimeout > 0)
                    {
                        m_SessionObj.Timeout = sessionoption.OperationTimeout;
                    }
                }
            }
            catch (COMException ex)
            {
                AssertError(ex.Message, false, null);
            }

            return(m_SessionObj);
        }
Ejemplo n.º 14
0
 public override void ExplicitVisit(SessionOption node) { this.action(node); }