简体   繁体   English

使用Unicode的AD身份验证

[英]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实现

  1. Have anyone a working version for Delphi 2009+ (unicode)? 有没有适用于Delphi 2009+(统一码)的工作版本?
  2. Have anyone a working sample with simple AD Authentication processing(eg. validating) domain\\userid and password? 是否有人通过简单的AD身份验证处理(例如,验证)域\\用户名和密码来工作?

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.

相关问题 使用Delphi 6处理Unicode字符 - Handling of Unicode Characters using Delphi 6 EInvalidPointer异常,因为在数组中使用Unicode字符 - Exception EInvalidPointer because using Unicode chars in array 在DELPHI XE2中使用Unicode字符 - Using Unicode characters with Delphi XE2 在非Unicode Delphi 7上使用TNT控件将Delphi VirtualKey转换为WideString / UNICODE - Delphi VirtualKey to WideString/UNICODE using TNT controls on non-unicode Delphi 7 使用Delphi 2009下载并保存任何网页为Unicode吗? - Download and save any web page as Unicode, using Delphi 2009? 使用NTQuerySystemInformation / NtQueryInformationFile / NtQueryObject获取进程使用的Unicode文件名 - Get Unicode filenames used by a process using NTQuerySystemInformation/NtQueryInformationFile/NtQueryObject 使用Delphi 2010替换UTF-8文件中的Unicode字符 - Replacing a unicode character in UTF-8 file using delphi 2010 无法使用Delphi ZeosLib和Delphi 7将Unicode插入SQL Server 2008中 - Unable to insert Unicode into SQL Server 2008 using Delphi ZeosLib and Delphi 7 使用Delphi打开ANSI文件并保存Unicode文件 - Open an ANSI file and Save a a Unicode file using Delphi Delphi:使用身份验证下载文件的应用程序 - Delphi : application to download the files using the authentication
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM