Solved

MSLogon in delphi?

Posted on 2001-07-16
4
219 Views
Last Modified: 2012-06-27
Hello all,

I want to write an application that is able to authenticate against the nt domain. does anybody have some code examples for me?

Spank you and have a very nice day!
0
Comment
Question by:aluiken
4 Comments
 
LVL 17

Expert Comment

by:geobul
ID: 6285535
Hi,

You can use NetUserChangePassword API function. Fill its parameters with the entered password both as the old and the new one. If the function fails, the password is wrong or you can't check it now. Otherwize it's OK.

Regards, Geo
0
 
LVL 1

Author Comment

by:aluiken
ID: 6285617
Can you please provide me with an code example? (I know I'm stupid :) )
0
 
LVL 21

Accepted Solution

by:
gemarti earned 200 total points
ID: 6286703
Here is an example:

Create a new application

Put three edit components, 4 labels and one button.

Paste this code in the unit

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Button1: TButton;
    Button2: TButton;
    Label4: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  uname: PChar;
  Paswd: PChar;
  Domain: PChar;
  phToken: Cardinal;
  result : integer;
begin
  uname := PChar(Edit1.Text);
  pasWd := PChar(Edit2.Text);
  Domain:= PChar(Edit3.Text);
  if LogOnUser(uname,Domain,paswd,LOGON32_LOGON_NETWORK,LOGON32_PROVIDER_DEFAULT,phToken) then
    label4.caption := 'Logon Failed'
  else label4.caption := 'Logon successful';
end;

end.
0
 
LVL 3

Expert Comment

by:vladh
ID: 6286986
aluiken,

Seems that what you want is to authenticate, i.e. submit user name and password to the domain but not to actually log the user in. If this is correct, I can email you the DLL that does the job. The dll has one function, you call it from your app specifying the domain, username and password and get 'success' or 'failire' as the return.

If you want it, leave your email here.

Thanks
Vlad
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question