delphi - 如何在 Delphi 中对 Windows 域用户进行身份验证?

标签 delphi ldap

我正在尝试在 Delphi 中对 Windows 域用户进行身份验证。我使用了下面的代码。
如果我使用 ADS_SECURE_AUTHENTICATION , 它说

Logon failure: unknown user name or bad password



如果我使用 ADS_USE_SSL 它是说

An invalid dn syntax has been specified


function TLoginForm.Authenticate( pUser, pPassword,pDomain: WideString): Boolean;
Var
 aUser,Obj : IAdsUser;
 infoback : HRESULT;
begin
 Try       
   CoInitialize(nil);
   infoback := 0;    

   infoback  := ADsOpenObject(Format('LDAP://%s',[pDomain]),Format('%s',[pUser]),pPassword,ADS_USE_SSL,IAds,aUser);
   CoUninitialize;
   Result := true;
   ShowMessage('Success');
     // here retrieve the information needed
 Except
   On E:Exception do
   Begin
      Result := false;
      ShowMessage(E.Message);
      aUser := Nil;
   End;
 End
end;

提前致谢

最佳答案

只要我使用完全合格的域 Controller ,下面的代码就对我有用:

var
  hr: HResult;
  pObject : IADs;
  Pwd : String;
begin
      Pwd := 'Hello';
      hr := ADsOpenObject('LDAP://'+ FQDC,
                       'Administrator',
                       Pwd,
                       ADS_SECURE_AUTHENTICATION,
                       IID_IADs,
                       pObject);
      OleCheck(hr);
      pObject := nil;
end;

more on the name and path formats..

关于delphi - 如何在 Delphi 中对 Windows 域用户进行身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39041992/

相关文章:

linux - 如何使用多个过滤器进行 ldapsearch?

Delphi 中的 Json 和 System.JSON

delphi - Indy "Could not load SSL Library"与 Delphi 2007/Apache

Delphi - 列表索引越界(4)

java - Spring Security Ldap,只登录指定组的用户

c# - LDAP 与 ADSI 在操作 Active Directory 用户方面的比较

delphi - 在 Delphi 中查找未使用的(又名 "dead")代码

web-services - 德尔福7的WSDL导入问题

用于选择具有特定成员的组的 LDAP 搜索过滤器

java - 在 Java 6(GlassFish 3 服务器)中设置 SSL