Пример #1
0
        private void cbAuthenticationModes_SelectedIndexChanged(object sender, EventArgs e)
        {
            AuthenticationModeEnum authMode = ((ComboBoxItem <AuthenticationModeEnum>)cbAuthenticationModes.SelectedItem).Item;

            switch (authMode)
            {
            case AuthenticationModeEnum.OnlyPassword:
                cbAuthenticationModes.SelectedItem = cbAuthenticationModes.Items[1];
                gbPassword.Enabled = true;
                pUsers.Enabled     = false;
                break;

            case AuthenticationModeEnum.UsernameAndPassword:
                cbAuthenticationModes.SelectedItem = cbAuthenticationModes.Items[2];
                gbPassword.Enabled = false;
                pUsers.Enabled     = true;
                break;

            case AuthenticationModeEnum.Off:
                cbAuthenticationModes.SelectedItem = cbAuthenticationModes.Items[0];
                gbPassword.Enabled = false;
                pUsers.Enabled     = false;
                break;
            }
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthenticationForm"/> class.
 /// </summary>
 /// <param name="authMode">The authentication mode.</param>
 public AuthenticationForm(AuthenticationModeEnum authMode) : this()
 {
     if (authMode != AuthenticationModeEnum.UsernameAndPassword)
     {
         tbUsername.Enabled = false;
     }
 }
Пример #3
0
        private void commonEnumComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmdAuthMode.EditValue == null)
            {
                return;
            }

            //Seteamos la contraseña en blanco
            txtPassword.Text = string.Empty;

            //Validamos el tipo de Enumeración seleccionada
            switch ((AuthenticationModeEnum)Convert.ToInt32(cmdAuthMode.EditValue))
            {
            case AuthenticationModeEnum.WindowsIntegrated:
                EnableDisableFieldsByAuthenticationMode(true);
                txtUserName.Text    = Environment.UserName;
                txtUserName.Enabled = false;
                _IsEnvironmentUser  = true;
                cmbDominios.Enabled = false;
                EnableDisablePassword();
                btnChangePassword.Enabled = false;
                break;

            case AuthenticationModeEnum.Mixed:
                EnableDisableFieldsByAuthenticationMode(true);
                cmbDominios.Enabled       = false;
                txtPassword.Enabled       = true;
                btnChangePassword.Enabled = true;
                break;

            case AuthenticationModeEnum.LDAP:
                EnableDisableFieldsByAuthenticationMode(true);
                cmbDominios.Enabled       = true;
                txtPassword.Enabled       = true;
                btnChangePassword.Enabled = false;
                break;

            default:
                MessageViewer.Show("El modo de autenticación seleccionado no se encuentra configurado aún.");
                EnableDisableFieldsByAuthenticationMode(false);
                txtUserName.Enabled       = false;
                txtPassword.Enabled       = false;
                cmbDominios.Enabled       = false;
                btnChangePassword.Enabled = false;
                break;
            }

            //Seteamos en blanco los ErrorProviders
            dxErrorProvider1.SetError(txtUserName, string.Empty);
            dxErrorProvider1.SetError(txtPassword, string.Empty);

            txtUserName.Focus();

            //Guardamos el Modo de autenticación seleccionado
            _AuthenticationMode = (AuthenticationModeEnum)Enum.Parse(typeof(AuthenticationModeEnum), cmdAuthMode.EditValue.ToString());
        }
Пример #4
0
        /// <summary>
        /// Realiza la autenticacion del usuario para determinar si puede ingresar al sistema o no.-
        /// </summary>
        /// <param name="pName">Nombre de usuario ingresado en la pantalla de Login</param>
        /// <param name="pPassword">Clave</param>
        /// <param name="pAuthenticationMode">Modo de autenticación</param>
        /// <param name="pDomain">Dominio</param>
        /// <param name="pIsEnvironmentUser">Variable booleana que permite determinar si es el usuario que esta logueado en Windows</param>
        protected static void AuthenticateUser(String pName, String pPassword, AuthenticationModeEnum pAuthenticationMode, String pDomain, Boolean pIsEnvironmentUser)
        {
            //SecurityServiceCalls controller = _Controllerfactory.GetObject();

            //Se saco la validación de abajo ya que ahora se ve si el usuario tiene roles y si no tiene se vuelve a la pantalla de Login
            //y el FormBase.IndentityUserInfo tiene valores y no se volvería a recargar si se cambia de usuario en el Login.

            //if (FormBase.IndentityUserInfo == null)
            FormBase.IndentityUserInfo = SecurityServiceCalls.AuthenticateUser(pName, pPassword, pAuthenticationMode, pDomain, pIsEnvironmentUser);
            if (FormBase.IndentityUserInfo != null)
            {
                FormBase.IndentityUserInfo.AuthenticationMode = pAuthenticationMode;
            }
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pName"></param>
        /// <param name="pPassword"></param>
        /// <param name="pAuthenticationMode"></param>
        /// <param name="pDomain"></param>
        /// <param name="pIsEnvironmentUser"></param>
        /// <returns></returns>
        internal static User AuthenticateUser(String pName, String pPassword, AuthenticationModeEnum pAuthenticationMode, String pDomain, Boolean pIsEnvironmentUser)
        {
            AuthenticateUserReq req = new AuthenticateUserReq();

            req.BusinessData.IsEnvironmentUser  = pIsEnvironmentUser;
            req.BusinessData.UserName           = pName;
            req.BusinessData.Password           = pPassword;
            req.BusinessData.Domain             = pDomain;
            req.BusinessData.AuthenticationMode = pAuthenticationMode;

            AuthenticateUserRes res = _ClientServiceBase.ExecuteService <AuthenticateUserReq, AuthenticateUserRes>(WrapperSecurityProvider, req);

            if (res.Error != null)
            {
                throw Fwk.Exceptions.ExceptionHelper.ProcessException(res.Error);
            }
            ///TODO: arreglar AuthenticateUserRes
            return(res.BusinessData.UserInfo);
        }
Пример #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pName"></param>
        /// <param name="pPassword"></param>
        /// <param name="pAuthenticationMode"></param>
        /// <param name="pDomain"></param>
        /// <param name="pIsEnvironmentUser"></param>
        /// <returns></returns>
        internal static User AuthenticateUser(String pName, String pPassword, AuthenticationModeEnum pAuthenticationMode, String pDomain, Boolean pIsEnvironmentUser)
        {
            AuthenticateUserReq req = new AuthenticateUserReq();

            req.BusinessData.IsEnvironmentUser = pIsEnvironmentUser;
            req.BusinessData.UserName = pName;
            req.BusinessData.Password = pPassword;
            req.BusinessData.Domain = pDomain;
            req.BusinessData.AuthenticationMode = pAuthenticationMode;

            AuthenticateUserRes res = _ClientServiceBase.ExecuteService<AuthenticateUserReq, AuthenticateUserRes>(WrapperSecurityProvider,req);

            if (res.Error != null)
                throw Fwk.Exceptions.ExceptionHelper.ProcessException(res.Error);
            ///TODO: arreglar AuthenticateUserRes
            return  res.BusinessData.UserInfo;
        }
Пример #7
0
        /// <summary>
        /// Realiza la autenticacion del usuario para determinar si puede ingresar al sistema o no.-
        /// </summary>
        /// <param name="pName">Nombre de usuario ingresado en la pantalla de Login</param>
        /// <param name="pPassword">Clave</param>
        /// <param name="pAuthenticationMode">Modo de autenticación</param>
        /// <param name="pDomain">Dominio</param>
        /// <param name="pIsEnvironmentUser">Variable booleana que permite determinar si es el usuario que esta logueado en Windows</param>
        protected static void AuthenticateUser(String pName, String pPassword, AuthenticationModeEnum pAuthenticationMode, String pDomain, Boolean pIsEnvironmentUser)
        {
            //SecurityServiceCalls controller = _Controllerfactory.GetObject();

            //Se saco la validación de abajo ya que ahora se ve si el usuario tiene roles y si no tiene se vuelve a la pantalla de Login 
            //y el FormBase.IndentityUserInfo tiene valores y no se volvería a recargar si se cambia de usuario en el Login.

            //if (FormBase.IndentityUserInfo == null)
            FormBase.IndentityUserInfo = SecurityServiceCalls.AuthenticateUser(pName, pPassword, pAuthenticationMode, pDomain, pIsEnvironmentUser);
            if(FormBase.IndentityUserInfo!=null)
                FormBase.IndentityUserInfo.AuthenticationMode = pAuthenticationMode;
        }
Пример #8
0
        private static void SectionHandler_OnConfigurationChanged(object sender, EventArgs e)
        {
            CategoryPropertyItem rootItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemoteDesktopConfiguration.Settings.CategoryPropertyItems, CONFIG_ROOT);

            if (rootItem != null)
            {
                AuthenticationModeEnum authMode = AuthenticationModeEnum.OnlyPassword;
                if (ConfigurationAccessHelper.ParseEnumValue <AuthenticationModeEnum>(rootItem.PropertyItems, CONFIG_AUTHENTICATION_MODE, ref authMode))
                {
                    AuthenticationMode = authMode;
                }

                string moduleStore = string.Empty;
                if (ConfigurationAccessHelper.ParseStringValue(rootItem.PropertyItems, CONFIG_AUTHENTICATION_MODULE_STORE, ref moduleStore))
                {
                    mAuthenticationModuleStore = moduleStore;
                }

                bool propagateOnNetwork = true;
                if (ConfigurationAccessHelper.ParseBooleanValue(rootItem.PropertyItems, CONFIG_PROPAGATE_ON_NETWORK, ref propagateOnNetwork))
                {
                    PropagateServiceOnTheNetwork = propagateOnNetwork;
                }

                DesktopShareModeEnum desktopShareMode = DesktopShareModeEnum.Shared;
                if (ConfigurationAccessHelper.ParseEnumValue <DesktopShareModeEnum>(rootItem.PropertyItems, CONFIG_DESKTOP_SHARE_MODE, ref desktopShareMode))
                {
                    DesktopShareMode = desktopShareMode;
                }

                bool acceptKeyboardAndMouseInputFromClients = true;
                if (ConfigurationAccessHelper.ParseBooleanValue(rootItem.PropertyItems, CONFIG_ACCEPT_INPUTS_FROM_CLIENTS, ref acceptKeyboardAndMouseInputFromClients))
                {
                    AcceptKeyboardAndMouseInputFromClients = acceptKeyboardAndMouseInputFromClients;
                }

                int desktopImageClipWidth = Consts.DEFAULT_DESKTOP_IMAGE_CLIP_SIZE;
                if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_DESKTOP_IMAGE_CLIP_WIDTH, Consts.MINIMAL_CLIP_SIZE, int.MaxValue, ref desktopImageClipWidth))
                {
                    DesktopImageClipWidth = desktopImageClipWidth;
                }

                int desktopImageClipHeight = Consts.DEFAULT_DESKTOP_IMAGE_CLIP_SIZE;
                if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_DESKTOP_IMAGE_CLIP_WIDTH, Consts.MINIMAL_CLIP_SIZE, int.MaxValue, ref desktopImageClipHeight))
                {
                    DesktopImageClipHeight = desktopImageClipHeight;
                }

                int clientsPerServiceThreads = Consts.DEFAULT_CLIENTS_PER_SERVICE_THREADS;
                if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_DESKTOP_IMAGE_CLIP_WIDTH, Consts.MINIMAL_CLIENTS_PER_SERVICE_THREADS, int.MaxValue, ref clientsPerServiceThreads))
                {
                    ClientsPerServiceThreads = clientsPerServiceThreads;
                }

                int maximumFailedLoginAttempt = Consts.DEFAULT_MAXIMUM_FAILED_LOGIN_ATTEMPT;
                if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_MAXIMUM_FAILED_LOGIN_ATTEMPT, 0, int.MaxValue, ref maximumFailedLoginAttempt))
                {
                    MaximumFailedLoginAttempt = maximumFailedLoginAttempt;
                }

                int blackListTimeout = Consts.DEFAULT_BLACKLIST_TIMEOUT_IN_MINUTES;
                if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_BLACKLIST_TIMEOUT, 0, int.MaxValue, ref blackListTimeout))
                {
                    BlackListTimeout = blackListTimeout;
                }

                int imageClipQuality = Consts.DEFAULT_IMAGE_CLIP_QUALITY;
                if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_IMAGE_CLIP_QUALITY, 10, 100, ref imageClipQuality))
                {
                    DefaultImageClipQuality = imageClipQuality;
                }

                int mouseMoveSendingInterval = Consts.DEFAULT_MOUSE_MOVE_SEND_INTERVAL;
                if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_MOUSE_MOVE_SEND_INTERVAL, 0, int.MaxValue, ref mouseMoveSendingInterval))
                {
                    MouseMoveSendInterval = mouseMoveSendingInterval;
                }
            }

            Raiser.CallDelegatorBySync(EventConfigurationChanged, new object[] { null, EventArgs.Empty });
        }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthModeResponseArgs"/> class.
 /// </summary>
 /// <param name="mode">The mode.</param>
 public AuthModeResponseArgs(AuthenticationModeEnum mode)
 {
     this.AuthenticationMode = mode;
 }
Пример #10
0
        private void ConnectEventHandler(object sender, EventArgs e)
        {
            AuthenticationModeEnum  mode       = AuthenticationModeEnum.UsernameAndPassword;
            RemoteDesktopClientForm clientForm = new RemoteDesktopClientForm();

            try
            {
                clientForm.Connect(connectControl.Locator.ChannelId, connectControl.SelectedProvider.RemoteEndPoint);
                mode = clientForm.GetAuthenticationMode();
            }
            catch (Exception)
            {
                clientForm.Dispose();
                MessageBox.Show(this, "Failed to connect to the remote host.", Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            mActiveWindows.Add(clientForm);
            clientForm.FormClosed += new FormClosedEventHandler(ClientForm_FormClosed);
            clientForm.Show(this);

            while (true)
            {
                switch (mode)
                {
                case AuthenticationModeEnum.OnlyPassword:
                case AuthenticationModeEnum.UsernameAndPassword:
                    using (AuthenticationForm authForm = new AuthenticationForm(mode))
                    {
                        if (authForm.ShowDialog(clientForm) == System.Windows.Forms.DialogResult.OK)
                        {
                            try
                            {
                                if (HandleLoginResult(clientForm, clientForm.Login(authForm.Username, authForm.Password)))
                                {
                                    return;
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(clientForm, string.Format("Failed to login. Reason: {0}", ex.Message), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                if (!clientForm.IsConnected)
                                {
                                    clientForm.Close();
                                    //clientForm.Dispose();
                                    return;
                                }
                            }
                        }
                        else
                        {
                            clientForm.Close();
                            clientForm.Dispose();
                            return;
                        }
                    }
                    break;

                case AuthenticationModeEnum.Off:
                {
                    try
                    {
                        if (HandleLoginResult(clientForm, clientForm.Login(string.Empty, string.Empty)))
                        {
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        clientForm.Close();
                        clientForm.Dispose();
                        MessageBox.Show(clientForm, string.Format("Failed to login. Reason: {0}", ex.Message), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                break;
                }
            }
        }