Hi!
Wie kann ich anhand der
IP, den eingeloggten User im Netzwerk ermitteln?
Christian Seehase hat mir folgenden Code gegeben, der die User anzeigt, ich hätte das Selbe nur gerne so, dass man das anhand der
IP herausbekommt, geht so etwas?
Delphi-Quellcode:
type
NET_API_STATUS = DWORD;
PWKSTA_USER_INFO_0 = ^WKSTA_USER_INFO_0;
WKSTA_USER_INFO_0 = packed record
wkui0_username : PWChar;
end;
function NetWkstaUserEnum(
const servername : PWChar;
const level : DWord;
const bufptr : Pointer;
const prefmaxlen : DWord;
const entriesread : PDWord;
const totalentries : PDWord;
const resumehandle : PDWord
) : NET_API_STATUS; stdcall; external 'netapi32.dll';
function NetApiBufferFree(
const Buffer : Pointer
) : NET_API_STATUS; stdcall; external 'netapi32.dll';
const
NERR_Success = 0;
MAX_PREFERRED_LENGTH = DWORD(-1);
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
pwuiWork : PWKSTA_USER_INFO_0;
pwuiRead : PWKSTA_USER_INFO_0;
dwEntriesRead : DWORD;
dwTotalEntries : DWORD;
i : integer;
dwResult : DWORD;
pwsServer : PWideChar;
begin
pwsServer := '';
dwResult := NetWkstaUserEnum(pwsServer,0,@pwuiRead,MAX_PREFERRED_LENGTH,@dwEntriesRead,@dwTotalEntries,nil);
if dwResult <> NERR_SUCCESS then begin
ShowMessage(SysErrorMessage(dwResult)+#13#10+IntToStr(dwResult));
end;
try
pwuiWork := pwuiRead;
for i := 1 to dwEntriesRead do begin
ShowMessage(pwuiWork.wkui0_username);
inc(pwuiWork);
end;
finally
NetApiBufferFree(pwuiRead);
end;
end;