在 系统空间\系统运行库\系统初始化
static function TINIT.InternalLogon(AParam: String): Boolean;
const
MaxLogonFailCount = 3;
LogonErrorMsg01 = '登录失败';
LogonErrorMsg02 = '用户不存在或者密码错误,请注意大小写,密码是区分大小写的。';
LogonErrorMsg03 = '对不起,您已经 %d 次登录失败,将退出系统。';
var
I: Integer;
lAccept: Boolean;
sUser, sPass, lAccountID, lUserID, lMessage: String;
lIniFile: TIniFile;
lIniFileName: String;
lPerson: Org.TPerson;
lLogonPerson: Org.TPersonMember;
begin
if not FInternalDisableAutoLogon then
begin
if UseAD and LoginUseAD then
begin
Result := True;
Exit;
end;
if AParam <> '' then
begin
Result := TAutoLogon.AutoLogon(AParam, lUserID, lMessage, lAccountID);
if not Result then
begin
Dialogs.MessageDlg(lMessage, TMsgDlgType.mtError, [TMsgDlgBtn.mbOK] , 0);
Exit;
end;
BizSys.BizSystem.ClientAccount := lAccountID;
if not SysUtils.SameText(lUserID, 'System') then
begin
lPerson := Org.OrgSys.OrgSystem.FindPerson(lUserID);
Result := (not Opr.IsSystemManager(lUserID) or ExtUtils.ClientAccountExist(BizSys.BizSystem.ClientAccount)) and
TSystemCore.Logon(lPerson.LoginID, lPerson.Password);
end else begin
Result := TSystemCore.Logon(lUserID, ExtUtils.ReadUserSysMngerPassWord);
end;
Exit;
end;
end;
lIniFileName := jsCommon.ModulePath + 'Business.ini';
lIniFile := TIniFile.Create(lIniFileName);
try
sUser := lIniFile.ReadString('System', 'LastLogonUserID', '');
sPass := '';
I := MaxLogonFailCount;
repeat
if I <> MaxLogonFailCount then
Dialogs.MessageDlg(LogonErrorMsg02, TMsgDlgType.mtError, [TMsgDlgBtn.mbOK] , 0);
{ 旧调用模式
lAccept := TSystemCore.SystemInterface.ShowLogonForm(sUser, sPass);}
lAccept := TSystemCore.SystemInterface.ShowLogonFormEx(sUser, sPass, lLogonPerson);
if not lAccept then Break;
// IE嵌入登陆 sUser的返回可以为空(这个方案不好,为了做嵌入IE登陆)
if sUser <> '' then
begin
lAccountID := sUser;
lUserID := JSCommon.SplitStr('@', lAccountID);
BizSys.BizSystem.ClientAccount := lAccountID;
Result := (not Opr.IsSystemManager(lUserID) or ExtUtils.ClientAccountExist(BizSys.BizSystem.ClientAccount)) and
TSystemCore.LogonEx(lUserID, sPass, lLogonPerson);
end
else
Result := True;
if Result then Break;
Dec(I);
until I = 0;
if Result then
try
//这里登陆成功
lIniFile.WriteString('System', 'LastLogonUserID', sUser);
except
end
else
if lAccept then
Dialogs.MessageDlg(SysUtils.Format(LogonErrorMsg03, [MaxLogonFailCount]),
TMsgDlgType.mtError, [TMsgDlgBtn.mbOK] , 0);
finally
lIniFile.Free;
end;
end; |