/// <summary>
        /// 认证管理{D515E09B-E299-47e0-BF19-EDFDB6E4C775}
        /// </summary>
        /// <param name="name"></param>
        /// <param name="password"></param>
        /// <param name="domain"></param>
        /// <returns></returns>
        public NeuIdentity Authenticate(string name, string password, string domain)
        {
            //根据帐户获得患者信息
            User _user = SecurityService.GetUserByAccount(name);

            if (_user == null)
            {
                throw new Exception("没有该用户注册信息!");
            }
            //{D515E09B-E299-47e0-BF19-EDFDB6E4C775}
            string pass = Neusoft.HisCrypto.HisDecrypt.Encrypt(password);
            //string pass = Neusoft.HisCrypto.DESCryptoService.DESEncrypt(password,Neusoft.FrameWork.Management.Connection.DESKey);


            bool _isMatch;

            //判断密码是否相符
            _isMatch = string.Equals(_user.Password, pass);

            if (!_isMatch)
            {
                throw new Exception("输入密码不正确!");
            }

            NeuIdentity _identity = new NeuIdentity(_user, "DAO", true);

            return(_identity);
        }
示例#2
0
        public static int Login(string account, string password)
        {
            NeuPrincipal _principal = null;
            NeuIdentity  _identity  = null;

            if (Program.isMessageShow == true)
            {
                Program.isMessageShow = false;
                return(-1);
            }
            //认证
            PrivilegeService proxy = new PrivilegeService();

            try
            {
                _identity = proxy.Authenticate(account, password, "");
                ///
                ///查询该用户拥有的角色
                IList <Role> _roles;

                using (proxy as IDisposable)
                {
                    //表更改了,所以修改了SQL语句(张凯钧)Security.Org.GetRoleByUserID
                    _roles = proxy.QueryRole(_identity.User.Id);
                }

                if (_roles == null | _roles.Count == 0)
                {
                    Program.isMessageShow = false;
                    MessageBox.Show("该用户没有进行角色授权!");
                    Program.isMessageShow = true;
                    return(-1);
                }

                _principal = new NeuPrincipal(_identity, _roles);
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    Program.isMessageShow = false;
                    MessageBox.Show(ex.Message);
                    Program.isMessageShow = true;
                }
                else
                {
                    SystemErrorForm _error = new SystemErrorForm(ex);
                    _error.ShowDialog();
                }

                return(-1);
            }

            if (_principal.Identity.IsAuthenticated)
            {
                //加载选择角色科室界面
                Role _role = SelectLoginRole((_principal.Identity as NeuIdentity).User, _principal.Roles);

                if (_role == null)
                {
                    Application.Exit();
                    //{AE0687E4-FE13-4b00-8865-738F84B74BB2}
                    return(-1);
                }

                //通过认证以后,给当前角色赋值;
                _principal.CurrentRole = _role;


                //设置登录时间
                _principal.LoginTime = Neusoft.FrameWork.Function.NConvert.ToDateTime(new Neusoft.FrameWork.Management.DataBaseManger().GetSysDateTime());

                //设置当前操作员信息
                SetLoginUser((_principal.Identity as NeuIdentity).User, (Neusoft.FrameWork.Models.NeuObject)_principal.CurrentRole, _principal.CurrentRole.UnitId);
            }
            return(0);
        }