托尼·卡杜托为我提供了“协同”解决办法:
我把这 st倒在我制造的认证标语中,我不想说整个话,因为其中还有其他一些非相关的 st子。
This should get you going, the key is to concatenate the AD username with @your.ad.domain.name
After you succesfully bind, you can then do searches against the AD directory by supplying a base DN
and using the search function of the ldapsend unit.
I have found this to be faster than other methods and it s solid. You do need to get the trunk version of
synapse so it works with the later versions of delphi.
uses ldapsend
var
fldap:tldapsend;
fad_domain,ausername,apassword:string;
begin
ausername:= your AD username ;
apassword:= your AD password ;
fldap := TLDAPSend.Create;
fad_domain:= your.ad.domain ;
fldap.TargetHost:=fad_domain;
//next line is the key to getting AD authentication working
fldap.UserName := ausername+ @ +fad_domain;
fldap.Password := apassword;
try
try
if fldap.Login then
if fldap.Bind then
begin
//user is succesfully authenticated at this point
end else
raise exception.Create( LDAP bind failed. );
except
on e:exception do
//whatever
end;
finally
fldap.logout;
freeandnil(fldap);
end;
end;
感谢托尼!