08-30-2021, 02:45 PM
(This post was last modified: 09-29-2021, 03:01 PM by mikel.pahl.)
Thanks,
with comInitialization= ciNormal or ciMultiThreaded adsGetObject works fine !
BUT if password and user are correct adsOpenObject now returns not zero . Variable ap ist filled correct.
Returnvalues are like: 71498898, 75889652 or 74120338
with comInitialization= ciNormal or ciMultiThreaded adsGetObject works fine !
BUT if password and user are correct adsOpenObject now returns not zero . Variable ap ist filled correct.
Returnvalues are like: 71498898, 75889652 or 74120338
Code:
function AuthADUser (aUser,aPassword : string) : boolean;
var
ADSerg: HRESULT;
ap : string;
User : IADsUser;
begin
ADSerg:=0;
ap:=SearchUser (aUser);
result:=(length(ap)>0);
if not result then
begin
MessageDlg('Benutzer nicht gefunden',mtInformation,[MBOK],0);
end;
if result then
begin
try
ADSerg:=adshlp.ADsOpenObject(ap, aUser,aPassword, 1, IID_IADsUser,user);
result:=(ADSerg=s_OK);
except
on e :eoleException do
begin
result:=false;
MessageDlg('Name oder Passwort sind falsch !',mtInformation,[MBOK],0);
end
else
begin
result:=false;
MessageDlg('Name oder Passwort sind falsch !',mtInformation,[MBOK],0);
end;
end;
end;
if result then
begin
user.GetInfo;
result:=(user.EmailAddress<>'');
end
end;
function TIWUserSession.CheckUser(const aUserName, aPassword: string): Boolean;
begin
Result := FAuthenticated;
if not Result then begin
FAuthenticated := AuthADUser(aUserName,aPassword); // do your username/password validation here
Result := FAuthenticated;
end;
end;