Autor Beitrag
Assun
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 26


D2005 PE
BeitragVerfasst: So 24.07.05 12:14 
Hi !

Mein Server funtkioniert soweit schon ganz gut ! Doch wie kann kann ich realisieren, dass sich Benutzer nur mit gültigem Passwort + Nutzername einloggen können ?

Also ich dachte ich speichere Die vorhandenen Nutzer + Passw in der Lokalen Registry des Servers.

Dann dachte ich, dass ich einfach wenn sich jemand einlogg, einen Wert namens LoggedIn := True; setze.

Doch dabei entsteht das Problem, dass der server ja nicht weiss wer nun eingeloggt ist !

Das würde bedeuten, dass wenn einer der erlaubten Benutzer sich einloggt, dass dann der Wert auf True steht und dann die anderen zugelassenen (in der registry gespeicherten) bentutzer einfach drauf zugreifen könnten ohne sich eingeloggt zu haben !

hat jemand eine Idee wie sich das lösen lässt ?

Vielen Dank

mfg,

Assun
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: So 24.07.05 12:38 
du könntest ja den LogIn über den HTTP Login realisieren. dann wir bei jedem HTTP Request an deinen Server der Username und das Passwort mitgeschickt und du weisst immer wer es gerade ist, der da den Request stellt.

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Assun Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 26


D2005 PE
BeitragVerfasst: So 24.07.05 14:23 
Ich habe nun diesen Code:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
procedure TForm1.IdHTTPServer1CommandGet(AContext: TIdContext;
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
Var
  Stream: TFilestream;
  TheString : String;

  begin
if ARequestInfo.Document = '/'  then
begin
  try
  if ARequestinfo.Username = 'Assun' then
  begin
  inc(i);
  Caption := ('Bereits' + IntToStr(i) + 'Aufrufe');
  AResponseInfo.ContentType   := 'text/html';
  Stream := TfileStream.Create('Admin/test.htm', fmOpenRead or fmShareDenyWrite );
  AResponseInfo.ContentStream := Stream;
  setlength(TheString, stream.size);
  stream.Read(TheString[1], stream.size);
  end
  except
  Exit;
  end;
  end
else
if ARequestInfo.Document = '/test.jpg'  then
begin
  try
  AResponseInfo.ContentType   := 'image/jpeg';
  Stream := TfileStream.Create('Admin/test.jpg', fmOpenRead or fmShareDenyWrite );
  AResponseInfo.ContentStream := Stream;
  except
  Exit;
  end;
end;


doch ich weiss nicht wie ich den Usernamen nun übergeben soll !

Weiss da jemand rat?
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mo 25.07.05 16:19 
du musst quasi dem browser erst die anweisung geben, dass er nachfragen soll:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
     if (ARequestinfo.authUsername = '') or (ARequestinfo.authPassword = '') then begin
        AResponseInfo.AuthRealm := 'Geschützter Bereich';
        exit;
     end;

_________________
In the beginning was the word.
And the word was content-type: text/plain.