Neos.IdentityServer 3.0/Neos.IdentityServer.Common/Neos.IdentityServer.MultiFactor.Utilities.cs
/// <summary>
/// PushRemoteConfiguration method implmentation
/// Push Configuration file cache to Remote server using wsman
/// </summary>
PushRemoteConfiguration method implmentation
Push Configuration file cache to Remote server using wsman
PushRemoteConfiguration method implmentation Push Configuration file cache to Remote server using wsman
internal static void PushRemoteConfiguration(MFAConfig cfg, string servername)
        {
            Runspace SPRunSpace = null;
            PowerShell SPPowerShell = null;
            try
            {
                string filePath = CFGUtilities.configcachedir;
                using (var fs = File.Open(filePath, FileMode.Open, FileAccess.Read))
                {
                    byte[] buffer = new byte[fs.Length];
                    int bytesRead = fs.Read(buffer, 0, Convert.ToInt32(fs.Length));
                    WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, servername, cfg.WsMan.Port, "/" + cfg.WsMan.AppName, cfg.WsMan.ShellUri, null, cfg.WsMan.TimeOut);
                    SPRunSpace = RunspaceFactory.CreateRunspace(connectionInfo);
                    connectionInfo.AuthenticationMechanism = AuthenticationMechanism.NegotiateWithImplicitCredential;
                    string psscript = string.Concat("$fs=[IO.File]::Open($filepath, [IO.FileMode]::Create, [IO.FileAccess]::Write);",
                                                    "$fs.Write($bytes, 0, $bytes.Length);",
                                                    "$fs.Flush();",
                                                    "$fs.Dispose();");
                    SPPowerShell = PowerShell.Create();
                    SPPowerShell.Runspace = SPRunSpace;
                    SPRunSpace.Open();
                    PSCommand command = new PSCommand();
                    command.AddCommand("Set-Variable");
                    command.AddParameter("Name", "bytes");
                    command.AddParameter("Value", buffer);
                    command.AddCommand("Set-Variable");
                    command.AddParameter("Name", "filepath");
                    command.AddParameter("Value", filePath);
                    SPPowerShell.Commands = command;
                    SPPowerShell.AddScript(psscript);
                    SPPowerShell.Invoke();
                }
            }
            finally
            {
                if (SPRunSpace != null)
                    SPRunSpace.Close();
                if (SPPowerShell != null)
                    SPPowerShell.Dispose();
            }
        }
internal static void PushRemoteConfiguration ( MFAConfig cfg , string servername ) { Runspace SPRunSpace = null ; PowerShell SPPowerShell = null ; try { string filePath = CFGUtilities . configcachedir ; using ( var fs = File . Open ( filePath , FileMode . Open , FileAccess . Read ) ) { byte [ ] buffer = new byte [ fs . Length ] ; int bytesRead = fs . Read ( buffer , 0 , Convert . ToInt32 ( fs . Length ) ) ; WSManConnectionInfo connectionInfo = new WSManConnectionInfo ( false , servername , cfg . WsMan . Port , " " + cfg . WsMan . AppName , cfg . WsMan . ShellUri , null , cfg . WsMan . TimeOut ) ; SPRunSpace = RunspaceFactory . CreateRunspace ( connectionInfo ) ; connectionInfo . AuthenticationMechanism = AuthenticationMechanism . NegotiateWithImplicitCredential ; string psscript = string . Concat ( " " , " " , " " , " " ) ; SPPowerShell = PowerShell . Create ( ) ; SPPowerShell . Runspace = SPRunSpace ; SPRunSpace . Open ( ) ; PSCommand command = new PSCommand ( ) ; command . AddCommand ( " " ) ; command . AddParameter ( " " , " " ) ; command . AddParameter ( " " , buffer ) ; command . AddCommand ( " " ) ; command . AddParameter ( " " , " " ) ; command . AddParameter ( " " , filePath ) ; SPPowerShell . Commands = command ; SPPowerShell . AddScript ( psscript ) ; SPPowerShell . Invoke ( ) ; } } finally { if ( SPRunSpace != null ) SPRunSpace . Close ( ) ; if ( SPPowerShell != null ) SPPowerShell . Dispose ( ) ; } }
PushRemoteConfiguration method implmentation
Push Configuration file cache to Remote server using wsman
PushRemoteConfiguration method implmentation Push Configuration file cache to Remote server using wsman
cfg
MFAConfig
servername
string