示例#1
0
        private void StartNewProcess(CredentialManagement.BaseCredentialsPrompt promptResult)
        {
            string commandName = $"{Process.GetCurrentProcess().MainModule.FileName} --machine={machineHostname}";
            string username    = null;
            string domain      = null;

            string[] splitCheck = promptResult.Username.Split(new char[] { '\\' });
            if (splitCheck.Length > 1)
            {
                username = splitCheck[1];
                domain   = splitCheck[0];
            }
            else
            {
                username = splitCheck[0];
            }
            RunAs.StartProcess(username, domain, promptResult.Password, RunAs.LogonFlags.NetworkCredentialsOnly, null, commandName, RunAs.CreationFlags.NewProcessGroup, null);

            machineHostname = Environment.MachineName;
            toolStripConnectToTextBox.Text = machineHostname;
        }
示例#2
0
        private void StartNewProcess(BaseCredentialsPrompt promptResult)
        {
            string username, domain;

            var splitCheck = promptResult.Username.Split('\\');

            if (splitCheck.Length > 1)
            {
                username = splitCheck[1];
                domain   = splitCheck[0];
            }
            else
            {
                username = splitCheck[0];
                domain   = null;
            }

            var commandName = $"{Process.GetCurrentProcess().MainModule?.FileName} --machine={machineHostname}";

            RunAs.StartProcess(username, domain, promptResult.Password, RunAs.LogonFlags.NetworkCredentialsOnly, null, commandName, RunAs.CreationFlags.NewProcessGroup, null);

            Application.Exit();
        }