Neos.IdentityServer 3.0/Neos.IdentityServer.Common/Neos.IdentityServer.MultiFactor.Utilities.cs
/// <summary>
/// PushRemoteNotification method implmentation
/// Push Remote Notification using wsman
/// </summary>
PushRemoteNotification method implmentation
Push Remote Notification using wsman
PushRemoteNotification method implmentation Push Remote Notification using wsman
internal static void PushRemoteNotification(MFAConfig cfg, string servername, NotificationsKind kind, string message)
        {
            Runspace SPRunSpace = null;
            PowerShell SPPowerShell = null;
            try
            {
                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;
                SPPowerShell = PowerShell.Create();
                SPPowerShell.Runspace = SPRunSpace;
                SPRunSpace.Open();
                string psscript = string.Concat("[System.Reflection.Assembly]::Load('Neos.IdentityServer.MultiFactor.Administration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=175aa5ee756d2aa2');",
                                                "[Neos.IdentityServer.MultiFactor.Administration.NotificationsEvents]::PopNotification($kind, $message);");
                PSCommand command = new PSCommand();
                command.AddCommand("Set-Variable");
                command.AddParameter("Name", "kind");
                command.AddParameter("Value", (byte)kind);
                command.AddCommand("Set-Variable");
                command.AddParameter("Name", "message");
                command.AddParameter("Value", message);
                SPPowerShell.Commands = command;
                SPPowerShell.AddScript(psscript);
                SPPowerShell.Invoke();
            }
            finally
            {
                if (SPRunSpace != null)
                    SPRunSpace.Close();
                if (SPPowerShell != null)
                    SPPowerShell.Dispose();
            }
        }
internal static void PushRemoteNotification ( MFAConfig cfg , string servername , NotificationsKind kind , string message ) { Runspace SPRunSpace = null ; PowerShell SPPowerShell = null ; try { 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 ; SPPowerShell = PowerShell . Create ( ) ; SPPowerShell . Runspace = SPRunSpace ; SPRunSpace . Open ( ) ; string psscript = string . Concat ( " " , " " ) ; PSCommand command = new PSCommand ( ) ; command . AddCommand ( " " ) ; command . AddParameter ( " " , " " ) ; command . AddParameter ( " " , ( byte ) kind ) ; command . AddCommand ( " " ) ; command . AddParameter ( " " , " " ) ; command . AddParameter ( " " , message ) ; SPPowerShell . Commands = command ; SPPowerShell . AddScript ( psscript ) ; SPPowerShell . Invoke ( ) ; } finally { if ( SPRunSpace != null ) SPRunSpace . Close ( ) ; if ( SPPowerShell != null ) SPPowerShell . Dispose ( ) ; } }
PushRemoteNotification method implmentation
Push Remote Notification using wsman
PushRemoteNotification method implmentation Push Remote Notification using wsman
cfg
MFAConfig
servername
string
kind
NotificationsKind
message
string