was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

69 Visitors Online


 
...Benutzer einer NT Domain ermitteln?
Autor: Henrik Jonsson
[ Tip ausdrucken ]  

Tip Bewertung (5):  
     


// The NetUserEnum function provides information about all user accounts on a server.

type
  
USER_INFO_1 = record
    
usri1_name: LPWSTR;
    usri1_password: LPWSTR;
    usri1_password_age: DWORD;
    usri1_priv: DWORD;
    usri1_home_dir: LPWSTR;
    usri1_comment: LPWSTR;
    usri1_flags: DWORD;
    usri1_script_path: LPWSTR;
  end;
  lpUSER_INFO_1 = ^USER_INFO_1;

function NetUserEnum(ServerName: PWideChar;
  Level,
  Filter: DWORD;
  var Buffer: Pointer;
  PrefMaxLen: DWORD;
  var EntriesRead,
  TotalEntries,
  ResumeHandle: DWORD): Longword; stdcallexternal 'netapi32.dll';

function NetApiBufferFree(pBuffer: PByte): Longint; stdcallexternal
'netapi32.dll';

{...}

procedure TForm1.Button1Click(Sender: TObject);
var
  
EntiesRead: DWORD;
  TotalEntries: DWORD;
  UserInfo: lpUSER_INFO_1;
  lpBuffer: Pointer;
  ResumeHandle: DWORD;
  Counter: Integer;
  NetApiStatus: LongWord;
begin
  
ResumeHandle := 0;
  repeat
    
// NetApiStatus :=
    // NetUserEnum(PChar('\\NT-Domain'), 1, 0, lpBuffer, 0,EntiesRead, TotalEntries, ResumeHandle);
    
NetApiStatus := NetUserEnum(nil, 1, 0, lpBuffer, 0, EntiesRead,
      TotalEntries, ResumeHandle);
    UserInfo     := lpBuffer;

    for Counter := 0 to EntiesRead - 1 do
    begin
      
listbox1.Items.Add(WideCharToString(UserInfo^.usri1_name) + ' --> ' +
        WideCharToString(UserInfo^.usri1_comment));
      Inc(UserInfo);
    end;

    NetApiBufferFree(lpBuffer);
  until (NetApiStatus <> ERROR_MORE_DATA);
end;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners