Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How to validate a domain user?


This question is answered.


Permlink Replies: 1 - Last Post: Apr 12, 2017 2:40 PM Last Post By: Thomas Horstmann
Brian Wheatley

Posts: 60
Registered: 2/5/01
How to validate a domain user?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 12, 2017 10:14 AM
Hello,

I'm building an application which will prompt the user to enter their domain user name and password. How do I validate the user's credentials?

In other words, what is the Delphi equivalent of...

bool valid = false;

using (PrincipalContext context = new PrincipalContext(ContextType.Domain))
{
valid = context.ValidateCredentials( username, password );
}
Thomas Horstmann

Posts: 4
Registered: 10/14/03
Re: How to validate a domain user?
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 12, 2017 2:40 PM   in response to: Brian Wheatley in response to: Brian Wheatley
Brian Wheatley wrote:
Hello,

I'm building an application which will prompt the user to enter their domain user name and password. How do I validate the user's credentials?

In other words, what is the Delphi equivalent of...

bool valid = false;

using (PrincipalContext context = new PrincipalContext(ContextType.Domain))
{
valid = context.ValidateCredentials( username, password );
}

Maybe helpfull:

uses
System.Classes,
System.DateUtils,
System.SysUtils,
Winapi.Windows ;
...
function CheckDomainPassword
( const iUser : String ;
const iDomain : String ;
const iPassword : String ) : Boolean ;
var
iToken : THandle ;
begin
Result := LogonUser(PChar(iUser),PChar(iDomain),PChar(iPassword),LOGON32_LOGON_NETWORK,LOGON32_PROVIDER_DEFAULT,iToken) ;
if Result = True then CloseHandle(iToken) ;
end ;
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02