|
楼主 |
发表于 2007-7-20 17:29:29
|
显示全部楼层
上面的程序在新区中运行有时报错有时又不报,很奇怪。
看平台的域用户验证过程,其实实质只要获取登录机器的帐号就行了,其他的好像都没有用。如果这样可能会带来一点安全隐患。
static function TINIT.LoginUseAD: Boolean;
var
I: Integer;
o: object;
disp: System.dispatchhelper;
s, domain, pdc, username: string;
person: Org.TPerson;
domains: IXMLDOMNodeList;
domainNode: IXMLDOMElement;
pdcip: array of string;
begin
Result := False;
try
o := ComObj.CreateOleObject('WinNTSystemInfo');
try
disp := TDispatchHelper.Create(o);
domain := disp.PropertyGet('DomainName', []) as System.String;
if domain = '' then
Exit;
[B] // pdc := disp.PropertyGet('PDC', []) as System.String;[/B]
username := disp.PropertyGet('UserName', []) as System.String;
if username = '' then
Exit;
finally
(o as System.IDisposable).Dispose;
end;
[B] { domains := SysSrv.SysService.Config.Element.getElementsByTagName('domain');
for I := 0 to domains.length - 1 do
begin
domainNode := domains.item[I] as IXMLDOMElement;
s := ObjectHelper.ToString(domainNode.getAttribute('name'), '');
if SysUtils.SameText(s, domain) then
begin
s := ObjectHelper.ToString(domainNode.getAttribute('pdcip'), '');
if s <> '' then
begin
pdcip := s.Split([';', ',', ' ']);
if not (pdcip as IList).Contains(jsSysUtils.GetComputerIPStr(pdc)) then
Exit;
end;
s := ObjectHelper.ToString(domainNode.getAttribute('account'), domain);
BizSys.BizSystem.ClientAccount := s; }[/B]
s := Opr.OperatorLoader.FindPersonID(username, '', False);
if s = '' then
Exit;
person := Org.OrgSys.OrgSystem.FindPerson(s);
if person = nil then
Exit;
Result := TSystemCore.Logon(person.ID, person.Password);
Exit;
[B] // end;
// end;[/B]
except
end;
end; |
|