簡體   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