/// <summary> /// 执行窗体.参数:loginInfo为登录对象ss /// </summary> public static void Execute(LoginUser user, ModifyPwdType type) { frmModifyPwd form = new frmModifyPwd(); form.txtAccount.Text = user.Account; form._user = user; form._type = type; form.ShowDialog(); }
public bool Login(LoginUser loginUser) { string novellAccount = NovellLdapTools.NovellWhoAmI(); //获取当前Novell用户及组. 通过groups获取用户权限数据 //string[] groups = NovellLdapTools.NovellGetGroups(ref novellAccount); if (string.IsNullOrEmpty(novellAccount)) throw new CustomException("获取Novell本地用户登录资料失败!"); _User.Text = novellAccount; //显示当前Novell帐号 _User.Update(); loginUser.Account = novellAccount; IBridge_User bridge = BridgeFactory.CreateUserBridge(); //调用数据访问层的接口检查用户登录 DataTable dt = bridge.Login(loginUser, Char.Parse(LoginUserType.N.ToString())); if (dt.Rows.Count == 0) throw new CustomException("Novell用户'" + novellAccount + "'没有建立权限关联!"); DataRow row = dt.Rows[0]; Loginer user = new Loginer(); user.Account = ConvertEx.ToString(row[tb_sys_User.FAccount]); user.AccountName = ConvertEx.ToString(row[tb_sys_User.FUserName]); user.FlagAdmin = ConvertEx.ToString(row[tb_sys_User.FFlagAdmin]); user.Email = ConvertEx.ToString(row[tb_sys_User.FMail]); user.Fid = ConvertEx.ToString(row[tb_sys_User.FID]); user.LoginTime = DateTime.Now; user.MachineName = GetComputerinfo.GetHostName(); user.IPAddress = GetComputerinfo.GetIP(); user.CardNo = ConvertEx.ToString(row[tb_sys_User.FCardNo]); user.DbType = loginUser.DbType; user.DataSetName = loginUser.DataSetDBName; Loginer.CurrentUser = user;//保存当前用户 IBridge_CommonService comBridge = BridgeFactory.CreateCommonServiceBridge(); comBridge.WriteLogOP("0", "0", "登录系统", ""); SystemAuthentication.UserAuthorities = bridge.Getb_sys_UserAuthorities(user);//下载用户权限 return true; }
/// <summary> /// 用户刷卡登录 /// </summary> /// <param name="loginUser">登录用户信息</param> /// <param name="LoginUserType">登录类型</param> /// <returns></returns> public DataTable LoginByCard(LoginUser loginUser, char LoginUserType) { string strErr = ""; string sql = ""; //用户名为空 if (loginUser.CardNo == string.Empty) { strErr = "卡号不能为空!"; } if (!"S,W,N".Contains(LoginUserType.ToString())) { strErr = "无法识别的登录类型!"; } //Windows域 if (LoginUserType == 'W') { if (loginUser.DbType == DbAcessTyp.SQLServer) { sql = "select * from sys_user where fdomainName like '%'+(select FAccount from sys_User where FCardNo='" + loginUser.CardNo + "')+'@%'"; } else if (loginUser.DbType == DbAcessTyp.Oracle) { sql = "select * from sys_user where fdomainName like '%'||(select FAccount from sys_User where FCardNo='" + loginUser.CardNo + "')||'@%'"; } } //Novell域 if (LoginUserType == 'N') { if (loginUser.DbType == DbAcessTyp.SQLServer) { sql = "select * from sys_user where fnovellaccount like '%'+(select FAccount from sys_User where FCardNo='" + loginUser.CardNo + "')+'.%'"; } else if (loginUser.DbType == DbAcessTyp.Oracle) { sql = "select * from sys_user where fnovellaccount like '%'||(select FAccount from sys_User where FCardNo='" + loginUser.CardNo + "')||'.%'"; } } //系统 if (LoginUserType == 'S') { sql = "select * from sys_User where FCardNo='" + loginUser.CardNo + "'"; } if (strErr.Trim() != string.Empty) throw new CustomException(strErr); //抛出异常 DataTable ds = new DataBaseLayer(_Loginer.DBName).ExecuteQueryDataTable(sql); if (ds.Rows.Count == 1) { if (_Loginer.DbType == DbAcessTyp.SQLServer) sql = "UPDATE sys_User SET FFlagOnline='1',FLastLoginTime=GetDate(),FLoginCounter=isnull(FLoginCounter,0) + 1 WHERE FCardNo='" + loginUser.CardNo + "'"; else sql = "UPDATE sys_User SET FFlagOnline='1',FLastLoginTime=sysdate,FLoginCounter=nvl(FLoginCounter,0) + 1 WHERE FCardNo='" + loginUser.CardNo + "'"; new DataBaseLayer(_Loginer.DBName).ExecuteSql(sql); return ds; } else throw new CustomException("请检查卡号!"); //抛出异常 }
private void btnLogin_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; this.SetButtonEnable(false); this.Update();//必须 this.ShowLoginInfo("正在验证用户名及密码"); bllUser.ValidateLogin(txtUser.Text, txtPwd.Text);//检查登录信息 string userID = txtUser.Text; string password = CEncoder.Encode(txtPwd.Text);/*常规加密*/ string dataSetID = cmbDataset.EditValue.ToString();//帐套编号 string dataSetDB = GetDataSetDBName(); string DbType = GetDataDbType(); string dbName = GetDBName(); LoginUser loginUser = new LoginUser(userID, password, dataSetID, dataSetDB); loginUser.DbType = DbType; loginUser.DBName = dbName; Loginer.CurrentUser.DbType = DbType; Loginer.CurrentUser.DBName = dbName; if (_CurrentAuthorization.Login(loginUser)) //调用登录策略 { //if (chkSaveLoginInfo.Checked) this.SaveLoginInfo();//跟据选项保存登录信息 SystemAuthentication.Current = _CurrentAuthorization; //授权成功, 保存当前授权模式 Program.MainForm = new frmMain();//登录成功创建主窗体 Program.MainForm.InitUserInterface(new LoadStatus(lblLoadingInfo)); this.DialogResult = DialogResult.OK; //成功 this.Close(); //关闭登陆窗体 } else { this.ShowLoginInfo("登录失败,请检查用户名和密码!"); Msg.Warning("登录失败,请检查用户名和密码!"); } } catch (CustomException ex) { this.SetButtonEnable(true); this.ShowLoginInfo(ex.Message); Msg.Warning(ex.Message); } catch (Exception ex) { this.SetButtonEnable(true); this.ShowLoginInfo("登录失败,请检查用户名和密码!" + ex.Message); Msg.Warning("登录失败,请检查用户名和密码!" + ex.Message); } this.Cursor = Cursors.Default; }
private void VerifyUserByCard() { try { timer1.Stop(); if (string.IsNullOrEmpty(txtCardNo.Text)) { txtCardNo.Text = ""; txtCardNo.Focus(); lblInfo.Text = "请刷卡。。。"; timer1.Start(); return; } this.Cursor = Cursors.WaitCursor; this.SetButtonEnable(false); this.Update();//必须 this.ShowLoginInfo("正在验证卡号"); string cardNo = CEncoder.Encode(txtCardNo.Text);/*常规加密*/ string dataSetID = cmbDataset.EditValue.ToString();//帐套编号 string dataSetDB = GetDataSetDBName(); string DbType = GetDataDbType(); string dbName = GetDBName(); LoginUser loginUser = new LoginUser(cardNo, dataSetID, dataSetDB); loginUser.DbType = DbType; loginUser.DBName = dbName; Loginer.CurrentUser.DbType = DbType; Loginer.CurrentUser.DBName = dbName; if (_CurrentAuthorization.LoginByCard(loginUser)) //调用登录策略 { //if (chkSaveLoginInfo.Checked) this.SaveLoginInfo();//跟据选项保存登录信息 SystemAuthentication.Current = _CurrentAuthorization; //授权成功, 保存当前授权模式 Program.MainForm = new frmMain();//登录成功创建主窗体 Program.MainForm.InitUserInterface(new LoadStatus(lblLoadingInfo)); this.DialogResult = DialogResult.OK; //成功 this.Close(); //关闭登陆窗体 } else { txtCardNo.Text = ""; txtCardNo.Focus(); lblInfo.Text = "登录失败,请检查卡号!"; timer1.Start(); this.ShowLoginInfo("登录失败,请检查卡号!"); //Msg.Warning("登录失败,请检查卡号!"); } } catch (CustomException ex) { this.SetButtonEnable(true); this.ShowLoginInfo(ex.Message); Msg.Warning(ex.Message); txtCardNo.Text = ""; txtCardNo.Focus(); lblInfo.Text = "登录失败,请检查卡号!"; timer1.Start(); } catch (Exception ex) { this.SetButtonEnable(true); this.ShowLoginInfo("登录失败,请检查卡号!" + ex.Message); Msg.Warning("登录失败,请检查卡号!" + ex.Message); txtCardNo.Text = ""; txtCardNo.Focus(); lblInfo.Text = "登录失败,请检查卡号!"; timer1.Start(); } this.Cursor = Cursors.Default; }
private void btnModifyPwd_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { LoginUser user = new LoginUser(); user.Account = txtUser.Text; user.DataSetID = cmbDataset.EditValue.ToString(); user.DataSetDBName = GetDBName(); frmModifyPwd.Execute(user, ModifyPwdType.LoginWindowDirect); }
public DataTable LoginByCard(LoginUser loginUser, char LoginUserType) { using (SGBaseUser_WClient client = SoapClientFactory.CreateSGBaseUser_WClient()) { byte[] loginTicket = WebServiceSecurity.GetLoginTicket(); byte[] login = ZipTools.CompressionObject(loginUser); byte[] receivedData = client.U_LoginByCard(loginTicket, login, LoginUserType); return ZipTools.DecompressionDataSet(receivedData).Tables[0]; } }
public void OnChangePwdClick(object sender, EventArgs e) { DataRow user = gvSummary.GetDataRow(gvSummary.FocusedRowHandle); LoginUser data = new LoginUser(); data.Account = user[tb_sys_User.FAccount].ToString(); data.Password = user[tb_sys_User.FPassword].ToString(); data.DataSetDBName = Loginer.CurrentUser.DBName; data.DataSetID = Loginer.CurrentUser.DataSetID; frmModifyPwd.Execute(data, ModifyPwdType.UserManage); }
public bool LoginByCard(LoginUser loginUser) { string userPrincipalName = DomainLdapTools.GetCurrentUserPrincipalName(); if (string.IsNullOrEmpty(userPrincipalName)) throw new CustomException("获取本地域用户资料失败!"); _User.Text = userPrincipalName; //显示当前Domain帐号 _User.Update(); loginUser.Account = userPrincipalName; IBridge_User bridge = BridgeFactory.CreateUserBridge(); //调用数据访问层的接口检查用户登录 DataTable dt = bridge.LoginByCard(loginUser, Char.Parse(LoginUserType.W.ToString())); if (dt.Rows.Count == 0) throw new CustomException("域用户'" + userPrincipalName + "'没有建立权限关联!"); DataRow row = dt.Rows[0]; Loginer user = new Loginer(); user.Account = ConvertEx.ToString(row[tb_sys_User.FAccount]); user.AccountName = ConvertEx.ToString(row[tb_sys_User.FUserName]); user.FlagAdmin = ConvertEx.ToString(row[tb_sys_User.FFlagAdmin]); user.Email = ConvertEx.ToString(row[tb_sys_User.FMail]); user.Fid = ConvertEx.ToString(row[tb_sys_User.FID]); user.LoginTime = DateTime.Now; user.MachineName = GetComputerinfo.GetHostName(); user.IPAddress = GetComputerinfo.GetIP(); user.CardNo = ConvertEx.ToString(row[tb_sys_User.FCardNo]); user.DbType = loginUser.DbType; user.DataSetName = loginUser.DataSetDBName; Loginer.CurrentUser = user;//保存当前用户 //登录日志 IBridge_CommonService comBridge = BridgeFactory.CreateCommonServiceBridge(); comBridge.WriteLogOP("0", "0", "登录系统", ""); //下载用户权限 SystemAuthentication.UserAuthorities = bridge.Getb_sys_UserAuthorities(user); return true; }
public bool LoginByCard(LoginUser loginUser) { //调用数据访问层的接口检查用户登录 //用户登录前尚未创建Loginer对象,所有传null值 IBridge_User bridge = BridgeFactory.CreateUserBridge(); DataTable data = bridge.LoginByCard(loginUser, Char.Parse(LoginUserType.S.ToString())); if (data.Rows.Count == 0) throw new CustomException("登录失败,请检查卡号!"); DataRow row = data.Rows[0]; //用户实例,登录成功 Loginer user = new Loginer(); user.Account = ConvertEx.ToString(row[tb_sys_User.FAccount]); user.AccountName = ConvertEx.ToString(row[tb_sys_User.FUserName]); user.FlagAdmin = ConvertEx.ToString(row[tb_sys_User.FFlagAdmin]); user.Email = ConvertEx.ToString(row[tb_sys_User.FMail]); user.Fid = ConvertEx.ToString(row[tb_sys_User.FID]); user.LoginTime = DateTime.Now; user.MachineName = GetComputerinfo.GetHostName(); user.IPAddress = GetComputerinfo.GetIP(); user.CardNo = ConvertEx.ToString(row[tb_sys_User.FCardNo]); //参数:dataSet: 帐套编号, 从帐套字典表获取DBName,DataSetID,DataSetName三个字段的值 //给下面三个属性赋值 user.DBName = loginUser.DBName; //重要:在数据层根据DBName设置连接数据库 user.DataSetID = loginUser.DataSetID; user.DbType = loginUser.DbType; user.DataSetName = loginUser.DataSetDBName; Loginer.CurrentUser = user;//保存当前用户 IBridge_CommonService comBridge = BridgeFactory.CreateCommonServiceBridge(); comBridge.WriteLogOP("0", "0", "登录系统", ""); SystemAuthentication.UserAuthorities = bridge.Getb_sys_UserAuthorities(user); //下载用户权限 return true; }
public void Validate(LoginUser user) { if (CheckNoExists(user.Account)) throw new Exception("用户已经存在!"); }
public DataTable Login(LoginUser loginUser, char LoginUserType) { return _MyBridge.Login(loginUser, LoginUserType); }