Active Directory authentication using Delphi

Active Directory authentication using Delphi

I am using TLDAPSend for active directory authentication and using following code :
var
    fldap:TLDAPSend;
    fad_domain,userName,password:string;
begin
   fldap := TLDAPSend.Create;
  fldap.TargetHost := fad_domain;
  fldap.UserName := ausername+'@'+fad_domain;
  fldap.Password := apassword;
 if fldap.Login then
    if fldap.Bind then
      ShowMessage('Logged in successfully')
    else
      ShowMessage('Error in Bind')
  else
    ShowMessage('Error in Login');
end;

This code is giving unpredictable results.
sometimes its authenticate user to AD and sometime fails.
Thanks in advance.

Comments