Stew 0 Posted May 5, 2020 I have been tasked with updating login verification in a number of Delphi applications to use Active Directory rather than the existing method of reading from an internal db table. I have never used AD in any application before, so I have been looking on line for helpful files/components that will allow me to access basic user attributes in AD. Everything I have come across so far is relatively old and frequently the links that are cited no longer work. Does anybody know of helpful AD access components, please? I m using XE3. Thanks for any pointers Share this post Link to post
Anders Melander 1783 Posted May 5, 2020 12 minutes ago, Stew said: Does anybody know of helpful AD access components, please? You don't need any components. Just use the COM interface: https://docs.microsoft.com/windows/win32/adsi/active-directory-service-interfaces-adsi I haven't worked with AD but my guess is that you just need to import the relevant type library and work from there (Component > Import Component...): but start by reading the documentation. Share this post Link to post
mvanrijnen 123 Posted May 5, 2020 That or just find some information on how to access a LDAP server, AD is an extended LDAP server. (if you search delphi ldap activedirectory, you will find examples) Share this post Link to post
FredS 138 Posted May 5, 2020 (edited) 6 hours ago, Stew said: any pointers Once you have the type library imported see: ADsOpenObject Edited May 5, 2020 by FredS Share this post Link to post
Stew 0 Posted May 6, 2020 Thank you all for the helpful advice. I have had some trouble trying to import the Active DS Type Library (registry problem), but nothing that cannot be sorted out today. In the meantime, following your general reading suggestions, I have been able to use ADO to access LDAP through OpenQuery and now have a working two-stage authentication process, first to check that the username/password combination is valid, then to verify membership and permissions within an AD group. Actually didn't take me nearly as long as I had feared it might, and although the current solution is probably not the best it will suffice until I can fix the other problems and familiarise myself further with the workings of AD. Thanks again for your helpful replies. Share this post Link to post
Diego Carvalho 0 Posted December 2, 2022 Good morning. I'm having the same difficulty accessing my delphi application in Active Directory. Could you show me how you achieved this integration? Share this post Link to post
aehimself 396 Posted December 2, 2022 Var TokenHandle: THandle; Begin If LogonUser(PChar(UserEdit.Text), PChar(DomainEdit.Text), PChar(PasswordEdit.Text), LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, TokenHandle) Then Try // Credentials are valid... // In case needed: If ImpersonateLoggedOnUser(TokenHandle) Then Try // Do stuff in the context of user Finally RevertToSelf; End; Finally CloseHandle(TokenHandle); End; End; User must have network login right to the PC, though. Share this post Link to post