繁体   English   中英

使用Unicode的AD身份验证

[英]AD authentication using Unicode

刚刚使用以下命令在C#中实现了AD身份验证:

DirectoryEntry entry = 
  new DirectoryEntry(_path, domainAndUsername, pwd, AuthenticationTypes.Secure);

其中_path是LDAP:// +完全限定的域名(例如,域控制器的ip)。

现在,我必须使用Delphi进行相同的操作。 因此,我在http://www.freemeg.com/index.php/projects/projects-2/15-delphi-ldap-authentication-component上找到了所罗门出色的Delphi 2007 LDAP实现

  1. 有没有适用于Delphi 2009+(统一码)的工作版本?
  2. 是否有人通过简单的AD身份验证处理(例如,验证)域\\用户名和密码来工作?

在C#中,很好的部分是我不需要遍历AD-我只是通过LDAP执行一级搜索-只是检查用户是否已通过身份验证。

Tony Caduto为我提供了Synapse解决方案:

我从创建的身份验证对象中删除了这些内容,因为其中包含许多其他不相关的内容,所以我不想发布整个内容。

这应该可以帮助您,关键是用'@ your.ad.domain.name'连接AD用户名。成功绑定后,您可以通过提供基本DN并使用的搜索功能来对AD目录进行搜索。 ldapsend单位。

我发现这比其他方法要快,而且很可靠。 您确实需要获得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;

谢谢托尼!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM