Solved

MSLogon in delphi?

Posted on 2001-07-16
4
218 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

810 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