首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Unicode的广告认证

问使用Unicode的广告认证
EN

Stack Overflow用户
提问于 2011-10-12 16:50:39
回答 1查看 2.8K关注 0票数 2

刚刚在C#中实现了AD身份验证,使用:

代码语言:javascript
复制
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上找到了所罗门卓越的Delphi2007LDAP实现

  1. 有一个Delphi 2009+ (unicode)的工作版本吗?
  2. 有一个带有简单AD身份验证处理的工作示例(例如。验证)域\userid和密码?

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

EN

回答 1

Stack Overflow用户

发布于 2011-11-10 18:35:31

托尼·卡普托为我提供了Synapse解决方案:

我把这些东西从我创建的身份验证对象中删除,我不想发布全部内容,因为里面还有很多其他无关的东西。

这应该会让您开始工作,关键是在成功绑定之后,将AD用户名与'@your.ad.domain.name‘连接起来,然后可以通过提供基本DN并使用ldapsend单元的搜索函数对AD目录进行搜索。

我发现这个方法比其他方法更快,而且是可靠的。您确实需要获得synapse的主干版本,因此它可以与delphi的后期版本一起工作。

代码语言:javascript
复制
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;

感谢托尼!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7743601

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档