[英]AD authentication using Unicode
Just implemented AD Authentication in C# using: 刚刚使用以下命令在C#中实现了AD身份验证:
DirectoryEntry entry =
new DirectoryEntry(_path, domainAndUsername, pwd, AuthenticationTypes.Secure);
where _path is LDAP://
+ full qualified domain name (eg. the ip of the domain controler). 其中_path是
LDAP://
+完全限定的域名(例如,域控制器的ip)。
Now I have to do the same using Delphi. 现在,我必须使用Delphi进行相同的操作。 So I found Solomon's excelent Delphi 2007 LDAP implementation at http://www.freemeg.com/index.php/projects/projects-2/15-delphi-ldap-authentication-component
因此,我在http://www.freemeg.com/index.php/projects/projects-2/15-delphi-ldap-authentication-component上找到了所罗门出色的Delphi 2007 LDAP实现
In C# the nice part is that I don't need to traverse the AD - I simply performs a one level search via LDAP - just to check if the user is authenticated. 在C#中,很好的部分是我不需要遍历AD-我只是通过LDAP执行一级搜索-只是检查用户是否已通过身份验证。
Tony Caduto have provided me with a Synapse solution: Tony Caduto为我提供了Synapse解决方案:
I cut this stuff out of a authentication object I created, I don't want to post the whole thing since there is a bunch of other non related stuff in it. 我从创建的身份验证对象中删除了这些内容,因为其中包含许多其他不相关的内容,所以我不想发布整个内容。
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. 这应该可以帮助您,关键是用'@ your.ad.domain.name'连接AD用户名。成功绑定后,您可以通过提供基本DN并使用的搜索功能来对AD目录进行搜索。 ldapsend单位。
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.
您确实需要获得synapse的主干版本,以便它与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;
Thanks to Tony!!!! 谢谢托尼!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.