Esempio n. 1
0
        private bool IsValid()
        {
            string username = Convert.ToString(fld_txtUsername.EditValue);

            if (string.IsNullOrEmpty(username))
            {
                MessageBox.Show("Tên đăng nhập không được bỏ trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            ADUsersController objUsersController = new ADUsersController();
            ADUsersInfo       existingUser       = (ADUsersInfo)objUsersController.GetObjectByName(username);

            if (existingUser != null && existingUser.ADUserID != ADUsers.ADUserID)
            {
                MessageBox.Show("Tên đăng nhập đã được sử dụng. Vui lòng chọn tên đăng nhập khác!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
            if (ADUsers.ADUserID == 0)
            {
                if (String.IsNullOrEmpty(ADUsers.ADPassword))
                {
                    MessageBox.Show("Mật khẩu không đc để trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }

            //if (!string.IsNullOrEmpty(objUsersInfo.ADPassword) && objUsersInfo.ADPassword != fld_txtConfirmPassword.Text)
            //{
            //    MessageBox.Show(UserManagementLocalizedResources.PasswordNotMatchMessage, "Thông báo" MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    return false;
            //}
            return(false);
        }
Esempio n. 2
0
        public void Initialize(String strUser1, String strUser2)
        {
            User1         = strUser1;
            User2         = strUser2;
            EmployeeName1 = strUser1;
            EmployeeName2 = strUser2;

            ADUsersInfo user1Info = userCtrl.GetObjectByNo(User1) as ADUsersInfo;
            ADUsersInfo user2Info = userCtrl.GetObjectByNo(User2) as ADUsersInfo;

            if (user1Info != null && user1Info.FK_HREmployeeID.HasValue)
            {
                HREmployeesInfo emp1Info = employeeCtrl.GetObjectByID(user1Info.FK_HREmployeeID.Value) as HREmployeesInfo;
                if (emp1Info != null)
                {
                    EmployeeName1 = emp1Info.Name;
                }
            }
            if (user2Info != null && user2Info.FK_HREmployeeID.HasValue)
            {
                HREmployeesInfo emp2Info = employeeCtrl.GetObjectByID(user2Info.FK_HREmployeeID.Value) as HREmployeesInfo;
                if (emp2Info != null)
                {
                    EmployeeName2 = emp2Info.Name;
                }
            }
            CheckPlaySound();
            LoadChatContents(true);
        }
Esempio n. 3
0
        public static bool IsAuthenticated(string strUser, string strPassword)
        {
            ADUsersController ADUserCtrl = new ADUsersController();
            ADUsersInfo       UserInfo   = (ADUsersInfo)ADUserCtrl.GetObjectByName(strUser);

            return(UserInfo != null && UserInfo.ADPassword.Equals(new Crypto().Encrypt(strPassword)));
        }
Esempio n. 4
0
        public static bool IsAuthenticated(string username, string password, out string strMessage)
        {
            strMessage = string.Empty;
            ADUsersController adUsersController = new ADUsersController();
            ADUsersInfo       objUsersInfo      = (ADUsersInfo)adUsersController.GetObjectByName(username);

            if (objUsersInfo == null)
            {
                return(false);
            }

            if (!objUsersInfo.ADUserActiveCheck)
            {
                strMessage = "Tài khoản của bạn đã bị khóa. Vui lòng thử lại sau!";
                return(false);
            }

            if (!objUsersInfo.ADPassword.Equals(VinaUtil.EncryptMD5Hash(password)))
            {
                strMessage = "Tài khoản hoặc mật khẩu không chính xác. Vui lòng thử lại!";
                return(false);
            }
            VinaApp.CurrentUserName = objUsersInfo.ADUserName;
            VinaApp.CurrentUserInfo = objUsersInfo;
            return(true);
        }
Esempio n. 5
0
 public guiManageUser(ADUsersInfo objUsersInfo)
 {
     InitializeComponent();
     ADUsers = objUsersInfo;
     fld_txtUsername.Enabled = true;
     if (ADUsers.ADUserID > 0)
     {
         fld_txtUsername.Enabled = false;
     }
 }
        public ActionResult RejectDocument(int iInboxItemID, string strMessenger, string strRemark)
        {
            AuthConfig.SetMailConfig();
            ADInboxItemsInfo InboxItem = (ADInboxItemsInfo) new ADInboxItemsController().GetObjectByID(iInboxItemID);

            InboxItem.ADInboxItemMessage = strMessenger;
            InboxItem.ADInboxItemRemark  = strRemark;
            ADUsersInfo CurrentUserInfo = (ADUsersInfo) new ADUsersController().GetObjectByName(Convert.ToString(AuthConfig.GetSession("CurrentUser")));

            MailUtil.RejectDocument(InboxItem, CurrentUserInfo);
            return(null);
        }
Esempio n. 7
0
        public void AddUser()
        {
            UserManagementEntities entity       = (UserManagementEntities)CurrentModuleEntity;
            ADUsersInfo            objUsersInfo = new ADUsersInfo();
            guiManageUser          guiUser      = new guiManageUser(objUsersInfo);

            //guiUser.BringToFront();
            //guiUser.loca
            if (guiUser.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            objUsersInfo = guiUser.ADUsers;
            ADUsersController objUsersController = new ADUsersController();

            objUsersController.CreateObject(objUsersInfo);
            InvalidateUserList();
        }
Esempio n. 8
0
        public void DeleteUser()
        {
            UserManagementEntities entity       = (UserManagementEntities)CurrentModuleEntity;
            ADUsersInfo            objUsersInfo = entity.ADUserList[entity.ADUserList.CurrentIndex];

            if (objUsersInfo == null)
            {
                return;
            }

            DialogResult rs = MessageBox.Show("Bạn có chắn chắn muốn xóa người dùng này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (rs != DialogResult.Yes)
            {
                return;
            }

            ADUsersController objUsersController = new ADUsersController();

            objUsersController.DeleteObject(objUsersInfo.ADUserID);
            InvalidateUserList();
        }
Esempio n. 9
0
        public void EditUser()
        {
            UserManagementEntities entity       = (UserManagementEntities)CurrentModuleEntity;
            ADUsersInfo            objUsersInfo = entity.ADUserList[entity.ADUserList.CurrentIndex];

            if (objUsersInfo == null)
            {
                return;
            }

            guiManageUser guiUser = new guiManageUser(objUsersInfo);

            if (guiUser.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            objUsersInfo = guiUser.ADUsers;
            ADUsersController objUsersController = new ADUsersController();

            objUsersController.UpdateObject(objUsersInfo);
            InvalidateUserList();
        }
Esempio n. 10
0
        public static void LogOn()
        {
            DevExpress.Skins.SkinManager.EnableFormSkins();
            DevExpress.LookAndFeel.LookAndFeelHelper.ForceDefaultLookAndFeelChanged();

            ADUsersInfo objUsersInfo = VinaApp.CurrentUserInfo;

            if (VinaApp.CurrentUserInfo != null)
            {
                VinaApp.SetApplicationStyle(CurrentUserInfo.ADUserStyle, CurrentUserInfo.ADUserStyleSkin);
            }

            InitToolbarImageList();

            InitMainFormTitle();

            InitLookupTables();

            InitMenuOfMainForm();

            //InitCurrencyList();
        }
Esempio n. 11
0
 public ActionResult ResetPassword(ResetPassWordModel model)
 {
     if (ModelState.IsValid)
     {
         string strCMND = model.CMND;
         string strSrv  = model.Server;
         AuthConfig.ConnectionAuth(strSrv);
         AccountModels acc  = new AccountModels();
         ADUsersInfo   user = acc.GetEmployeeUserByIDNumber(strCMND);
         if (user == null)
         {
             ModelState.AddModelError("ResetPasswordFaild", "The CMND provided is incorrect.");
         }
         else
         {
             AuthConfig.SetSession("UserName", user.ADUserName);
             return(Redirect("ChangePassword"));
         }
     }
     ViewBag.Title      = Properties.Settings.Default.WebTitle;
     ViewData["lstSrv"] = new LoginModel().InitCompanys();
     return(View(model));
 }
Esempio n. 12
0
        public static string LogIn(string strSrv, string strUser, string strPassword, System.DateTime dt)
        {
            ConnectionAuth(strSrv);
            if (!SqlDatabaseHelper.TestConnection())
            {
                return("Không kết nối được CSDL! Vui lòng liên hệ người quản trị!");
            }
            ADUsersController ADUserCtrl = new ADUsersController();

            CurrenUserInfo = (ADUsersInfo)ADUserCtrl.GetObjectByName(strUser);
            ADUserConfigsInfo UserCfgInfo = new ADUserConfigsController().GetFirstObject() as ADUserConfigsInfo;

            GMCWebApp.GetLocalMachineInfo();
            if (CurrenUserInfo != null && CurrenUserInfo.ADUserIsLockedCheck)
            {
                return("Tài khoản đăng nhập này đã bị khóa! Vui lòng liên hệ người quản trị!");
            }
            else if (IsUserLoggedIn(strUser))
            {
                GEUserAuditsInfo UserAudisInfo = new GEUserAuditsController().GetGEUserAuditsByADUserName(strUser);
                return(string.Format("Người dùng này đã đăng nhập trên máy {0} với địa chỉ IP {1}!", UserAudisInfo.GEUserAuditPCName, UserAudisInfo.GEUserAuditIP));
            }
            else if (IsAuthenticated(strUser, strPassword))
            {
                if (!new ADUserGroupsController().IsExist(CurrenUserInfo.ADUserGroupID))
                {
                    return(string.Format("Nhóm người dùng của tài khoản {0} không tồn tại trên hệ thống!", strUser));
                }
                else
                {
                    SetCurrentUserLogin(dt);
                    SaveUserAuditLogin("Login");
                    if (UserCfgInfo != null && UserCfgInfo.ADUserConfigPassDayExpires > 0)
                    {
                        if (new ADUserPassHistorysController().IsOldPassExpired(CurrenUserInfo.ADUserID, UserCfgInfo.ADUserConfigPassDayExpires))
                        {
                            return("Mật khẩu đã hết hạn! Vui lòng đổi mật khẩu mới!");
                        }
                    }
                }
            }
            else
            {
                int iCountLoginFail = new GEUserAuditsController().GetCountLoginFail(strUser, "WebHome", dt);
                iCountLoginFail++;
                if (UserCfgInfo != null && (iCountLoginFail >= UserCfgInfo.ADUserConfigMaxLogonCount) && UserCfgInfo.ADUserConfigMaxLogonCount > 0)
                {
                    SaveUserAuditLogin("LoginFailLock", 0, strUser);
                    if (CurrenUserInfo != null)
                    {
                        CurrenUserInfo.ADUserIsLockedCheck = true;
                        CurrenUserInfo.ADUserLockedInfo    = Environment.MachineName + ", " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
                        ADUserCtrl.UpdateObject(CurrenUserInfo, true, "ADUserIsLockedCheck", "ADUserLockedInfo");
                    }
                    return(string.Format("Vượt quá số lần đăng nhập sai cho phép! Tài khoản đăng nhập {0} đã bị khóa", strUser));
                }
                SaveUserAuditLogin("LoginFail", 0, strUser);
                string strError = "Tên đăng nhập/ Mật khẩu không hợp lệ!";
                if (UserCfgInfo != null && UserCfgInfo.ADUserConfigMaxLogonCount > 0)
                {
                    strError += string.Format(" Còn lại {0} lần thử", UserCfgInfo.ADUserConfigMaxLogonCount - iCountLoginFail);
                }
                return(strError);
            }
            ADConfigValueUtility.InitGlobalConfigValueTables();
            return("");
        }