Пример #1
0
        private bool SelectComputer(bool bConnect)
        {
            Logger.Log(String.Format(
                           "LUGPlugin.SelectComputer: hn: {0}",
                           _hn));

            SelectComputerDialog selectDlg = new SelectComputerDialog(
                _hn.hostName,
                _hn.creds.UserName);

            if (selectDlg.ShowDialog() == DialogResult.OK)
            {
                int result = (int)LUGAPI.WinError.ERROR_SUCCESS;

                _hn.hostName       = selectDlg.GetHostname();
                _hn.creds.UserName = selectDlg.GetUsername();
                _hn.creds.Password = selectDlg.GetPassword();

                if (!selectDlg.UseDefaultUserCreds() || bConnect)
                {
                    // Only add a connection if we are not using default creds.
                    result = (int)LUGAPI.NetAddConnection(
                        _hn.hostName,
                        _hn.creds.UserName,
                        _hn.creds.Password);

                    if (Configurations.currentPlatform != LikewiseTargetPlatform.Windows &&
                        result == (int)LUGAPI.WinError.ERROR_FILE_NOT_FOUND)
                    {
                        result = (int)LUGAPI.WinError.ERROR_SUCCESS;
                    }

                    if (result != (int)LUGAPI.WinError.ERROR_SUCCESS)
                    {
                        MessageBox.Show(
                            "Unable to connect to system:\n" + ErrorCodes.WIN32String(result),
                            "Likewise Administrative Console",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Exclamation);

                        return(false);
                    }
                }

                return(true);
            }

            return(false);
        }
Пример #2
0
        private bool SelectComputer()
        {
            Logger.Log(String.Format(
                           "LUGPlugin.SelectComputer: hn: {0}",
                           _hn));

            SelectComputerDialog selectDlg = new SelectComputerDialog(
                _hn.hostName,
                _hn.creds.UserName);

            if (selectDlg.ShowDialog() == DialogResult.OK)
            {
                int result = (int)ErrorCodes.WIN32Enum.ERROR_SUCCESS;

                _hn.hostName = selectDlg.GetHostname();

                if (!selectDlg.UseDefaultUserCreds())
                {
                    _hn.creds.UserName = selectDlg.GetUsername();
                    _hn.creds.Password = selectDlg.GetPassword();

                    // Only add a connection if we are not using default creds.
                    result = (int)LUGAPI.NetAddConnection(
                        _hn.hostName,
                        _hn.creds.UserName,
                        _hn.creds.Password);

                    if (result != (int)ErrorCodes.WIN32Enum.ERROR_SUCCESS)
                    {
                        MessageBox.Show(
                            "Unable to connect to system:\n" + ErrorCodes.WIN32String(result),
                            "Likewise Administrative Console",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Exclamation);

                        return(false);
                    }
                }

                // This function is going to set _hn.IsConnectionSuccess... return
                // that value for this selection.
                ConnectToDomain();

                return(_hn.IsConnectionSuccess);
            }

            return(false);
        }
Пример #3
0
        public void SetContext(IContext ctx)
        {
            Hostinfo hn = ctx as Hostinfo;

            Logger.Log(String.Format("LUGPlugin.SetHost(hn: {0})",
                                     hn == null ? "null" : hn.hostName), Logger.manageLogLevel);

            _hn = hn;

            if (_hn == null)
            {
                _hn = new Hostinfo();
            }

            if (_pluginNode != null &&
                (!String.IsNullOrEmpty(hn.hostName)))
            {
                uint result = LUGAPI.NetAddConnection(
                    _hn.hostName,
                    _hn.creds.UserName,
                    _hn.creds.Password);

                if (Configurations.currentPlatform != LikewiseTargetPlatform.Windows &&
                    result == (uint)LUGAPI.WinError.ERROR_FILE_NOT_FOUND)
                {
                    result = (uint)LUGAPI.WinError.ERROR_SUCCESS;
                }

                hn.IsConnectionSuccess = false;
                if (result == (uint)LUGAPI.WinError.ERROR_SUCCESS)
                {
                    hn.IsConnectionSuccess = true;
                }

                _pluginNode.SetContext(_hn);
            }
        }