我正在尝试在 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/